Manual merge

This commit is contained in:
SaschaNaz
2015-09-04 12:22:15 +09:00
443 changed files with 48360 additions and 39704 deletions
+5 -4
View File
@@ -143,7 +143,8 @@ var harnessSources = harnessCoreSources.concat([
"convertToBase64.ts",
"transpile.ts",
"reuseProgramStructure.ts",
"cachingInServerLSHost.ts"
"cachingInServerLSHost.ts",
"moduleResolution.ts"
].map(function (f) {
return path.join(unittestsDirectory, f);
})).concat([
@@ -157,10 +158,10 @@ var harnessSources = harnessCoreSources.concat([
var librarySourceMap = [
{ target: "lib.core.d.ts", sources: ["core.d.ts"] },
{ target: "lib.dom.d.ts", sources: ["importcore.d.ts", "extensions.d.ts", "intl.d.ts", "dom.generated.d.ts"], },
{ target: "lib.webworker.d.ts", sources: ["importcore.d.ts", "extensions.d.ts", "intl.d.ts", "webworker.generated.d.ts"], },
{ target: "lib.dom.d.ts", sources: ["importcore.d.ts", "intl.d.ts", "dom.generated.d.ts"], },
{ target: "lib.webworker.d.ts", sources: ["importcore.d.ts", "intl.d.ts", "webworker.generated.d.ts"], },
{ target: "lib.scriptHost.d.ts", sources: ["importcore.d.ts", "scriptHost.d.ts"], },
{ target: "lib.d.ts", sources: ["core.d.ts", "extensions.d.ts", "intl.d.ts", "dom.generated.d.ts", "webworker.importscripts.d.ts", "scriptHost.d.ts"], },
{ target: "lib.d.ts", sources: ["core.d.ts", "intl.d.ts", "dom.generated.d.ts", "webworker.importscripts.d.ts", "scriptHost.d.ts"], },
{ target: "lib.core.es6.d.ts", sources: ["core.d.ts", "es6.d.ts"]},
{ target: "lib.es6.d.ts", sources: ["core.d.ts", "es6.d.ts", "intl.d.ts", "dom.generated.d.ts", "dom.es6.d.ts", "webworker.importscripts.d.ts", "scriptHost.d.ts"] },
];
+1 -1
View File
@@ -6,7 +6,7 @@
[![Join the chat at https://gitter.im/Microsoft/TypeScript](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/Microsoft/TypeScript?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[TypeScript](http://www.typescriptlang.org/) is a language for application-scale JavaScript. TypeScript adds optional types, classes, and modules to JavaScript. TypeScript supports tools for large-scale JavaScript applications for any browser, for any host, on any OS. TypeScript compiles to readable, standards-based JavaScript. Try it out at the [playground](http://www.typescriptlang.org/Playground), and stay up to date via [our blog](http://blogs.msdn.com/typescript) and [twitter account](https://twitter.com/typescriptlang).
[TypeScript](http://www.typescriptlang.org/) is a language for application-scale JavaScript. TypeScript adds optional types, classes, and modules to JavaScript. TypeScript supports tools for large-scale JavaScript applications for any browser, for any host, on any OS. TypeScript compiles to readable, standards-based JavaScript. Try it out at the [playground](http://www.typescriptlang.org/Playground), and stay up to date via [our blog](http://blogs.msdn.com/typescript) and [Twitter account](https://twitter.com/typescriptlang).
## Installing
+2653 -12
View File
File diff suppressed because it is too large Load Diff
+2800 -2548
View File
File diff suppressed because it is too large Load Diff
+426 -66
View File
@@ -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<T> {
*/
then<TResult>(onfulfilled?: (value: T) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => TResult | PromiseLike<TResult>): PromiseLike<TResult>;
then<TResult>(onfulfilled?: (value: T) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => void): PromiseLike<TResult>;
}
}
interface ArrayLike<T> {
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<number>, 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<number>): 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<number>, 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<number>, 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<number>): 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<number>, 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<number>) => 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<U>(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<U>(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<number>): Uint8ClampedArray;
new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint8ClampedArray;
/**
* The size in bytes of each element in the array.
*/
BYTES_PER_ELEMENT: number;
/**
* Returns a new array from a set of elements.
* @param items A set of elements to include in the new array object.
*/
of(...items: number[]): Uint8ClampedArray;
/**
* Creates an array from an array-like or iterable object.
* @param arrayLike An array-like or iterable object to convert to an array.
* @param mapfn A mapping function to call on every element of the array.
* @param thisArg Value of 'this' used to invoke the mapfn.
*/
from(arrayLike: ArrayLike<number>, 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<number>, 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<number>): 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<number>, 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<number>, 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<number>): 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<number>, 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<number>, 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<number>): 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<number>, 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<number>, 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<number>): 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<number>, 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<number>, 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<number>): 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<number>, 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<number>, 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<number>): 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<number>, 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<Element>;
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<Element>;
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;
+37 -2318
View File
File diff suppressed because it is too large Load Diff
+2839 -2562
View File
File diff suppressed because it is too large Load Diff
+142 -2325
View File
File diff suppressed because it is too large Load Diff
+5257 -4097
View File
File diff suppressed because it is too large Load Diff
+7100 -5426
View File
File diff suppressed because it is too large Load Diff
+352 -300
View File
@@ -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<string>;
}
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;
+8238 -6498
View File
File diff suppressed because it is too large Load Diff
+352 -301
View File
@@ -23,6 +23,7 @@ declare namespace ts {
contains(fileName: string): boolean;
remove(fileName: string): void;
forEachValue(f: (v: T) => void): void;
clear(): void;
}
interface TextRange {
pos: number;
@@ -35,293 +36,294 @@ declare namespace ts {
MultiLineCommentTrivia = 3,
NewLineTrivia = 4,
WhitespaceTrivia = 5,
ConflictMarkerTrivia = 6,
NumericLiteral = 7,
StringLiteral = 8,
RegularExpressionLiteral = 9,
NoSubstitutionTemplateLiteral = 10,
TemplateHead = 11,
TemplateMiddle = 12,
TemplateTail = 13,
OpenBraceToken = 14,
CloseBraceToken = 15,
OpenParenToken = 16,
CloseParenToken = 17,
OpenBracketToken = 18,
CloseBracketToken = 19,
DotToken = 20,
DotDotDotToken = 21,
SemicolonToken = 22,
CommaToken = 23,
LessThanToken = 24,
LessThanSlashToken = 25,
GreaterThanToken = 26,
LessThanEqualsToken = 27,
GreaterThanEqualsToken = 28,
EqualsEqualsToken = 29,
ExclamationEqualsToken = 30,
EqualsEqualsEqualsToken = 31,
ExclamationEqualsEqualsToken = 32,
EqualsGreaterThanToken = 33,
PlusToken = 34,
MinusToken = 35,
AsteriskToken = 36,
SlashToken = 37,
PercentToken = 38,
PlusPlusToken = 39,
MinusMinusToken = 40,
LessThanLessThanToken = 41,
GreaterThanGreaterThanToken = 42,
GreaterThanGreaterThanGreaterThanToken = 43,
AmpersandToken = 44,
BarToken = 45,
CaretToken = 46,
ExclamationToken = 47,
TildeToken = 48,
AmpersandAmpersandToken = 49,
BarBarToken = 50,
QuestionToken = 51,
ColonToken = 52,
AtToken = 53,
EqualsToken = 54,
PlusEqualsToken = 55,
MinusEqualsToken = 56,
AsteriskEqualsToken = 57,
SlashEqualsToken = 58,
PercentEqualsToken = 59,
LessThanLessThanEqualsToken = 60,
GreaterThanGreaterThanEqualsToken = 61,
GreaterThanGreaterThanGreaterThanEqualsToken = 62,
AmpersandEqualsToken = 63,
BarEqualsToken = 64,
CaretEqualsToken = 65,
Identifier = 66,
BreakKeyword = 67,
CaseKeyword = 68,
CatchKeyword = 69,
ClassKeyword = 70,
ConstKeyword = 71,
ContinueKeyword = 72,
DebuggerKeyword = 73,
DefaultKeyword = 74,
DeleteKeyword = 75,
DoKeyword = 76,
ElseKeyword = 77,
EnumKeyword = 78,
ExportKeyword = 79,
ExtendsKeyword = 80,
FalseKeyword = 81,
FinallyKeyword = 82,
ForKeyword = 83,
FunctionKeyword = 84,
IfKeyword = 85,
ImportKeyword = 86,
InKeyword = 87,
InstanceOfKeyword = 88,
NewKeyword = 89,
NullKeyword = 90,
ReturnKeyword = 91,
SuperKeyword = 92,
SwitchKeyword = 93,
ThisKeyword = 94,
ThrowKeyword = 95,
TrueKeyword = 96,
TryKeyword = 97,
TypeOfKeyword = 98,
VarKeyword = 99,
VoidKeyword = 100,
WhileKeyword = 101,
WithKeyword = 102,
ImplementsKeyword = 103,
InterfaceKeyword = 104,
LetKeyword = 105,
PackageKeyword = 106,
PrivateKeyword = 107,
ProtectedKeyword = 108,
PublicKeyword = 109,
StaticKeyword = 110,
YieldKeyword = 111,
AbstractKeyword = 112,
AsKeyword = 113,
AnyKeyword = 114,
AsyncKeyword = 115,
AwaitKeyword = 116,
BooleanKeyword = 117,
ConstructorKeyword = 118,
DeclareKeyword = 119,
GetKeyword = 120,
IsKeyword = 121,
ModuleKeyword = 122,
NamespaceKeyword = 123,
RequireKeyword = 124,
NumberKeyword = 125,
SetKeyword = 126,
StringKeyword = 127,
SymbolKeyword = 128,
TypeKeyword = 129,
FromKeyword = 130,
OfKeyword = 131,
QualifiedName = 132,
ComputedPropertyName = 133,
TypeParameter = 134,
Parameter = 135,
Decorator = 136,
PropertySignature = 137,
PropertyDeclaration = 138,
MethodSignature = 139,
MethodDeclaration = 140,
Constructor = 141,
GetAccessor = 142,
SetAccessor = 143,
CallSignature = 144,
ConstructSignature = 145,
IndexSignature = 146,
TypePredicate = 147,
TypeReference = 148,
FunctionType = 149,
ConstructorType = 150,
TypeQuery = 151,
TypeLiteral = 152,
ArrayType = 153,
TupleType = 154,
UnionType = 155,
IntersectionType = 156,
ParenthesizedType = 157,
ObjectBindingPattern = 158,
ArrayBindingPattern = 159,
BindingElement = 160,
ArrayLiteralExpression = 161,
ObjectLiteralExpression = 162,
PropertyAccessExpression = 163,
ElementAccessExpression = 164,
CallExpression = 165,
NewExpression = 166,
TaggedTemplateExpression = 167,
TypeAssertionExpression = 168,
ParenthesizedExpression = 169,
FunctionExpression = 170,
ArrowFunction = 171,
DeleteExpression = 172,
TypeOfExpression = 173,
VoidExpression = 174,
AwaitExpression = 175,
PrefixUnaryExpression = 176,
PostfixUnaryExpression = 177,
BinaryExpression = 178,
ConditionalExpression = 179,
TemplateExpression = 180,
YieldExpression = 181,
SpreadElementExpression = 182,
ClassExpression = 183,
OmittedExpression = 184,
ExpressionWithTypeArguments = 185,
AsExpression = 186,
TemplateSpan = 187,
SemicolonClassElement = 188,
Block = 189,
VariableStatement = 190,
EmptyStatement = 191,
ExpressionStatement = 192,
IfStatement = 193,
DoStatement = 194,
WhileStatement = 195,
ForStatement = 196,
ForInStatement = 197,
ForOfStatement = 198,
ContinueStatement = 199,
BreakStatement = 200,
ReturnStatement = 201,
WithStatement = 202,
SwitchStatement = 203,
LabeledStatement = 204,
ThrowStatement = 205,
TryStatement = 206,
DebuggerStatement = 207,
VariableDeclaration = 208,
VariableDeclarationList = 209,
FunctionDeclaration = 210,
ClassDeclaration = 211,
InterfaceDeclaration = 212,
TypeAliasDeclaration = 213,
EnumDeclaration = 214,
ModuleDeclaration = 215,
ModuleBlock = 216,
CaseBlock = 217,
ImportEqualsDeclaration = 218,
ImportDeclaration = 219,
ImportClause = 220,
NamespaceImport = 221,
NamedImports = 222,
ImportSpecifier = 223,
ExportAssignment = 224,
ExportDeclaration = 225,
NamedExports = 226,
ExportSpecifier = 227,
MissingDeclaration = 228,
ExternalModuleReference = 229,
JsxElement = 230,
JsxSelfClosingElement = 231,
JsxOpeningElement = 232,
JsxText = 233,
JsxClosingElement = 234,
JsxAttribute = 235,
JsxSpreadAttribute = 236,
JsxExpression = 237,
CaseClause = 238,
DefaultClause = 239,
HeritageClause = 240,
CatchClause = 241,
PropertyAssignment = 242,
ShorthandPropertyAssignment = 243,
EnumMember = 244,
SourceFile = 245,
JSDocTypeExpression = 246,
JSDocAllType = 247,
JSDocUnknownType = 248,
JSDocArrayType = 249,
JSDocUnionType = 250,
JSDocTupleType = 251,
JSDocNullableType = 252,
JSDocNonNullableType = 253,
JSDocRecordType = 254,
JSDocRecordMember = 255,
JSDocTypeReference = 256,
JSDocOptionalType = 257,
JSDocFunctionType = 258,
JSDocVariadicType = 259,
JSDocConstructorType = 260,
JSDocThisType = 261,
JSDocComment = 262,
JSDocTag = 263,
JSDocParameterTag = 264,
JSDocReturnTag = 265,
JSDocTypeTag = 266,
JSDocTemplateTag = 267,
SyntaxList = 268,
Count = 269,
FirstAssignment = 54,
LastAssignment = 65,
FirstReservedWord = 67,
LastReservedWord = 102,
FirstKeyword = 67,
LastKeyword = 131,
FirstFutureReservedWord = 103,
LastFutureReservedWord = 111,
FirstTypeNode = 148,
LastTypeNode = 157,
FirstPunctuation = 14,
LastPunctuation = 65,
ShebangTrivia = 6,
ConflictMarkerTrivia = 7,
NumericLiteral = 8,
StringLiteral = 9,
RegularExpressionLiteral = 10,
NoSubstitutionTemplateLiteral = 11,
TemplateHead = 12,
TemplateMiddle = 13,
TemplateTail = 14,
OpenBraceToken = 15,
CloseBraceToken = 16,
OpenParenToken = 17,
CloseParenToken = 18,
OpenBracketToken = 19,
CloseBracketToken = 20,
DotToken = 21,
DotDotDotToken = 22,
SemicolonToken = 23,
CommaToken = 24,
LessThanToken = 25,
LessThanSlashToken = 26,
GreaterThanToken = 27,
LessThanEqualsToken = 28,
GreaterThanEqualsToken = 29,
EqualsEqualsToken = 30,
ExclamationEqualsToken = 31,
EqualsEqualsEqualsToken = 32,
ExclamationEqualsEqualsToken = 33,
EqualsGreaterThanToken = 34,
PlusToken = 35,
MinusToken = 36,
AsteriskToken = 37,
SlashToken = 38,
PercentToken = 39,
PlusPlusToken = 40,
MinusMinusToken = 41,
LessThanLessThanToken = 42,
GreaterThanGreaterThanToken = 43,
GreaterThanGreaterThanGreaterThanToken = 44,
AmpersandToken = 45,
BarToken = 46,
CaretToken = 47,
ExclamationToken = 48,
TildeToken = 49,
AmpersandAmpersandToken = 50,
BarBarToken = 51,
QuestionToken = 52,
ColonToken = 53,
AtToken = 54,
EqualsToken = 55,
PlusEqualsToken = 56,
MinusEqualsToken = 57,
AsteriskEqualsToken = 58,
SlashEqualsToken = 59,
PercentEqualsToken = 60,
LessThanLessThanEqualsToken = 61,
GreaterThanGreaterThanEqualsToken = 62,
GreaterThanGreaterThanGreaterThanEqualsToken = 63,
AmpersandEqualsToken = 64,
BarEqualsToken = 65,
CaretEqualsToken = 66,
Identifier = 67,
BreakKeyword = 68,
CaseKeyword = 69,
CatchKeyword = 70,
ClassKeyword = 71,
ConstKeyword = 72,
ContinueKeyword = 73,
DebuggerKeyword = 74,
DefaultKeyword = 75,
DeleteKeyword = 76,
DoKeyword = 77,
ElseKeyword = 78,
EnumKeyword = 79,
ExportKeyword = 80,
ExtendsKeyword = 81,
FalseKeyword = 82,
FinallyKeyword = 83,
ForKeyword = 84,
FunctionKeyword = 85,
IfKeyword = 86,
ImportKeyword = 87,
InKeyword = 88,
InstanceOfKeyword = 89,
NewKeyword = 90,
NullKeyword = 91,
ReturnKeyword = 92,
SuperKeyword = 93,
SwitchKeyword = 94,
ThisKeyword = 95,
ThrowKeyword = 96,
TrueKeyword = 97,
TryKeyword = 98,
TypeOfKeyword = 99,
VarKeyword = 100,
VoidKeyword = 101,
WhileKeyword = 102,
WithKeyword = 103,
ImplementsKeyword = 104,
InterfaceKeyword = 105,
LetKeyword = 106,
PackageKeyword = 107,
PrivateKeyword = 108,
ProtectedKeyword = 109,
PublicKeyword = 110,
StaticKeyword = 111,
YieldKeyword = 112,
AbstractKeyword = 113,
AsKeyword = 114,
AnyKeyword = 115,
AsyncKeyword = 116,
AwaitKeyword = 117,
BooleanKeyword = 118,
ConstructorKeyword = 119,
DeclareKeyword = 120,
GetKeyword = 121,
IsKeyword = 122,
ModuleKeyword = 123,
NamespaceKeyword = 124,
RequireKeyword = 125,
NumberKeyword = 126,
SetKeyword = 127,
StringKeyword = 128,
SymbolKeyword = 129,
TypeKeyword = 130,
FromKeyword = 131,
OfKeyword = 132,
QualifiedName = 133,
ComputedPropertyName = 134,
TypeParameter = 135,
Parameter = 136,
Decorator = 137,
PropertySignature = 138,
PropertyDeclaration = 139,
MethodSignature = 140,
MethodDeclaration = 141,
Constructor = 142,
GetAccessor = 143,
SetAccessor = 144,
CallSignature = 145,
ConstructSignature = 146,
IndexSignature = 147,
TypePredicate = 148,
TypeReference = 149,
FunctionType = 150,
ConstructorType = 151,
TypeQuery = 152,
TypeLiteral = 153,
ArrayType = 154,
TupleType = 155,
UnionType = 156,
IntersectionType = 157,
ParenthesizedType = 158,
ObjectBindingPattern = 159,
ArrayBindingPattern = 160,
BindingElement = 161,
ArrayLiteralExpression = 162,
ObjectLiteralExpression = 163,
PropertyAccessExpression = 164,
ElementAccessExpression = 165,
CallExpression = 166,
NewExpression = 167,
TaggedTemplateExpression = 168,
TypeAssertionExpression = 169,
ParenthesizedExpression = 170,
FunctionExpression = 171,
ArrowFunction = 172,
DeleteExpression = 173,
TypeOfExpression = 174,
VoidExpression = 175,
AwaitExpression = 176,
PrefixUnaryExpression = 177,
PostfixUnaryExpression = 178,
BinaryExpression = 179,
ConditionalExpression = 180,
TemplateExpression = 181,
YieldExpression = 182,
SpreadElementExpression = 183,
ClassExpression = 184,
OmittedExpression = 185,
ExpressionWithTypeArguments = 186,
AsExpression = 187,
TemplateSpan = 188,
SemicolonClassElement = 189,
Block = 190,
VariableStatement = 191,
EmptyStatement = 192,
ExpressionStatement = 193,
IfStatement = 194,
DoStatement = 195,
WhileStatement = 196,
ForStatement = 197,
ForInStatement = 198,
ForOfStatement = 199,
ContinueStatement = 200,
BreakStatement = 201,
ReturnStatement = 202,
WithStatement = 203,
SwitchStatement = 204,
LabeledStatement = 205,
ThrowStatement = 206,
TryStatement = 207,
DebuggerStatement = 208,
VariableDeclaration = 209,
VariableDeclarationList = 210,
FunctionDeclaration = 211,
ClassDeclaration = 212,
InterfaceDeclaration = 213,
TypeAliasDeclaration = 214,
EnumDeclaration = 215,
ModuleDeclaration = 216,
ModuleBlock = 217,
CaseBlock = 218,
ImportEqualsDeclaration = 219,
ImportDeclaration = 220,
ImportClause = 221,
NamespaceImport = 222,
NamedImports = 223,
ImportSpecifier = 224,
ExportAssignment = 225,
ExportDeclaration = 226,
NamedExports = 227,
ExportSpecifier = 228,
MissingDeclaration = 229,
ExternalModuleReference = 230,
JsxElement = 231,
JsxSelfClosingElement = 232,
JsxOpeningElement = 233,
JsxText = 234,
JsxClosingElement = 235,
JsxAttribute = 236,
JsxSpreadAttribute = 237,
JsxExpression = 238,
CaseClause = 239,
DefaultClause = 240,
HeritageClause = 241,
CatchClause = 242,
PropertyAssignment = 243,
ShorthandPropertyAssignment = 244,
EnumMember = 245,
SourceFile = 246,
JSDocTypeExpression = 247,
JSDocAllType = 248,
JSDocUnknownType = 249,
JSDocArrayType = 250,
JSDocUnionType = 251,
JSDocTupleType = 252,
JSDocNullableType = 253,
JSDocNonNullableType = 254,
JSDocRecordType = 255,
JSDocRecordMember = 256,
JSDocTypeReference = 257,
JSDocOptionalType = 258,
JSDocFunctionType = 259,
JSDocVariadicType = 260,
JSDocConstructorType = 261,
JSDocThisType = 262,
JSDocComment = 263,
JSDocTag = 264,
JSDocParameterTag = 265,
JSDocReturnTag = 266,
JSDocTypeTag = 267,
JSDocTemplateTag = 268,
SyntaxList = 269,
Count = 270,
FirstAssignment = 55,
LastAssignment = 66,
FirstReservedWord = 68,
LastReservedWord = 103,
FirstKeyword = 68,
LastKeyword = 132,
FirstFutureReservedWord = 104,
LastFutureReservedWord = 112,
FirstTypeNode = 149,
LastTypeNode = 158,
FirstPunctuation = 15,
LastPunctuation = 66,
FirstToken = 0,
LastToken = 131,
LastToken = 132,
FirstTriviaToken = 2,
LastTriviaToken = 6,
FirstLiteralToken = 7,
LastLiteralToken = 10,
FirstTemplateToken = 10,
LastTemplateToken = 13,
FirstBinaryOperator = 24,
LastBinaryOperator = 65,
FirstNode = 132,
LastTriviaToken = 7,
FirstLiteralToken = 8,
LastLiteralToken = 11,
FirstTemplateToken = 11,
LastTemplateToken = 14,
FirstBinaryOperator = 25,
LastBinaryOperator = 66,
FirstNode = 133,
}
const enum NodeFlags {
Export = 1,
@@ -452,9 +454,9 @@ declare namespace ts {
* Several node kinds share function-like features such as a signature,
* a name, and a body. These nodes should extend FunctionLikeDeclaration.
* Examples:
* FunctionDeclaration
* MethodDeclaration
* AccessorDeclaration
* - FunctionDeclaration
* - MethodDeclaration
* - AccessorDeclaration
*/
interface FunctionLikeDeclaration extends SignatureDeclaration {
_functionLikeDeclarationBrand: any;
@@ -944,7 +946,7 @@ declare namespace ts {
getSourceFile(fileName: string): SourceFile;
getCurrentDirectory(): string;
}
interface ParseConfigHost {
interface ParseConfigHost extends ModuleResolutionHost {
readDirectory(rootDir: string, extension: string, exclude: string[]): string[];
}
interface WriteFileCallback {
@@ -958,6 +960,10 @@ declare namespace ts {
throwIfCancellationRequested(): void;
}
interface Program extends ScriptReferenceHost {
/**
* Get a list of root file names that were passed to a 'createProgram'
*/
getRootFileNames(): string[];
/**
* Get a list of files in the program
*/
@@ -1019,11 +1025,6 @@ declare namespace ts {
emitSkipped: boolean;
diagnostics: Diagnostic[];
}
interface TypeCheckerHost {
getCompilerOptions(): CompilerOptions;
getSourceFiles(): SourceFile[];
getSourceFile(fileName: string): SourceFile;
}
interface TypeChecker {
getTypeOfSymbolAtLocation(symbol: Symbol, node: Node): Type;
getDeclaredTypeOfSymbol(symbol: Symbol): Type;
@@ -1031,6 +1032,7 @@ declare namespace ts {
getPropertyOfType(type: Type, propertyName: string): Symbol;
getSignaturesOfType(type: Type, kind: SignatureKind): Signature[];
getIndexTypeOfType(type: Type, kind: IndexKind): Type;
getBaseTypes(type: InterfaceType): ObjectType[];
getReturnTypeOfSignature(signature: Signature): Type;
getSymbolsInScope(location: Node, meaning: SymbolFlags): Symbol[];
getSymbolAtLocation(node: Node): Symbol;
@@ -1054,6 +1056,7 @@ declare namespace ts {
getExportsOfModule(moduleSymbol: Symbol): Symbol[];
getJsxElementAttributesType(elementNode: JsxOpeningLikeElement): Type;
getJsxIntrinsicTagNames(): Symbol[];
isOptionalParameter(node: ParameterDeclaration): boolean;
}
interface SymbolDisplayBuilder {
buildTypeDisplay(type: Type, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void;
@@ -1198,7 +1201,7 @@ declare namespace ts {
Anonymous = 65536,
Instantiated = 131072,
ObjectLiteral = 524288,
ESSymbol = 4194304,
ESSymbol = 16777216,
StringLike = 258,
NumberLike = 132,
ObjectType = 80896,
@@ -1218,8 +1221,6 @@ declare namespace ts {
typeParameters: TypeParameter[];
outerTypeParameters: TypeParameter[];
localTypeParameters: TypeParameter[];
resolvedBaseConstructorType?: Type;
resolvedBaseTypes: ObjectType[];
}
interface InterfaceTypeWithDeclaredMembers extends InterfaceType {
declaredProperties: Symbol[];
@@ -1292,6 +1293,10 @@ declare namespace ts {
Error = 1,
Message = 2,
}
const enum ModuleResolutionKind {
Classic = 1,
NodeJs = 2,
}
interface CompilerOptions {
allowNonTsExtensions?: boolean;
charset?: string;
@@ -1299,6 +1304,7 @@ declare namespace ts {
diagnostics?: boolean;
emitBOM?: boolean;
help?: boolean;
init?: boolean;
inlineSourceMap?: boolean;
inlineSources?: boolean;
jsx?: JsxEmit;
@@ -1315,6 +1321,7 @@ declare namespace ts {
noLib?: boolean;
noResolve?: boolean;
out?: string;
outFile?: string;
outDir?: string;
preserveConstEnums?: boolean;
project?: string;
@@ -1330,6 +1337,7 @@ declare namespace ts {
experimentalDecorators?: boolean;
experimentalAsyncFunctions?: boolean;
emitDecoratorMetadata?: boolean;
moduleResolution?: ModuleResolutionKind;
[option: string]: string | number | boolean;
}
const enum ModuleKind {
@@ -1367,14 +1375,25 @@ declare namespace ts {
fileNames: string[];
errors: Diagnostic[];
}
interface CompilerHost {
interface ModuleResolutionHost {
fileExists(fileName: string): boolean;
readFile(fileName: string): string;
}
interface ResolvedModule {
resolvedFileName: string;
failedLookupLocations: string[];
}
type ModuleNameResolver = (moduleName: string, containingFile: string, options: CompilerOptions, host: ModuleResolutionHost) => ResolvedModule;
interface CompilerHost extends ModuleResolutionHost {
getSourceFile(fileName: string, languageVersion: ScriptTarget, onError?: (message: string) => void): SourceFile;
getCancellationToken?(): CancellationToken;
getDefaultLibFileName(options: CompilerOptions): string;
writeFile: WriteFileCallback;
getCurrentDirectory(): string;
getCanonicalFileName(fileName: string): string;
useCaseSensitiveFileNames(): boolean;
getNewLine(): string;
resolveModuleNames?(moduleNames: string[], containingFile: string): string[];
}
interface TextSpan {
start: number;
@@ -1448,9 +1467,11 @@ declare namespace ts {
function couldStartTrivia(text: string, pos: number): boolean;
function getLeadingCommentRanges(text: string, pos: number): CommentRange[];
function getTrailingCommentRanges(text: string, pos: number): CommentRange[];
/** Optionally, get the shebang */
function getShebang(text: string): string;
function isIdentifierStart(ch: number, languageVersion: ScriptTarget): boolean;
function isIdentifierPart(ch: number, languageVersion: ScriptTarget): boolean;
function createScanner(languageVersion: ScriptTarget, skipTrivia: boolean, languageVariant: ts.LanguageVariant, text?: string, onError?: ErrorCallback, start?: number, length?: number): Scanner;
function createScanner(languageVersion: ScriptTarget, skipTrivia: boolean, languageVariant?: LanguageVariant, text?: string, onError?: ErrorCallback, start?: number, length?: number): Scanner;
}
declare namespace ts {
function getDefaultLibFileName(options: CompilerOptions): string;
@@ -1490,13 +1511,17 @@ declare namespace ts {
function updateSourceFile(sourceFile: SourceFile, newText: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile;
}
declare namespace ts {
/** The version of the TypeScript compiler release */
const version: string;
function findConfigFile(searchPath: string): string;
function resolveTripleslashReference(moduleName: string, containingFile: string): string;
function resolveModuleName(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModule;
function nodeModuleNameResolver(moduleName: string, containingFile: string, host: ModuleResolutionHost): ResolvedModule;
function baseUrlModuleNameResolver(moduleName: string, containingFile: string, baseUrl: string, host: ModuleResolutionHost): ResolvedModule;
function classicNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModule;
function createCompilerHost(options: CompilerOptions, setParentNodes?: boolean): CompilerHost;
function getPreEmitDiagnostics(program: Program, sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[];
function flattenDiagnosticMessageText(messageText: string | DiagnosticMessageChain, newLine: string): string;
function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost): Program;
function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost, oldProgram?: Program): Program;
}
declare namespace ts {
function parseCommandLine(commandLine: string[]): ParsedCommandLine;
@@ -1560,6 +1585,7 @@ declare namespace ts {
getConstructSignatures(): Signature[];
getStringIndexType(): Type;
getNumberIndexType(): Type;
getBaseTypes(): ObjectType[];
}
interface Signature {
getDeclaration(): SignatureDeclaration;
@@ -1601,6 +1627,7 @@ declare namespace ts {
interface PreProcessedFileInfo {
referencedFiles: FileReference[];
importedFiles: FileReference[];
ambientExternalModules: string[];
isLibFile: boolean;
}
interface HostCancellationToken {
@@ -1621,6 +1648,7 @@ declare namespace ts {
trace?(s: string): void;
error?(s: string): void;
useCaseSensitiveFileNames?(): boolean;
resolveModuleNames?(moduleNames: string[], containingFile: string): string[];
}
interface LanguageService {
cleanupSemanticCache(): void;
@@ -1661,6 +1689,7 @@ declare namespace ts {
getFormattingEditsForRange(fileName: string, start: number, end: number, options: FormatCodeOptions): TextChange[];
getFormattingEditsForDocument(fileName: string, options: FormatCodeOptions): TextChange[];
getFormattingEditsAfterKeystroke(fileName: string, position: number, key: string, options: FormatCodeOptions): TextChange[];
getDocCommentTemplateAtPosition(fileName: string, position: number): TextInsertion;
getEmitOutput(fileName: string): EmitOutput;
getProgram(): Program;
getSourceFile(fileName: string): SourceFile;
@@ -1697,6 +1726,11 @@ declare namespace ts {
span: TextSpan;
newText: string;
}
interface TextInsertion {
newText: string;
/** The position in newText the caret should point to after the insertion. */
caretOffset: number;
}
interface RenameLocation {
textSpan: TextSpan;
fileName: string;
@@ -1717,6 +1751,7 @@ declare namespace ts {
const writtenReference: string;
}
interface HighlightSpan {
fileName?: string;
textSpan: TextSpan;
kind: string;
}
@@ -1744,6 +1779,7 @@ declare namespace ts {
InsertSpaceAfterKeywordsInControlFlowStatements: boolean;
InsertSpaceAfterFunctionKeywordForAnonymousFunctions: boolean;
InsertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: boolean;
InsertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: boolean;
PlaceOpenBraceOnNewLineForFunctions: boolean;
PlaceOpenBraceOnNewLineForControlBlocks: boolean;
[s: string]: boolean | number | string;
@@ -1986,6 +2022,7 @@ declare namespace ts {
* @param compilationSettings The compilation settings used to acquire the file
*/
releaseDocument(fileName: string, compilationSettings: CompilerOptions): void;
reportStats(): string;
}
module ScriptElementKind {
const unknown: string;
@@ -2072,10 +2109,24 @@ declare namespace ts {
}
function displayPartsToString(displayParts: SymbolDisplayPart[]): string;
function getDefaultCompilerOptions(): CompilerOptions;
interface TranspileOptions {
compilerOptions?: CompilerOptions;
fileName?: string;
reportDiagnostics?: boolean;
moduleName?: string;
renamedDependencies?: Map<string>;
}
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;
+8238 -6498
View File
File diff suppressed because it is too large Load Diff
+3 -2
View File
@@ -2,7 +2,7 @@
"name": "typescript",
"author": "Microsoft Corp.",
"homepage": "http://typescriptlang.org/",
"version": "1.6.0",
"version": "1.7.0",
"license": "Apache-2.0",
"description": "TypeScript is a language for application scale JavaScript development",
"keywords": [
@@ -20,6 +20,7 @@
"url": "https://github.com/Microsoft/TypeScript.git"
},
"main": "./lib/typescript.js",
"typings": "./lib/typescript.d.ts",
"bin": {
"tsc": "./bin/tsc",
"tsserver": "./bin/tsserver"
@@ -49,5 +50,5 @@
"fs": false,
"os": false,
"path": false
}
}
}
+5 -1
View File
@@ -973,6 +973,10 @@ namespace ts {
else {
let bindingName = node.name ? node.name.text : "__class";
bindAnonymousDeclaration(node, SymbolFlags.Class, bindingName);
// Add name of class expression into the map for semantic classifier
if (node.name) {
classifiableNames[node.name.text] = node.name.text;
}
}
let symbol = node.symbol;
@@ -1062,4 +1066,4 @@ namespace ts {
: declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes);
}
}
}
}
+84 -103
View File
@@ -388,7 +388,7 @@ namespace ts {
return node1.pos <= node2.pos;
}
if (!compilerOptions.out) {
if (!compilerOptions.outFile && !compilerOptions.out) {
return true;
}
@@ -1893,7 +1893,7 @@ namespace ts {
function buildTypeParameterDisplayFromSymbol(symbol: Symbol, writer: SymbolWriter, enclosingDeclaraiton?: Node, flags?: TypeFormatFlags) {
let targetSymbol = getTargetSymbol(symbol);
if (targetSymbol.flags & SymbolFlags.Class || targetSymbol.flags & SymbolFlags.Interface) {
if (targetSymbol.flags & SymbolFlags.Class || targetSymbol.flags & SymbolFlags.Interface || targetSymbol.flags & SymbolFlags.TypeAlias) {
buildDisplayForTypeParametersAndDelimiters(getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol), writer, enclosingDeclaraiton, flags);
}
}
@@ -3119,7 +3119,7 @@ namespace ts {
}
function resolveTupleTypeMembers(type: TupleType) {
let arrayType = resolveStructuredTypeMembers(createArrayType(getUnionType(type.elementTypes)));
let arrayType = resolveStructuredTypeMembers(createArrayType(getUnionType(type.elementTypes, /*noSubtypeReduction*/ true)));
let members = createTupleTypeMemberSymbols(type.elementTypes);
addInheritedMembers(members, arrayType.properties);
setObjectTypeMembers(type, members, arrayType.callSignatures, arrayType.constructSignatures, arrayType.stringIndexType, arrayType.numberIndexType);
@@ -3451,29 +3451,6 @@ namespace ts {
return undefined;
}
// Check if a property with the given name is known anywhere in the given type. In an object
// type, a property is considered known if the object type is empty, if it has any index
// signatures, or if the property is actually declared in the type. In a union or intersection
// type, a property is considered known if it is known in any constituent type.
function isKnownProperty(type: Type, name: string): boolean {
if (type.flags & TypeFlags.ObjectType && type !== globalObjectType) {
const resolved = resolveStructuredTypeMembers(type);
return !!(resolved.properties.length === 0 ||
resolved.stringIndexType ||
resolved.numberIndexType ||
getPropertyOfType(type, name));
}
if (type.flags & TypeFlags.UnionOrIntersection) {
for (let t of (<UnionOrIntersectionType>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(<ObjectType>type);
@@ -4103,73 +4080,20 @@ namespace ts {
}
}
function isObjectLiteralTypeDuplicateOf(source: ObjectType, target: ObjectType): boolean {
let sourceProperties = getPropertiesOfObjectType(source);
let targetProperties = getPropertiesOfObjectType(target);
if (sourceProperties.length !== targetProperties.length) {
return false;
}
for (let sourceProp of sourceProperties) {
let targetProp = getPropertyOfObjectType(target, sourceProp.name);
if (!targetProp ||
getDeclarationFlagsFromSymbol(targetProp) & (NodeFlags.Private | NodeFlags.Protected) ||
!isTypeDuplicateOf(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp))) {
return false;
}
}
return true;
}
function isTupleTypeDuplicateOf(source: TupleType, target: TupleType): boolean {
let sourceTypes = source.elementTypes;
let targetTypes = target.elementTypes;
if (sourceTypes.length !== targetTypes.length) {
return false;
}
for (var i = 0; i < sourceTypes.length; i++) {
if (!isTypeDuplicateOf(sourceTypes[i], targetTypes[i])) {
return false;
}
}
return true;
}
// Returns true if the source type is a duplicate of the target type. A source type is a duplicate of
// a target type if the the two are identical, with the exception that the source type may have null or
// undefined in places where the target type doesn't. This is by design an asymmetric relationship.
function isTypeDuplicateOf(source: Type, target: Type): boolean {
if (source === target) {
return true;
}
if (source.flags & TypeFlags.Undefined || source.flags & TypeFlags.Null && !(target.flags & TypeFlags.Undefined)) {
return true;
}
if (source.flags & TypeFlags.ObjectLiteral && target.flags & TypeFlags.ObjectType) {
return isObjectLiteralTypeDuplicateOf(<ObjectType>source, <ObjectType>target);
}
if (isArrayType(source) && isArrayType(target)) {
return isTypeDuplicateOf((<TypeReference>source).typeArguments[0], (<TypeReference>target).typeArguments[0]);
}
if (isTupleType(source) && isTupleType(target)) {
return isTupleTypeDuplicateOf(<TupleType>source, <TupleType>target);
}
return isTypeIdenticalTo(source, target);
}
function isTypeDuplicateOfSomeType(candidate: Type, types: Type[]): boolean {
for (let type of types) {
if (candidate !== type && isTypeDuplicateOf(candidate, type)) {
function isSubtypeOfAny(candidate: Type, types: Type[]): boolean {
for (let i = 0, len = types.length; i < len; i++) {
if (candidate !== types[i] && isTypeSubtypeOf(candidate, types[i])) {
return true;
}
}
return false;
}
function removeDuplicateTypes(types: Type[]) {
function removeSubtypes(types: Type[]) {
let i = types.length;
while (i > 0) {
i--;
if (isTypeDuplicateOfSomeType(types[i], types)) {
if (isSubtypeOfAny(types[i], types)) {
types.splice(i, 1);
}
}
@@ -4194,12 +4118,14 @@ namespace ts {
}
}
// We always deduplicate the constituent type set based on object identity, but we'll also deduplicate
// based on the structure of the types unless the noDeduplication flag is true, which is the case when
// creating a union type from a type node and when instantiating a union type. In both of those cases,
// structural deduplication has to be deferred to properly support recursive union types. For example,
// a type of the form "type Item = string | (() => Item)" cannot be deduplicated during its declaration.
function getUnionType(types: Type[], noDeduplication?: boolean): Type {
// We reduce the constituent type set to only include types that aren't subtypes of other types, unless
// the noSubtypeReduction flag is specified, in which case we perform a simple deduplication based on
// object identity. Subtype reduction is possible only when union types are known not to circularly
// reference themselves (as is the case with union types created by expression constructs such as array
// literals and the || and ?: operators). Named types can circularly reference themselves and therefore
// cannot be deduplicated during their declaration. For example, "type Item = string | (() => Item" is
// a named type that circularly references itself.
function getUnionType(types: Type[], noSubtypeReduction?: boolean): Type {
if (types.length === 0) {
return emptyObjectType;
}
@@ -4208,12 +4134,12 @@ namespace ts {
if (containsTypeAny(typeSet)) {
return anyType;
}
if (noDeduplication) {
if (noSubtypeReduction) {
removeAllButLast(typeSet, undefinedType);
removeAllButLast(typeSet, nullType);
}
else {
removeDuplicateTypes(typeSet);
removeSubtypes(typeSet);
}
if (typeSet.length === 1) {
return typeSet[0];
@@ -4230,7 +4156,7 @@ namespace ts {
function getTypeFromUnionTypeNode(node: UnionTypeNode): Type {
let links = getNodeLinks(node);
if (!links.resolvedType) {
links.resolvedType = getUnionType(map(node.types, getTypeFromTypeNode), /*noDeduplication*/ true);
links.resolvedType = getUnionType(map(node.types, getTypeFromTypeNode), /*noSubtypeReduction*/ true);
}
return links.resolvedType;
}
@@ -4487,6 +4413,15 @@ namespace ts {
}
function instantiateAnonymousType(type: ObjectType, mapper: TypeMapper): ObjectType {
if (mapper.instantiations) {
let cachedType = mapper.instantiations[type.id];
if (cachedType) {
return cachedType;
}
}
else {
mapper.instantiations = [];
}
// Mark the anonymous type as instantiated such that our infinite instantiation detection logic can recognize it
let result = <ResolvedType>createObjectType(TypeFlags.Anonymous | TypeFlags.Instantiated, type.symbol);
result.properties = instantiateList(getPropertiesOfObjectType(type), mapper, instantiateSymbol);
@@ -4497,6 +4432,7 @@ namespace ts {
let numberIndexType = getIndexTypeOfType(type, IndexKind.Number);
if (stringIndexType) result.stringIndexType = instantiateType(stringIndexType, mapper);
if (numberIndexType) result.numberIndexType = instantiateType(numberIndexType, mapper);
mapper.instantiations[type.id] = result;
return result;
}
@@ -4516,7 +4452,7 @@ namespace ts {
return createTupleType(instantiateList((<TupleType>type).elementTypes, mapper, instantiateType));
}
if (type.flags & TypeFlags.Union) {
return getUnionType(instantiateList((<UnionType>type).types, mapper, instantiateType), /*noDeduplication*/ true);
return getUnionType(instantiateList((<UnionType>type).types, mapper, instantiateType), /*noSubtypeReduction*/ true);
}
if (type.flags & TypeFlags.Intersection) {
return getIntersectionType(instantiateList((<IntersectionType>type).types, mapper, instantiateType));
@@ -4612,7 +4548,7 @@ namespace ts {
* @param target The right-hand-side of the relation.
* @param relation The relation considered. One of 'identityRelation', 'assignableRelation', or 'subTypeRelation'.
* Used as both to determine which checks are performed and as a cache of previously computed results.
* @param errorNode The node upon which all errors will be reported, if defined.
* @param errorNode The suggested node upon which all errors will be reported, if defined. This may or may not be the actual node used.
* @param headMessage If the error chain should be prepended by a head message, then headMessage will be used.
* @param containingMessageChain A chain of errors to prepend any new errors found.
*/
@@ -4803,11 +4739,41 @@ namespace ts {
return Ternary.False;
}
// Check if a property with the given name is known anywhere in the given type. In an object type, a property
// is considered known if the object type is empty and the check is for assignability, if the object type has
// index signatures, or if the property is actually declared in the object type. In a union or intersection
// type, a property is considered known if it is known in any constituent type.
function isKnownProperty(type: Type, name: string): boolean {
if (type.flags & TypeFlags.ObjectType) {
const resolved = resolveStructuredTypeMembers(type);
if (relation === assignableRelation && (type === globalObjectType || resolved.properties.length === 0) ||
resolved.stringIndexType || resolved.numberIndexType || getPropertyOfType(type, name)) {
return true;
}
return false;
}
if (type.flags & TypeFlags.UnionOrIntersection) {
for (let t of (<UnionOrIntersectionType>type).types) {
if (isKnownProperty(t, name)) {
return true;
}
}
return false;
}
return true;
}
function hasExcessProperties(source: FreshObjectLiteralType, target: Type, reportErrors: boolean): boolean {
for (let prop of getPropertiesOfObjectType(source)) {
if (!isKnownProperty(target, prop.name)) {
if (reportErrors) {
reportError(Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, symbolToString(prop), typeToString(target));
// We know *exactly* where things went wrong when comparing the types.
// Use this property as the error node as this will be more helpful in
// reasoning about what went wrong.
errorNode = prop.valueDeclaration
reportError(Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1,
symbolToString(prop),
typeToString(target));
}
return true;
}
@@ -5584,7 +5550,7 @@ namespace ts {
return getWidenedTypeOfObjectLiteral(type);
}
if (type.flags & TypeFlags.Union) {
return getUnionType(map((<UnionType>type).types, getWidenedType));
return getUnionType(map((<UnionType>type).types, getWidenedType), /*noSubtypeReduction*/ true);
}
if (isArrayType(type)) {
return createArrayType(getWidenedType((<TypeReference>type).typeArguments[0]));
@@ -7151,7 +7117,7 @@ namespace ts {
let propertiesTable: SymbolTable = {};
let propertiesArray: Symbol[] = [];
let contextualType = getContextualType(node);
let typeFlags: TypeFlags;
let typeFlags: TypeFlags = 0;
for (let memberDecl of node.properties) {
let member = memberDecl.symbol;
@@ -7200,7 +7166,8 @@ namespace ts {
let stringIndexType = getIndexType(IndexKind.String);
let numberIndexType = getIndexType(IndexKind.Number);
let result = createAnonymousType(node.symbol, propertiesTable, emptyArray, emptyArray, stringIndexType, numberIndexType);
result.flags |= TypeFlags.ObjectLiteral | TypeFlags.FreshObjectLiteral | TypeFlags.ContainsObjectLiteral | (typeFlags & TypeFlags.PropagatingFlags);
let freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : TypeFlags.FreshObjectLiteral;
result.flags |= TypeFlags.ObjectLiteral | TypeFlags.ContainsObjectLiteral | freshObjectLiteralFlag | (typeFlags & TypeFlags.PropagatingFlags);
return result;
function getIndexType(kind: IndexKind) {
@@ -11384,9 +11351,16 @@ namespace ts {
// serialize the type metadata.
if (node && node.kind === SyntaxKind.TypeReference) {
let root = getFirstIdentifier((<TypeReferenceNode>node).typeName);
let rootSymbol = resolveName(root, root.text, SymbolFlags.Value, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined);
if (rootSymbol && rootSymbol.flags & SymbolFlags.Alias && !isInTypeQuery(node) && !isConstEnumOrConstEnumOnlyModule(resolveAlias(rootSymbol))) {
markAliasSymbolAsReferenced(rootSymbol);
let meaning = root.parent.kind === SyntaxKind.TypeReference ? SymbolFlags.Type : SymbolFlags.Namespace;
// Resolve type so we know which symbol is referenced
let rootSymbol = resolveName(root, root.text, meaning | SymbolFlags.Alias, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined);
// Resolved symbol is alias
if (rootSymbol && rootSymbol.flags & SymbolFlags.Alias) {
let aliasTarget = resolveAlias(rootSymbol);
// If alias has value symbol - mark alias as referenced
if (aliasTarget.flags & SymbolFlags.Value && !isConstEnumOrConstEnumOnlyModule(resolveAlias(rootSymbol))) {
markAliasSymbolAsReferenced(rootSymbol);
}
}
}
}
@@ -12596,6 +12570,7 @@ namespace ts {
if (baseTypes.length && produceDiagnostics) {
let baseType = baseTypes[0];
let staticBaseType = getBaseConstructorTypeOfClass(type);
checkSourceElement(baseTypeNode.expression);
if (baseTypeNode.typeArguments) {
forEach(baseTypeNode.typeArguments, checkSourceElement);
for (let constructor of getConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments)) {
@@ -13046,7 +13021,7 @@ namespace ts {
// illegal case: forward reference
if (!isDefinedBefore(propertyDecl, member)) {
reportError = false;
error(e, Diagnostics.A_member_initializer_in_a_const_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_const_enums);
error(e, Diagnostics.A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums);
return undefined;
}
@@ -13665,6 +13640,8 @@ namespace ts {
case SyntaxKind.VariableDeclaration:
case SyntaxKind.VariableDeclarationList:
case SyntaxKind.ClassDeclaration:
case SyntaxKind.HeritageClause:
case SyntaxKind.ExpressionWithTypeArguments:
case SyntaxKind.EnumDeclaration:
case SyntaxKind.EnumMember:
case SyntaxKind.ExportAssignment:
@@ -14402,6 +14379,10 @@ namespace ts {
// Resolve the symbol as a type so that we can provide a more useful hint for the type serializer.
let typeSymbol = resolveEntityName(typeName, SymbolFlags.Type, /*ignoreErrors*/ true);
// We might not be able to resolve type symbol so use unknown type in that case (eg error case)
if (!typeSymbol) {
return TypeReferenceSerializationKind.ObjectType;
}
let type = getDeclaredTypeOfSymbol(typeSymbol);
if (type === unknownType) {
return TypeReferenceSerializationKind.Unknown;
+54 -9
View File
@@ -30,6 +30,11 @@ namespace ts {
type: "boolean",
description: Diagnostics.Print_this_message,
},
{
name: "init",
type: "boolean",
description: Diagnostics.Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file,
},
{
name: "inlineSourceMap",
type: "boolean",
@@ -120,6 +125,13 @@ namespace ts {
{
name: "out",
type: "string",
isFilePath: false, // This is intentionally broken to support compatability with existing tsconfig files
// for correct behaviour, please use outFile
paramType: Diagnostics.FILE,
},
{
name: "outFile",
type: "string",
isFilePath: true,
description: Diagnostics.Concatenate_and_emit_output_to_single_file,
paramType: Diagnostics.FILE,
@@ -172,6 +184,12 @@ namespace ts {
description: Diagnostics.Specifies_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations,
paramType: Diagnostics.LOCATION,
},
{
name: "suppressExcessPropertyErrors",
type: "boolean",
description: Diagnostics.Suppress_excess_property_checks_for_object_literals,
experimental: true
},
{
name: "suppressImplicitAnyIndexErrors",
type: "boolean",
@@ -218,22 +236,49 @@ namespace ts {
type: "boolean",
experimental: true,
description: Diagnostics.Enables_experimental_support_for_emitting_type_metadata_for_decorators
}
},
{
name: "moduleResolution",
type: {
"node": ModuleResolutionKind.NodeJs,
"classic": ModuleResolutionKind.Classic
},
description: Diagnostics.Specifies_module_resolution_strategy_Colon_node_Node_or_classic_TypeScript_pre_1_6
}
];
export function parseCommandLine(commandLine: string[]): ParsedCommandLine {
let options: CompilerOptions = {};
let fileNames: string[] = [];
let errors: Diagnostic[] = [];
let shortOptionNames: Map<string> = {};
let optionNameMap: Map<CommandLineOption> = {};
/* @internal */
export interface OptionNameMap {
optionNameMap: Map<CommandLineOption>;
shortOptionNames: Map<string>;
}
let optionNameMapCache: OptionNameMap;
/* @internal */
export function getOptionNameMap(): OptionNameMap {
if (optionNameMapCache) {
return optionNameMapCache;
}
let optionNameMap: Map<CommandLineOption> = {};
let shortOptionNames: Map<string> = {};
forEach(optionDeclarations, option => {
optionNameMap[option.name.toLowerCase()] = option;
if (option.shortName) {
shortOptionNames[option.shortName] = option.name;
}
});
optionNameMapCache = { optionNameMap, shortOptionNames };
return optionNameMapCache;
}
export function parseCommandLine(commandLine: string[], readFile?: (path: string) => string): ParsedCommandLine {
let options: CompilerOptions = {};
let fileNames: string[] = [];
let errors: Diagnostic[] = [];
let { optionNameMap, shortOptionNames } = getOptionNameMap();
parseStrings(commandLine);
return {
options,
@@ -297,7 +342,7 @@ namespace ts {
}
function parseResponseFile(fileName: string) {
let text = sys.readFile(fileName);
let text = readFile ? readFile(fileName) : sys.readFile(fileName);
if (!text) {
errors.push(createCompilerDiagnostic(Diagnostics.File_0_not_found, fileName));
@@ -450,4 +495,4 @@ namespace ts {
return fileNames;
}
}
}
}
+4 -4
View File
@@ -287,14 +287,14 @@ namespace ts {
return <T>result;
}
export function extend<T>(first: Map<T>, second: Map<T>): Map<T> {
let result: Map<T> = {};
export function extend<T1, T2>(first: Map<T1>, second: Map<T2>): Map<T1 & T2> {
let result: Map<T1 & T2> = {};
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;
+4 -1
View File
@@ -896,6 +896,9 @@ namespace ts {
if (isSupportedExpressionWithTypeArguments(node)) {
emitTypeWithNewGetSymbolAccessibilityDiagnostic(node, getHeritageClauseVisibilityError);
}
else if (!isImplementsList && node.expression.kind === SyntaxKind.NullKeyword) {
write("null");
}
function getHeritageClauseVisibilityError(symbolAccesibilityResult: SymbolAccessiblityResult): SymbolAccessibilityDiagnostic {
let diagnosticMessage: DiagnosticMessage;
@@ -1574,7 +1577,7 @@ namespace ts {
? referencedFile.fileName // Declaration file, use declaration file name
: shouldEmitToOwnFile(referencedFile, compilerOptions)
? getOwnEmitOutputFilePath(referencedFile, host, ".d.ts") // Own output file so get the .d.ts file
: removeFileExtension(compilerOptions.out) + ".d.ts"; // Global out file
: removeFileExtension(compilerOptions.outFile || compilerOptions.out) + ".d.ts"; // Global out file
declFileName = getRelativePathToDirectoryOrUrl(
getDirectoryPath(normalizeSlashes(jsFilePath)),
@@ -425,7 +425,7 @@ namespace ts {
JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property: { code: 2607, category: DiagnosticCategory.Error, key: "JSX element class does not support attributes because it does not have a '{0}' property" },
The_global_type_JSX_0_may_not_have_more_than_one_property: { code: 2608, category: DiagnosticCategory.Error, key: "The global type 'JSX.{0}' may not have more than one property" },
Cannot_emit_namespaced_JSX_elements_in_React: { code: 2650, category: DiagnosticCategory.Error, key: "Cannot emit namespaced JSX elements in React" },
A_member_initializer_in_a_const_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_const_enums: { code: 2651, category: DiagnosticCategory.Error, key: "A member initializer in a 'const' enum declaration cannot reference members declared after it, including members defined in other 'const' enums." },
A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums: { code: 2651, category: DiagnosticCategory.Error, key: "A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums." },
Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead: { code: 2652, category: DiagnosticCategory.Error, key: "Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead." },
Import_declaration_0_is_using_private_name_1: { code: 4000, category: DiagnosticCategory.Error, key: "Import declaration '{0}' is using private name '{1}'." },
Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: DiagnosticCategory.Error, key: "Type parameter '{0}' of exported class has or is using private name '{1}'." },
@@ -506,19 +506,12 @@ namespace ts {
Unknown_compiler_option_0: { code: 5023, category: DiagnosticCategory.Error, key: "Unknown compiler option '{0}'." },
Compiler_option_0_requires_a_value_of_type_1: { code: 5024, category: DiagnosticCategory.Error, key: "Compiler option '{0}' requires a value of type {1}." },
Could_not_write_file_0_Colon_1: { code: 5033, category: DiagnosticCategory.Error, key: "Could not write file '{0}': {1}" },
Option_mapRoot_cannot_be_specified_without_specifying_sourceMap_option: { code: 5038, category: DiagnosticCategory.Error, key: "Option 'mapRoot' cannot be specified without specifying 'sourceMap' option." },
Option_sourceRoot_cannot_be_specified_without_specifying_sourceMap_option: { code: 5039, category: DiagnosticCategory.Error, key: "Option 'sourceRoot' cannot be specified without specifying 'sourceMap' option." },
Option_noEmit_cannot_be_specified_with_option_out_or_outDir: { code: 5040, category: DiagnosticCategory.Error, key: "Option 'noEmit' cannot be specified with option 'out' or 'outDir'." },
Option_noEmit_cannot_be_specified_with_option_declaration: { code: 5041, category: DiagnosticCategory.Error, key: "Option 'noEmit' cannot be specified with option 'declaration'." },
Option_project_cannot_be_mixed_with_source_files_on_a_command_line: { code: 5042, category: DiagnosticCategory.Error, key: "Option 'project' cannot be mixed with source files on a command line." },
Option_declaration_cannot_be_specified_with_option_isolatedModules: { code: 5044, category: DiagnosticCategory.Error, key: "Option 'declaration' cannot be specified with option 'isolatedModules'." },
Option_noEmitOnError_cannot_be_specified_with_option_isolatedModules: { code: 5045, category: DiagnosticCategory.Error, key: "Option 'noEmitOnError' cannot be specified with option 'isolatedModules'." },
Option_out_cannot_be_specified_with_option_isolatedModules: { code: 5046, category: DiagnosticCategory.Error, key: "Option 'out' cannot be specified with option 'isolatedModules'." },
Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES6_or_higher: { code: 5047, category: DiagnosticCategory.Error, key: "Option 'isolatedModules' can only be used when either option'--module' is provided or option 'target' is 'ES6' or higher." },
Option_sourceMap_cannot_be_specified_with_option_inlineSourceMap: { code: 5048, category: DiagnosticCategory.Error, key: "Option 'sourceMap' cannot be specified with option 'inlineSourceMap'." },
Option_sourceRoot_cannot_be_specified_with_option_inlineSourceMap: { code: 5049, category: DiagnosticCategory.Error, key: "Option 'sourceRoot' cannot be specified with option 'inlineSourceMap'." },
Option_mapRoot_cannot_be_specified_with_option_inlineSourceMap: { code: 5050, category: DiagnosticCategory.Error, key: "Option 'mapRoot' cannot be specified with option 'inlineSourceMap'." },
Option_inlineSources_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided: { code: 5051, category: DiagnosticCategory.Error, key: "Option 'inlineSources' can only be used when either option '--inlineSourceMap' or option '--sourceMap' is provided." },
Option_0_cannot_be_specified_without_specifying_option_1: { code: 5052, category: DiagnosticCategory.Error, key: "Option '{0}' cannot be specified without specifying option '{1}'." },
Option_0_cannot_be_specified_with_option_1: { code: 5053, category: DiagnosticCategory.Error, key: "Option '{0}' cannot be specified with option '{1}'." },
A_tsconfig_json_file_is_already_defined_at_Colon_0: { code: 5053, category: DiagnosticCategory.Error, key: "A 'tsconfig.json' file is already defined at: '{0}'." },
Concatenate_and_emit_output_to_single_file: { code: 6001, category: DiagnosticCategory.Message, key: "Concatenate and emit output to single file." },
Generates_corresponding_d_ts_file: { code: 6002, category: DiagnosticCategory.Message, key: "Generates corresponding '.d.ts' file." },
Specifies_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations: { code: 6003, category: DiagnosticCategory.Message, key: "Specifies the location where debugger should locate map files instead of generated locations." },
@@ -569,11 +562,14 @@ namespace ts {
Argument_for_newLine_option_must_be_CRLF_or_LF: { code: 6062, category: DiagnosticCategory.Error, key: "Argument for '--newLine' option must be 'CRLF' or 'LF'." },
Specify_JSX_code_generation_Colon_preserve_or_react: { code: 6080, category: DiagnosticCategory.Message, key: "Specify JSX code generation: 'preserve' or 'react'" },
Argument_for_jsx_must_be_preserve_or_react: { code: 6081, category: DiagnosticCategory.Message, key: "Argument for '--jsx' must be 'preserve' or 'react'." },
Option_experimentalDecorators_must_also_be_specified_when_option_emitDecoratorMetadata_is_specified: { code: 6064, category: DiagnosticCategory.Error, key: "Option 'experimentalDecorators' must also be specified when option 'emitDecoratorMetadata' is specified." },
Enables_experimental_support_for_ES7_decorators: { code: 6065, category: DiagnosticCategory.Message, key: "Enables experimental support for ES7 decorators." },
Enables_experimental_support_for_emitting_type_metadata_for_decorators: { code: 6066, category: DiagnosticCategory.Message, key: "Enables experimental support for emitting type metadata for decorators." },
Option_experimentalAsyncFunctions_cannot_be_specified_when_targeting_ES5_or_lower: { code: 6067, category: DiagnosticCategory.Message, key: "Option 'experimentalAsyncFunctions' cannot be specified when targeting ES5 or lower." },
Enables_experimental_support_for_ES7_async_functions: { code: 6068, category: DiagnosticCategory.Message, key: "Enables experimental support for ES7 async functions." },
Specifies_module_resolution_strategy_Colon_node_Node_or_classic_TypeScript_pre_1_6: { code: 6069, category: DiagnosticCategory.Message, key: "Specifies module resolution strategy: 'node' (Node) or 'classic' (TypeScript pre 1.6) ." },
Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file: { code: 6070, category: DiagnosticCategory.Message, key: "Initializes a TypeScript project and creates a tsconfig.json file." },
Successfully_created_a_tsconfig_json_file: { code: 6071, category: DiagnosticCategory.Message, key: "Successfully created a tsconfig.json file." },
Suppress_excess_property_checks_for_object_literals: { code: 6072, category: DiagnosticCategory.Message, key: "Suppress excess property checks for object literals." },
Variable_0_implicitly_has_an_1_type: { code: 7005, category: DiagnosticCategory.Error, key: "Variable '{0}' implicitly has an '{1}' type." },
Parameter_0_implicitly_has_an_1_type: { code: 7006, category: DiagnosticCategory.Error, key: "Parameter '{0}' implicitly has an '{1}' type." },
Member_0_implicitly_has_an_1_type: { code: 7008, category: DiagnosticCategory.Error, key: "Member '{0}' implicitly has an '{1}' type." },
+30 -46
View File
@@ -161,7 +161,7 @@
},
"Type '{0}' is not a valid async function return type.": {
"category": "Error",
"code": 1055
"code": 1055
},
"Accessors are only available when targeting ECMAScript 5 and higher.": {
"category": "Error",
@@ -1689,7 +1689,7 @@
"category": "Error",
"code": 2650
},
"A member initializer in a 'const' enum declaration cannot reference members declared after it, including members defined in other 'const' enums.": {
"A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums.": {
"category": "Error",
"code": 2651
},
@@ -2013,58 +2013,30 @@
"category": "Error",
"code": 5033
},
"Option 'mapRoot' cannot be specified without specifying 'sourceMap' option.": {
"category": "Error",
"code": 5038
},
"Option 'sourceRoot' cannot be specified without specifying 'sourceMap' option.": {
"category": "Error",
"code": 5039
},
"Option 'noEmit' cannot be specified with option 'out' or 'outDir'.": {
"category": "Error",
"code": 5040
},
"Option 'noEmit' cannot be specified with option 'declaration'.": {
"category": "Error",
"code": 5041
},
"Option 'project' cannot be mixed with source files on a command line.": {
"category": "Error",
"code": 5042
},
"Option 'declaration' cannot be specified with option 'isolatedModules'.": {
"category": "Error",
"code": 5044
},
"Option 'noEmitOnError' cannot be specified with option 'isolatedModules'.": {
"category": "Error",
"code": 5045
},
"Option 'out' cannot be specified with option 'isolatedModules'.": {
"category": "Error",
"code": 5046
},
"Option 'isolatedModules' can only be used when either option'--module' is provided or option 'target' is 'ES6' or higher.": {
"category": "Error",
"code": 5047
},
"Option 'sourceMap' cannot be specified with option 'inlineSourceMap'.": {
"category": "Error",
"code": 5048
},
"Option 'sourceRoot' cannot be specified with option 'inlineSourceMap'.": {
"category": "Error",
"code": 5049
},
"Option 'mapRoot' cannot be specified with option 'inlineSourceMap'.": {
"category": "Error",
"code": 5050
},
"Option 'inlineSources' can only be used when either option '--inlineSourceMap' or option '--sourceMap' is provided.": {
"category": "Error",
"code": 5051
},
"Option '{0}' cannot be specified without specifying option '{1}'.": {
"category": "Error",
"code": 5052
},
"Option '{0}' cannot be specified with option '{1}'.": {
"category": "Error",
"code": 5053
},
"A 'tsconfig.json' file is already defined at: '{0}'.": {
"category": "Error",
"code": 5053
},
"Concatenate and emit output to single file.": {
"category": "Message",
@@ -2266,10 +2238,6 @@
"category": "Message",
"code": 6081
},
"Option 'experimentalDecorators' must also be specified when option 'emitDecoratorMetadata' is specified.": {
"category": "Error",
"code": 6064
},
"Enables experimental support for ES7 decorators.": {
"category": "Message",
"code": 6065
@@ -2286,6 +2254,22 @@
"category": "Message",
"code": 6068
},
"Specifies module resolution strategy: 'node' (Node) or 'classic' (TypeScript pre 1.6) .": {
"category": "Message",
"code": 6069
},
"Initializes a TypeScript project and creates a tsconfig.json file.": {
"category": "Message",
"code": 6070
},
"Successfully created a tsconfig.json file.": {
"category": "Message",
"code": 6071
},
"Suppress excess property checks for object literals.": {
"category": "Message",
"code": 6072
},
"Variable '{0}' implicitly has an '{1}' type.": {
"category": "Error",
+361 -82
View File
@@ -78,18 +78,18 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
}
});
if (compilerOptions.out) {
emitFile(compilerOptions.out);
if (compilerOptions.outFile || compilerOptions.out) {
emitFile(compilerOptions.outFile || compilerOptions.out);
}
}
else {
// targetSourceFile is specified (e.g calling emitter from language service or calling getSemanticDiagnostic from language service)
if (shouldEmitToOwnFile(targetSourceFile, compilerOptions)) {
let jsFilePath = getOwnEmitOutputFilePath(targetSourceFile, host, forEach(host.getSourceFiles(), shouldEmitJsx) ? ".jsx" : ".js");
let jsFilePath = getOwnEmitOutputFilePath(targetSourceFile, host, shouldEmitJsx(targetSourceFile) ? ".jsx" : ".js");
emitFile(jsFilePath, targetSourceFile);
}
else if (!isDeclarationFile(targetSourceFile) && compilerOptions.out) {
emitFile(compilerOptions.out);
else if (!isDeclarationFile(targetSourceFile) && (compilerOptions.outFile || compilerOptions.out)) {
emitFile(compilerOptions.outFile || compilerOptions.out);
}
}
@@ -124,11 +124,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
function emitJavaScript(jsFilePath: string, root?: SourceFile) {
let writer = createTextWriter(newLine);
let write = writer.write;
let writeTextOfNode = writer.writeTextOfNode;
let writeLine = writer.writeLine;
let increaseIndent = writer.increaseIndent;
let decreaseIndent = writer.decreaseIndent;
let { write, writeTextOfNode, writeLine, increaseIndent, decreaseIndent } = writer;
let currentSourceFile: SourceFile;
// name of an exporter function if file is a System external module
@@ -1181,9 +1177,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
}
function emitJsxElement(openingNode: JsxOpeningLikeElement, children?: JsxChild[]) {
let syntheticReactRef = <Identifier>createSynthesizedNode(SyntaxKind.Identifier);
syntheticReactRef.text = 'React';
syntheticReactRef.parent = openingNode;
// Call React.createElement(tag, ...
emitLeadingComments(openingNode);
write("React.createElement(");
emitExpressionIdentifier(syntheticReactRef);
write(".createElement(");
emitTagName(openingNode.tagName);
write(", ");
@@ -1197,7 +1198,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
// a call to React.__spread
let attrs = openingNode.attributes;
if (forEach(attrs, attr => attr.kind === SyntaxKind.JsxSpreadAttribute)) {
write("React.__spread(");
emitExpressionIdentifier(syntheticReactRef);
write(".__spread(");
let haveOpenedObjectLiteral = false;
for (let i = 0; i < attrs.length; i++) {
@@ -1519,7 +1521,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
return;
}
}
writeTextOfNode(currentSourceFile, node);
if (nodeIsSynthesized(node)) {
write(node.text);
}
else {
writeTextOfNode(currentSourceFile, node);
}
}
function isNameOfNestedRedeclaration(node: Identifier) {
@@ -1546,6 +1554,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
else if (isNameOfNestedRedeclaration(node)) {
write(getGeneratedNameForNode(node));
}
else if (nodeIsSynthesized(node)) {
write(node.text);
}
else {
writeTextOfNode(currentSourceFile, node);
}
@@ -2105,7 +2116,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
emit(node.name);
decreaseIndentIf(indentedBeforeDot, indentedAfterDot);
}
function emitQualifiedName(node: QualifiedName) {
emit(node.left);
write(".");
@@ -2128,12 +2139,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
else {
emitEntityNameAsExpression(node.left, /*useFallback*/ false);
}
write(".");
emit(node.right);
}
function emitEntityNameAsExpression(node: EntityName, useFallback: boolean) {
function emitEntityNameAsExpression(node: EntityName, useFallback: boolean) {
switch (node.kind) {
case SyntaxKind.Identifier:
if (useFallback) {
@@ -2141,10 +2152,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
emitExpressionIdentifier(<Identifier>node);
write(" !== 'undefined' && ");
}
emitExpressionIdentifier(<Identifier>node);
break;
case SyntaxKind.QualifiedName:
emitQualifiedNameAsExpression(<QualifiedName>node, useFallback);
break;
@@ -3055,7 +3066,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
if (compilerOptions.module === ModuleKind.CommonJS || compilerOptions.module === ModuleKind.AMD || compilerOptions.module === ModuleKind.UMD) {
if (!currentSourceFile.symbol.exports["___esModule"]) {
if (languageVersion === ScriptTarget.ES5) {
// default value of configurable, enumerable, writable are `false`.
// default value of configurable, enumerable, writable are `false`.
write("Object.defineProperty(exports, \"__esModule\", { value: true });");
writeLine();
}
@@ -4311,7 +4322,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
if (ctor) {
// Emit all the directive prologues (like "use strict"). These have to come before
// any other preamble code we write (like parameter initializers).
startIndex = emitDirectivePrologues(ctor.body.statements, /*startWithNewLine*/ true);
startIndex = emitDirectivePrologues(ctor.body.statements, /*startWithNewLine*/ true);
emitDetachedComments(ctor.body.statements);
}
emitCaptureThisForNodeIfNecessary(node);
@@ -4883,7 +4894,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
}
return false;
}
/** Serializes the type of a declaration to an appropriate JS constructor value. Used by the __metadata decorator for a class member. */
function emitSerializedTypeOfNode(node: Node) {
// serialization of the type of a declaration uses the following rules:
@@ -4894,39 +4905,39 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
// * The serialized type of an AccessorDeclaration is the serialized type of the return type annotation of its getter or parameter type annotation of its setter.
// * The serialized type of any other FunctionLikeDeclaration is "Function".
// * The serialized type of any other node is "void 0".
//
//
// For rules on serializing type annotations, see `serializeTypeNode`.
switch (node.kind) {
case SyntaxKind.ClassDeclaration:
write("Function");
return;
case SyntaxKind.PropertyDeclaration:
case SyntaxKind.PropertyDeclaration:
emitSerializedTypeNode((<PropertyDeclaration>node).type);
return;
case SyntaxKind.Parameter:
case SyntaxKind.Parameter:
emitSerializedTypeNode((<ParameterDeclaration>node).type);
return;
case SyntaxKind.GetAccessor:
case SyntaxKind.GetAccessor:
emitSerializedTypeNode((<AccessorDeclaration>node).type);
return;
case SyntaxKind.SetAccessor:
case SyntaxKind.SetAccessor:
emitSerializedTypeNode(getSetAccessorTypeAnnotationNode(<AccessorDeclaration>node));
return;
}
if (isFunctionLike(node)) {
write("Function");
return;
}
write("void 0");
}
function emitSerializedTypeNode(node: TypeNode) {
if (!node) {
return;
@@ -4940,17 +4951,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
case SyntaxKind.ParenthesizedType:
emitSerializedTypeNode((<ParenthesizedTypeNode>node).type);
return;
case SyntaxKind.FunctionType:
case SyntaxKind.ConstructorType:
write("Function");
return;
case SyntaxKind.ArrayType:
case SyntaxKind.TupleType:
write("Array");
return;
case SyntaxKind.TypePredicate:
case SyntaxKind.BooleanKeyword:
write("Boolean");
@@ -4960,11 +4971,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
case SyntaxKind.StringLiteral:
write("String");
return;
case SyntaxKind.NumberKeyword:
write("Number");
return;
case SyntaxKind.SymbolKeyword:
write("Symbol");
return;
@@ -4972,22 +4983,22 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
case SyntaxKind.TypeReference:
emitSerializedTypeReferenceNode(<TypeReferenceNode>node);
return;
case SyntaxKind.TypeQuery:
case SyntaxKind.TypeLiteral:
case SyntaxKind.UnionType:
case SyntaxKind.IntersectionType:
case SyntaxKind.AnyKeyword:
break;
default:
Debug.fail("Cannot serialize unexpected type node.");
break;
}
write("Object");
}
/** Serializes a TypeReferenceNode to an appropriate JS constructor value. Used by the __metadata decorator. */
function emitSerializedTypeReferenceNode(node: TypeReferenceNode) {
let location: Node = node.parent;
@@ -5015,27 +5026,27 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
case TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue:
emitEntityNameAsExpression(typeName, /*useFallback*/ false);
break;
case TypeReferenceSerializationKind.VoidType:
write("void 0");
break;
case TypeReferenceSerializationKind.BooleanType:
write("Boolean");
break;
case TypeReferenceSerializationKind.NumberLikeType:
write("Number");
break;
case TypeReferenceSerializationKind.StringLikeType:
write("String");
break;
case TypeReferenceSerializationKind.ArrayLikeType:
write("Array");
break;
case TypeReferenceSerializationKind.ESSymbolType:
if (languageVersion < ScriptTarget.ES6) {
write("typeof Symbol === 'function' ? Symbol : Object");
@@ -5044,24 +5055,24 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
write("Symbol");
}
break;
case TypeReferenceSerializationKind.TypeWithCallSignature:
write("Function");
break;
case TypeReferenceSerializationKind.ObjectType:
write("Object");
break;
}
}
/** Serializes the parameter types of a function or the constructor of a class. Used by the __metadata decorator for a method or set accessor. */
function emitSerializedParameterTypesOfNode(node: Node) {
// serialization of parameter types uses the following rules:
//
// * If the declaration is a class, the parameters of the first constructor with a body are used.
// * If the declaration is function-like and has a body, the parameters of the function are used.
//
//
// For the rules on serializing the type of each parameter declaration, see `serializeTypeOfDeclaration`.
if (node) {
let valueDeclaration: FunctionLikeDeclaration;
@@ -5071,7 +5082,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
else if (isFunctionLike(node) && nodeIsPresent((<FunctionLikeDeclaration>node).body)) {
valueDeclaration = <FunctionLikeDeclaration>node;
}
if (valueDeclaration) {
const parameters = valueDeclaration.parameters;
const parameterCount = parameters.length;
@@ -5080,7 +5091,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
if (i > 0) {
write(", ");
}
if (parameters[i].dotDotDotToken) {
let parameterType = parameters[i].type;
if (parameterType.kind === SyntaxKind.ArrayType) {
@@ -5092,7 +5103,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
else {
parameterType = undefined;
}
emitSerializedTypeNode(parameterType);
}
else {
@@ -5103,18 +5114,18 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
}
}
}
/** Serializes the return type of function. Used by the __metadata decorator for a method. */
function emitSerializedReturnTypeOfNode(node: Node): string | string[] {
if (node && isFunctionLike(node) && (<FunctionLikeDeclaration>node).type) {
emitSerializedTypeNode((<FunctionLikeDeclaration>node).type);
return;
}
write("void 0");
}
function emitSerializedTypeMetadata(node: Declaration, writeComma: boolean): number {
// This method emits the serialized type metadata for a decorator target.
// The caller should have already tested whether the node has decorators.
@@ -5131,7 +5142,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
argumentsWritten++;
}
if (shouldEmitParamTypesMetadata(node)) {
debugger;
if (writeComma || argumentsWritten) {
write(", ");
}
@@ -5145,7 +5155,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
if (writeComma || argumentsWritten) {
write(", ");
}
writeLine();
write("__metadata('design:returntype', ");
emitSerializedReturnTypeOfNode(node);
@@ -5153,10 +5163,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
argumentsWritten++;
}
}
return argumentsWritten;
}
function emitInterfaceDeclaration(node: InterfaceDeclaration) {
emitOnlyPinnedOrTripleSlashComments(node);
}
@@ -5522,18 +5532,18 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
(!isExternalModule(currentSourceFile) && resolver.isTopLevelValueImportEqualsWithEntityName(node))) {
emitLeadingComments(node);
emitStart(node);
// variable declaration for import-equals declaration can be hoisted in system modules
// in this case 'var' should be omitted and emit should contain only initialization
let variableDeclarationIsHoisted = shouldHoistVariable(node, /*checkIfSourceFileLevelDecl*/ true);
// is it top level export import v = a.b.c in system module?
// if yes - it needs to be rewritten as exporter('v', v = a.b.c)
let isExported = isSourceFileLevelDeclarationInSystemJsModule(node, /*isExported*/ true);
if (!variableDeclarationIsHoisted) {
Debug.assert(!isExported);
if (isES6ExportedDeclaration(node)) {
write("export ");
write("var ");
@@ -5542,8 +5552,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
write("var ");
}
}
if (isExported) {
write(`${exportFunctionForFile}("`);
emitNodeWithoutSourceMap(node.name);
@@ -5557,8 +5567,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
if (isExported) {
write(")");
}
write(";");
write(";");
emitEnd(node);
emitExportImportAssignments(node);
emitTrailingComments(node);
@@ -6080,12 +6090,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
}
return;
}
if (isInternalModuleImportEqualsDeclaration(node)) {
if (!hoistedVars) {
hoistedVars = [];
}
hoistedVars.push(node.name);
return;
}
@@ -6513,9 +6523,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
}
}
function trimReactWhitespace(node: JsxText): string {
function trimReactWhitespaceAndApplyEntities(node: JsxText): string {
let result: string = undefined;
let text = getTextOfNode(node);
let text = getTextOfNode(node, /*includeTrivia*/ true);
let firstNonWhitespace = 0;
let lastNonWhitespace = -1;
@@ -6538,19 +6548,32 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
}
}
}
if (firstNonWhitespace !== -1) {
let part = text.substr(firstNonWhitespace);
result = (result ? result + "\" + ' ' + \"" : "") + part;
}
if (result) {
// Replace entities like &nbsp;
result = result.replace(/&(\w+);/g, function(s: any, m: string) {
if (entities[m] !== undefined) {
return String.fromCharCode(entities[m]);
}
else {
return s;
}
});
}
return result;
}
function getTextToEmit(node: JsxText) {
switch (compilerOptions.jsx) {
case JsxEmit.React:
let text = trimReactWhitespace(node);
if (text.length === 0) {
let text = trimReactWhitespaceAndApplyEntities(node);
if (text === undefined || text.length === 0) {
return undefined;
}
else {
@@ -6558,7 +6581,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
}
case JsxEmit.Preserve:
default:
return getTextOfNode(node, true);
return getTextOfNode(node, /*includeTrivia*/ true);
}
}
@@ -6566,13 +6589,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
switch (compilerOptions.jsx) {
case JsxEmit.React:
write("\"");
write(trimReactWhitespace(node));
write(trimReactWhitespaceAndApplyEntities(node));
write("\"");
break;
case JsxEmit.Preserve:
default: // Emit JSX-preserve as default when no --jsx flag is specified
writer.writeLiteral(getTextOfNode(node, true));
writer.writeLiteral(getTextOfNode(node, /*includeTrivia*/ true));
break;
}
}
@@ -7139,4 +7162,260 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
}
}
}
var entities: Map<number> = {
"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
}
}
+4 -2
View File
@@ -4941,12 +4941,15 @@ namespace ts {
function parseModuleOrNamespaceDeclaration(fullStart: number, decorators: NodeArray<Decorator>, modifiers: ModifiersArray, flags: NodeFlags): ModuleDeclaration {
let node = <ModuleDeclaration>createNode(SyntaxKind.ModuleDeclaration, fullStart);
// If we are parsing a dotted namespace name, we want to
// propagate the 'Namespace' flag across the names if set.
let namespaceFlag = flags & NodeFlags.Namespace;
node.decorators = decorators;
setModifiers(node, modifiers);
node.flags |= flags;
node.name = parseIdentifier();
node.body = parseOptional(SyntaxKind.DotToken)
? parseModuleOrNamespaceDeclaration(getNodePos(), /*decorators*/ undefined, /*modifiers*/ undefined, NodeFlags.Export)
? parseModuleOrNamespaceDeclaration(getNodePos(), /*decorators*/ undefined, /*modifiers*/ undefined, NodeFlags.Export | namespaceFlag)
: parseModuleBlock();
return finishNode(node);
}
@@ -5831,7 +5834,6 @@ namespace ts {
if (!name) {
parseErrorAtPosition(pos, 0, Diagnostics.Identifier_expected);
return undefined;
}
let preName: Identifier, postName: Identifier;
+200 -42
View File
@@ -1,5 +1,6 @@
/// <reference path="sys.ts" />
/// <reference path="emitter.ts" />
/// <reference path="core.ts" />
namespace ts {
/* @internal */ export let programTime = 0;
@@ -11,7 +12,7 @@ namespace ts {
let emptyArray: any[] = [];
export const version = "1.6.0";
export const version = "1.7.0";
export function findConfigFile(searchPath: string): string {
let fileName = "tsconfig.json";
@@ -36,11 +37,150 @@ namespace ts {
}
export function resolveModuleName(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModule {
// TODO: use different resolution strategy based on compiler options
return legacyNameResolver(moduleName, containingFile, compilerOptions, host);
let moduleResolution = compilerOptions.moduleResolution !== undefined
? compilerOptions.moduleResolution
: compilerOptions.module === ModuleKind.CommonJS ? ModuleResolutionKind.NodeJs : ModuleResolutionKind.Classic;
switch (moduleResolution) {
case ModuleResolutionKind.NodeJs: return nodeModuleNameResolver(moduleName, containingFile, host);
case ModuleResolutionKind.Classic: return classicNameResolver(moduleName, containingFile, compilerOptions, host);
}
}
export function nodeModuleNameResolver(moduleName: string, containingFile: string, host: ModuleResolutionHost): ResolvedModule {
let containingDirectory = getDirectoryPath(containingFile);
if (getRootLength(moduleName) !== 0 || nameStartsWithDotSlashOrDotDotSlash(moduleName)) {
let failedLookupLocations: string[] = [];
let candidate = normalizePath(combinePaths(containingDirectory, moduleName));
let resolvedFileName = loadNodeModuleFromFile(candidate, /* loadOnlyDts */ false, failedLookupLocations, host);
if (resolvedFileName) {
return { resolvedFileName, failedLookupLocations };
}
resolvedFileName = loadNodeModuleFromDirectory(candidate, /* loadOnlyDts */ false, failedLookupLocations, host);
return { resolvedFileName, failedLookupLocations };
}
else {
return loadModuleFromNodeModules(moduleName, containingDirectory, host);
}
}
function loadNodeModuleFromFile(candidate: string, loadOnlyDts: boolean, failedLookupLocation: string[], host: ModuleResolutionHost): string {
if (loadOnlyDts) {
return tryLoad(".d.ts");
}
else {
return forEach(supportedExtensions, tryLoad);
}
function tryLoad(ext: string): string {
let fileName = fileExtensionIs(candidate, ext) ? candidate : candidate + ext;
if (host.fileExists(fileName)) {
return fileName;
}
else {
failedLookupLocation.push(fileName);
return undefined;
}
}
}
function loadNodeModuleFromDirectory(candidate: string, loadOnlyDts: boolean, failedLookupLocation: string[], host: ModuleResolutionHost): string {
let packageJsonPath = combinePaths(candidate, "package.json");
if (host.fileExists(packageJsonPath)) {
let jsonContent: { typings?: string };
try {
let jsonText = host.readFile(packageJsonPath);
jsonContent = jsonText ? <{ typings?: string }>JSON.parse(jsonText) : { typings: undefined };
}
catch (e) {
// gracefully handle if readFile fails or returns not JSON
jsonContent = { typings: undefined };
}
if (jsonContent.typings) {
let result = loadNodeModuleFromFile(normalizePath(combinePaths(candidate, jsonContent.typings)), loadOnlyDts, failedLookupLocation, host);
if (result) {
return result;
}
}
}
else {
// record package json as one of failed lookup locations - in the future if this file will appear it will invalidate resolution results
failedLookupLocation.push(packageJsonPath);
}
return loadNodeModuleFromFile(combinePaths(candidate, "index"), loadOnlyDts, failedLookupLocation, host);
}
function loadModuleFromNodeModules(moduleName: string, directory: string, host: ModuleResolutionHost): ResolvedModule {
let failedLookupLocations: string[] = [];
directory = normalizeSlashes(directory);
while (true) {
let baseName = getBaseFileName(directory);
if (baseName !== "node_modules") {
let nodeModulesFolder = combinePaths(directory, "node_modules");
let candidate = normalizePath(combinePaths(nodeModulesFolder, moduleName));
let result = loadNodeModuleFromFile(candidate, /* loadOnlyDts */ true, failedLookupLocations, host);
if (result) {
return { resolvedFileName: result, failedLookupLocations };
}
result = loadNodeModuleFromDirectory(candidate, /* loadOnlyDts */ true, failedLookupLocations, host);
if (result) {
return { resolvedFileName: result, failedLookupLocations };
}
}
let parentPath = getDirectoryPath(directory);
if (parentPath === directory) {
break;
}
directory = parentPath;
}
return { resolvedFileName: undefined, failedLookupLocations };
}
export function baseUrlModuleNameResolver(moduleName: string, containingFile: string, baseUrl: string, host: ModuleResolutionHost): ResolvedModule {
Debug.assert(baseUrl !== undefined);
let normalizedModuleName = normalizeSlashes(moduleName);
let basePart = useBaseUrl(moduleName) ? baseUrl : getDirectoryPath(containingFile);
let candidate = normalizePath(combinePaths(basePart, moduleName));
let failedLookupLocations: string[] = [];
return forEach(supportedExtensions, ext => tryLoadFile(candidate + ext)) || { resolvedFileName: undefined, failedLookupLocations };
function tryLoadFile(location: string): ResolvedModule {
if (host.fileExists(location)) {
return { resolvedFileName: location, failedLookupLocations };
}
else {
failedLookupLocations.push(location);
return undefined;
}
}
}
function nameStartsWithDotSlashOrDotDotSlash(name: string) {
let i = name.lastIndexOf("./", 1);
return i === 0 || (i === 1 && name.charCodeAt(0) === CharacterCodes.dot);
}
function useBaseUrl(moduleName: string): boolean {
// path is not rooted
// module name does not start with './' or '../'
return getRootLength(moduleName) === 0 && !nameStartsWithDotSlashOrDotDotSlash(moduleName);
}
function legacyNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModule {
export function classicNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModule {
// module names that contain '!' are used to reference resources and are not resolved to actual files on disk
if (moduleName.indexOf('!') != -1) {
@@ -85,6 +225,16 @@ namespace ts {
return { resolvedFileName: referencedSourceFile, failedLookupLocations };
}
/* @internal */
export const defaultInitCompilerOptions: CompilerOptions = {
module: ModuleKind.CommonJS,
target: ScriptTarget.ES3,
noImplicitAny: false,
outDir: "built",
rootDir: ".",
sourceMap: false,
};
export function createCompilerHost(options: CompilerOptions, setParentNodes?: boolean): CompilerHost {
let currentDirectory: string;
let existingDirectories: Map<boolean> = {};
@@ -221,19 +371,9 @@ namespace ts {
host = host || createCompilerHost(options);
// initialize resolveModuleNameWorker only if noResolve is false
let resolveModuleNamesWorker: (moduleNames: string[], containingFile: string) => string[];
if (!options.noResolve) {
resolveModuleNamesWorker = host.resolveModuleNames;
if (!resolveModuleNamesWorker) {
resolveModuleNamesWorker = (moduleNames, containingFile) => {
return map(moduleNames, moduleName => {
let moduleResolution = resolveModuleName(moduleName, containingFile, options, host);
return moduleResolution.resolvedFileName;
});
}
}
}
const resolveModuleNamesWorker =
host.resolveModuleNames ||
((moduleNames, containingFile) => map(moduleNames, moduleName => resolveModuleName(moduleName, containingFile, options, host).resolvedFileName));
let filesByName = createFileMap<SourceFile>(fileName => host.getCanonicalFileName(fileName));
@@ -340,7 +480,7 @@ namespace ts {
}
// check imports
collectExternalModuleReferences(newSourceFile);
collectExternalModuleReferences(newSourceFile);
if (!arrayIsEqualTo(oldSourceFile.imports, newSourceFile.imports, moduleNameIsEqualTo)) {
// imports has changed
return false;
@@ -423,7 +563,7 @@ namespace ts {
// This is because in the -out scenario all files need to be emitted, and therefore all
// files need to be type checked. And the way to specify that all files need to be type
// checked is to not pass the file to getEmitResolver.
let emitResolver = getDiagnosticsProducingTypeChecker().getEmitResolver(options.out ? undefined : sourceFile);
let emitResolver = getDiagnosticsProducingTypeChecker().getEmitResolver((options.outFile || options.out)? undefined : sourceFile);
let start = new Date().getTime();
@@ -670,12 +810,15 @@ namespace ts {
// Set the source file for normalized absolute path
filesByName.set(canonicalAbsolutePath, file);
let basePath = getDirectoryPath(fileName);
if (!options.noResolve) {
let basePath = getDirectoryPath(fileName);
processReferencedFiles(file, basePath);
processImportedModules(file, basePath);
}
// always process imported modules to record module name resolutions
processImportedModules(file, basePath);
if (isDefaultLib) {
file.isDefaultLib = true;
files.unshift(file);
@@ -713,21 +856,19 @@ namespace ts {
});
}
function processImportedModules(file: SourceFile, basePath: string) {
collectExternalModuleReferences(file);
if (file.imports.length) {
function processImportedModules(file: SourceFile, basePath: string) {
collectExternalModuleReferences(file);
if (file.imports.length) {
file.resolvedModules = {};
let oldSourceFile = oldProgram && oldProgram.getSourceFile(file.fileName);
let moduleNames = map(file.imports, name => name.text);
let resolutions = resolveModuleNamesWorker(moduleNames, file.fileName);
for (let i = 0; i < file.imports.length; ++i) {
let resolution = resolutions[i];
setResolvedModuleName(file, moduleNames[i], resolution);
if (resolution) {
if (resolution && !options.noResolve) {
findModuleSourceFile(resolution, file.imports[i]);
}
}
}
}
else {
// no imports - drop cached module resolutions
@@ -803,27 +944,31 @@ namespace ts {
function verifyCompilerOptions() {
if (options.isolatedModules) {
if (options.declaration) {
diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_declaration_cannot_be_specified_with_option_isolatedModules));
diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "declaration", "isolatedModules"));
}
if (options.noEmitOnError) {
diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_noEmitOnError_cannot_be_specified_with_option_isolatedModules));
diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmitOnError", "isolatedModules"));
}
if (options.out) {
diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_out_cannot_be_specified_with_option_isolatedModules));
diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "out", "isolatedModules"));
}
if (options.outFile) {
diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "outFile", "isolatedModules"));
}
}
if (options.inlineSourceMap) {
if (options.sourceMap) {
diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_sourceMap_cannot_be_specified_with_option_inlineSourceMap));
diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "sourceMap", "inlineSourceMap"));
}
if (options.mapRoot) {
diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_mapRoot_cannot_be_specified_with_option_inlineSourceMap));
diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "mapRoot", "inlineSourceMap"));
}
if (options.sourceRoot) {
diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_sourceRoot_cannot_be_specified_with_option_inlineSourceMap));
diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "sourceRoot", "inlineSourceMap"));
}
}
@@ -834,18 +979,23 @@ namespace ts {
}
}
if (options.out && options.outFile) {
diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "out", "outFile"));
}
if (!options.sourceMap && (options.mapRoot || options.sourceRoot)) {
// Error to specify --mapRoot or --sourceRoot without mapSourceFiles
if (options.mapRoot) {
diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_mapRoot_cannot_be_specified_without_specifying_sourceMap_option));
diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "mapRoot", "sourceMap"));
}
if (options.sourceRoot) {
diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_sourceRoot_cannot_be_specified_without_specifying_sourceMap_option));
diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "sourceRoot", "sourceMap"));
}
return;
}
let languageVersion = options.target || ScriptTarget.ES3;
let outFile = options.outFile || options.out;
let firstExternalModuleSourceFile = forEach(files, f => isExternalModule(f) ? f : undefined);
if (options.isolatedModules) {
@@ -875,7 +1025,7 @@ namespace ts {
if (options.outDir || // there is --outDir specified
options.sourceRoot || // there is --sourceRoot specified
(options.mapRoot && // there is --mapRoot specified and there would be multiple js files generated
(!options.out || firstExternalModuleSourceFile !== undefined))) {
(!outFile || firstExternalModuleSourceFile !== undefined))) {
if (options.rootDir && checkSourceFilesBelongToPath(files, options.rootDir)) {
// If a rootDir is specified and is valid use it as the commonSourceDirectory
@@ -895,18 +1045,26 @@ namespace ts {
}
if (options.noEmit) {
if (options.out || options.outDir) {
diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_noEmit_cannot_be_specified_with_option_out_or_outDir));
if (options.out) {
diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "out"));
}
if (options.outFile) {
diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "outFile"));
}
if (options.outDir) {
diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "outDir"));
}
if (options.declaration) {
diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_noEmit_cannot_be_specified_with_option_declaration));
diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "noEmit", "declaration"));
}
}
if (options.emitDecoratorMetadata &&
!options.experimentalDecorators) {
diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_experimentalDecorators_must_also_be_specified_when_option_emitDecoratorMetadata_is_specified));
diagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "emitDecoratorMetadata", "experimentalDecorators"));
}
if (options.experimentalAsyncFunctions &&
+1 -1
View File
@@ -472,7 +472,7 @@ namespace ts {
break;
case CharacterCodes.hash:
if (isShebangTrivia(text, pos)) {
if (pos === 0 && isShebangTrivia(text, pos)) {
pos = scanShebangTrivia(text, pos);
continue;
}
+69
View File
@@ -159,6 +159,11 @@ namespace ts {
return sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped);
}
if (commandLine.options.init) {
writeConfigFile(commandLine.options, commandLine.fileNames);
return sys.exit(ExitStatus.Success);
}
if (commandLine.options.version) {
reportDiagnostic(createCompilerDiagnostic(Diagnostics.Version_0, ts.version));
return sys.exit(ExitStatus.Success);
@@ -489,6 +494,70 @@ namespace ts {
return Array(paddingLength + 1).join(" ");
}
}
function writeConfigFile(options: CompilerOptions, fileNames: string[]) {
let currentDirectory = sys.getCurrentDirectory();
let file = combinePaths(currentDirectory, 'tsconfig.json');
if (sys.fileExists(file)) {
reportDiagnostic(createCompilerDiagnostic(Diagnostics.A_tsconfig_json_file_is_already_defined_at_Colon_0, file));
}
else {
let compilerOptions = extend(options, defaultInitCompilerOptions);
let configurations: any = {
compilerOptions: serializeCompilerOptions(compilerOptions),
exclude: ["node_modules"]
};
if (fileNames && fileNames.length) {
// only set the files property if we have at least one file
configurations.files = fileNames;
}
sys.writeFile(file, JSON.stringify(configurations, undefined, 4));
reportDiagnostic(createCompilerDiagnostic(Diagnostics.Successfully_created_a_tsconfig_json_file));
}
return;
function serializeCompilerOptions(options: CompilerOptions): Map<string|number|boolean> {
let result: Map<string|number|boolean> = {};
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 = <Map<number>>optionDefinition.type;
for (let key in typeMap) {
if (hasProperty(typeMap, key)) {
if (typeMap[key] === value)
result[name] = key;
}
}
}
}
break;
}
}
}
return result;
}
}
}
ts.executeCommandLine(ts.sys.args);
+14 -3
View File
@@ -1411,6 +1411,7 @@ namespace ts {
/* @internal */ sourceMaps: SourceMapData[]; // Array of sourceMapData if compiler emitted sourcemaps
}
/* @internal */
export interface TypeCheckerHost {
getCompilerOptions(): CompilerOptions;
@@ -1551,8 +1552,8 @@ namespace ts {
export interface SymbolAccessiblityResult extends SymbolVisibilityResult {
errorModuleName?: string; // If the symbol is not visible from module, module's name
}
/** Indicates how to serialize the name for a TypeReferenceNode when emitting decorator
/** Indicates how to serialize the name for a TypeReferenceNode when emitting decorator
* metadata */
/* @internal */
export enum TypeReferenceSerializationKind {
@@ -1952,6 +1953,7 @@ namespace ts {
/* @internal */
export interface TypeMapper {
(t: TypeParameter): Type;
instantiations?: Type[]; // Cache of instantiations created using this type mapper.
context?: InferenceContext; // The inference context this mapper was created from.
// Only inference mappers have this set (in createInferenceMapper).
// The identity mapper and regular instantiation mappers do not need it.
@@ -2008,7 +2010,12 @@ namespace ts {
Error,
Message,
}
export const enum ModuleResolutionKind {
Classic = 1,
NodeJs = 2
}
export interface CompilerOptions {
allowNonTsExtensions?: boolean;
charset?: string;
@@ -2016,6 +2023,7 @@ namespace ts {
diagnostics?: boolean;
emitBOM?: boolean;
help?: boolean;
init?: boolean;
inlineSourceMap?: boolean;
inlineSources?: boolean;
jsx?: JsxEmit;
@@ -2032,6 +2040,7 @@ namespace ts {
noLib?: boolean;
noResolve?: boolean;
out?: string;
outFile?: string;
outDir?: string;
preserveConstEnums?: boolean;
project?: string;
@@ -2039,6 +2048,7 @@ namespace ts {
rootDir?: string;
sourceMap?: boolean;
sourceRoot?: string;
suppressExcessPropertyErrors?: boolean;
suppressImplicitAnyIndexErrors?: boolean;
target?: ScriptTarget;
version?: boolean;
@@ -2047,6 +2057,7 @@ namespace ts {
experimentalDecorators?: boolean;
experimentalAsyncFunctions?: boolean;
emitDecoratorMetadata?: boolean;
moduleResolution?: ModuleResolutionKind
/* @internal */ stripInternal?: boolean;
// Skip checking lib.d.ts to help speed up tests.
+5 -4
View File
@@ -240,7 +240,7 @@ namespace ts {
// Make an identifier from an external module name by extracting the string after the last "/" and replacing
// all non-alphanumeric characters with underscores
export function makeIdentifierFromModuleName(moduleName: string): string {
return getBaseFileName(moduleName).replace(/\W/g, "_");
return getBaseFileName(moduleName).replace(/^(\d)/, "_$1").replace(/\W/g, "_");
}
export function isBlockOrCatchScoped(declaration: Declaration) {
@@ -611,11 +611,11 @@ namespace ts {
return false;
}
export function isAccessor(node: Node): boolean {
export function isAccessor(node: Node): node is AccessorDeclaration {
return node && (node.kind === SyntaxKind.GetAccessor || node.kind === SyntaxKind.SetAccessor);
}
export function isClassLike(node: Node): boolean {
export function isClassLike(node: Node): node is ClassLikeDeclaration {
return node && (node.kind === SyntaxKind.ClassDeclaration || node.kind === SyntaxKind.ClassExpression);
}
@@ -978,6 +978,7 @@ namespace ts {
case SyntaxKind.ComputedPropertyName:
return node === (<ComputedPropertyName>parent).expression;
case SyntaxKind.Decorator:
case SyntaxKind.JsxExpression:
return true;
case SyntaxKind.ExpressionWithTypeArguments:
return (<ExpressionWithTypeArguments>parent).expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent);
@@ -1766,7 +1767,7 @@ namespace ts {
export function shouldEmitToOwnFile(sourceFile: SourceFile, compilerOptions: CompilerOptions): boolean {
if (!isDeclarationFile(sourceFile)) {
if ((isExternalModule(sourceFile) || !compilerOptions.out)) {
if ((isExternalModule(sourceFile) || !(compilerOptions.outFile || compilerOptions.out))) {
// 1. in-browser single file compilation scenario
// 2. non .js file
return compilerOptions.isolatedModules || !fileExtensionIs(sourceFile.fileName, ".js");
+36 -17
View File
@@ -123,18 +123,20 @@ module FourSlash {
mapRoot: "mapRoot",
module: "module",
out: "out",
outFile: "outFile",
outDir: "outDir",
sourceMap: "sourceMap",
sourceRoot: "sourceRoot",
allowNonTsExtensions: "allowNonTsExtensions",
resolveReference: "ResolveReference", // This flag is used to specify entry file for resolve file references. The flag is only allow once per test file
jsx: "jsx",
};
// List of allowed metadata names
let fileMetadataNames = [metadataOptionNames.fileName, metadataOptionNames.emitThisFile, metadataOptionNames.resolveReference];
let globalMetadataNames = [metadataOptionNames.allowNonTsExtensions, metadataOptionNames.baselineFile, metadataOptionNames.declaration,
metadataOptionNames.mapRoot, metadataOptionNames.module, metadataOptionNames.out,
metadataOptionNames.outDir, metadataOptionNames.sourceMap, metadataOptionNames.sourceRoot];
metadataOptionNames.mapRoot, metadataOptionNames.module, metadataOptionNames.out,metadataOptionNames.outFile,
metadataOptionNames.outDir, metadataOptionNames.sourceMap, metadataOptionNames.sourceRoot, metadataOptionNames.jsx];
function convertGlobalOptionsToCompilerOptions(globalOptions: { [idx: string]: string }): ts.CompilerOptions {
let settings: ts.CompilerOptions = { target: ts.ScriptTarget.ES5 };
@@ -169,6 +171,9 @@ module FourSlash {
case metadataOptionNames.out:
settings.out = globalOptions[prop];
break;
case metadataOptionNames.outFile:
settings.outFile = globalOptions[prop];
break;
case metadataOptionNames.outDir:
settings.outDir = globalOptions[prop];
break;
@@ -178,6 +183,20 @@ module FourSlash {
case metadataOptionNames.sourceRoot:
settings.sourceRoot = globalOptions[prop];
break;
case metadataOptionNames.jsx:
switch (globalOptions[prop].toLowerCase()) {
case "react":
settings.jsx = ts.JsxEmit.React;
break;
case "preserve":
settings.jsx = ts.JsxEmit.Preserve;
break;
default:
ts.Debug.assert(globalOptions[prop] === undefined || globalOptions[prop] === "None");
settings.jsx = ts.JsxEmit.None;
break;
}
break;
}
}
}
@@ -358,7 +377,7 @@ module FourSlash {
this.formatCodeOptions = {
IndentSize: 4,
TabSize: 4,
NewLineCharacter: ts.sys.newLine,
NewLineCharacter: Harness.IO.newLine(),
ConvertTabsToSpaces: true,
InsertSpaceAfterCommaDelimiter: true,
InsertSpaceAfterSemicolonInForStatements: true,
@@ -536,7 +555,7 @@ module FourSlash {
errors.forEach(function (error: ts.Diagnostic) {
Harness.IO.log(" minChar: " + error.start +
", limChar: " + (error.start + error.length) +
", message: " + ts.flattenDiagnosticMessageText(error.messageText, ts.sys.newLine) + "\n");
", message: " + ts.flattenDiagnosticMessageText(error.messageText, Harness.IO.newLine()) + "\n");
});
}
@@ -1247,21 +1266,21 @@ module FourSlash {
emitFiles.forEach(emitFile => {
let emitOutput = this.languageService.getEmitOutput(emitFile.fileName);
// Print emitOutputStatus in readable format
resultString += "EmitSkipped: " + emitOutput.emitSkipped + ts.sys.newLine;
resultString += "EmitSkipped: " + emitOutput.emitSkipped + Harness.IO.newLine();
if (emitOutput.emitSkipped) {
resultString += "Diagnostics:" + ts.sys.newLine;
resultString += "Diagnostics:" + Harness.IO.newLine();
let diagnostics = ts.getPreEmitDiagnostics(this.languageService.getProgram());
for (let i = 0, n = diagnostics.length; i < n; i++) {
resultString += " " + diagnostics[0].messageText + ts.sys.newLine;
resultString += " " + diagnostics[0].messageText + Harness.IO.newLine();
}
}
emitOutput.outputFiles.forEach((outputFile, idx, array) => {
let fileName = "FileName : " + outputFile.name + ts.sys.newLine;
let fileName = "FileName : " + outputFile.name + Harness.IO.newLine();
resultString = resultString + fileName + outputFile.text;
});
resultString += ts.sys.newLine;
resultString += Harness.IO.newLine();
});
return resultString;
@@ -1298,7 +1317,7 @@ module FourSlash {
Harness.IO.log(
"start: " + err.start +
", length: " + err.length +
", message: " + ts.flattenDiagnosticMessageText(err.messageText, ts.sys.newLine));
", message: " + ts.flattenDiagnosticMessageText(err.messageText, Harness.IO.newLine()));
});
}
}
@@ -1872,9 +1891,9 @@ module FourSlash {
}
function jsonMismatchString() {
return ts.sys.newLine +
"expected: '" + ts.sys.newLine + JSON.stringify(expected, (k, v) => v, 2) + "'" + ts.sys.newLine +
"actual: '" + ts.sys.newLine + JSON.stringify(actual, (k, v) => v, 2) + "'";
return Harness.IO.newLine() +
"expected: '" + Harness.IO.newLine() + JSON.stringify(expected, (k, v) => v, 2) + "'" + Harness.IO.newLine() +
"actual: '" + Harness.IO.newLine() + JSON.stringify(actual, (k, v) => v, 2) + "'";
}
}
@@ -2383,7 +2402,7 @@ module FourSlash {
let host = Harness.Compiler.createCompilerHost([{ unitName: Harness.Compiler.fourslashFileName, content: undefined }],
(fn, contents) => fourslashJsOutput = contents,
ts.ScriptTarget.Latest,
ts.sys.useCaseSensitiveFileNames);
Harness.IO.useCaseSensitiveFileNames());
let program = ts.createProgram([Harness.Compiler.fourslashFileName], { noResolve: true, target: ts.ScriptTarget.ES3 }, host);
@@ -2405,16 +2424,16 @@ module FourSlash {
],
(fn, contents) => result = contents,
ts.ScriptTarget.Latest,
ts.sys.useCaseSensitiveFileNames);
Harness.IO.useCaseSensitiveFileNames());
let program = ts.createProgram([Harness.Compiler.fourslashFileName, fileName], { out: "fourslashTestOutput.js", noResolve: true, target: ts.ScriptTarget.ES3 }, host);
let program = ts.createProgram([Harness.Compiler.fourslashFileName, fileName], { outFile: "fourslashTestOutput.js", noResolve: true, target: ts.ScriptTarget.ES3 }, host);
let sourceFile = host.getSourceFile(fileName, ts.ScriptTarget.ES3);
let diagnostics = ts.getPreEmitDiagnostics(program, sourceFile);
if (diagnostics.length > 0) {
throw new Error(`Error compiling ${fileName}: ` +
diagnostics.map(e => ts.flattenDiagnosticMessageText(e.messageText, ts.sys.newLine)).join("\r\n"));
diagnostics.map(e => ts.flattenDiagnosticMessageText(e.messageText, Harness.IO.newLine())).join("\r\n"));
}
program.emit(sourceFile);
+112 -43
View File
@@ -26,7 +26,6 @@
// Block scoped definitions work poorly for global variables, temporarily enable var
/* tslint:disable:no-var-keyword */
var Buffer: BufferConstructor = require("buffer").Buffer;
// this will work in the browser via browserify
var _chai: typeof chai = require("chai");
@@ -55,9 +54,17 @@ module Utils {
return ExecutionEnvironment.Node;
}
}
export let currentExecutionEnvironment = getExecutionEnvironment();
const Buffer: BufferConstructor = currentExecutionEnvironment !== ExecutionEnvironment.Browser
? require("buffer").Buffer
: undefined;
export function encodeString(s: string): string {
return Buffer ? (new Buffer(s)).toString("utf8") : s;
}
export function evalFile(fileContents: string, fileName: string, nodeContext?: any) {
let environment = getExecutionEnvironment();
switch (environment) {
@@ -102,7 +109,7 @@ module Utils {
let content: string = undefined;
try {
content = ts.sys.readFile(Harness.userSpecifiedRoot + path);
content = Harness.IO.readFile(Harness.userSpecifiedRoot + path);
}
catch (err) {
return undefined;
@@ -190,7 +197,7 @@ module Utils {
return {
start: diagnostic.start,
length: diagnostic.length,
messageText: ts.flattenDiagnosticMessageText(diagnostic.messageText, ts.sys.newLine),
messageText: ts.flattenDiagnosticMessageText(diagnostic.messageText, Harness.IO.newLine()),
category: (<any>ts).DiagnosticCategory[diagnostic.category],
code: diagnostic.code
};
@@ -323,8 +330,8 @@ module Utils {
assert.equal(d1.start, d2.start, "d1.start !== d2.start");
assert.equal(d1.length, d2.length, "d1.length !== d2.length");
assert.equal(
ts.flattenDiagnosticMessageText(d1.messageText, ts.sys.newLine),
ts.flattenDiagnosticMessageText(d2.messageText, ts.sys.newLine), "d1.messageText !== d2.messageText");
ts.flattenDiagnosticMessageText(d1.messageText, Harness.IO.newLine()),
ts.flattenDiagnosticMessageText(d2.messageText, Harness.IO.newLine()), "d1.messageText !== d2.messageText");
assert.equal(d1.category, d2.category, "d1.category !== d2.category");
assert.equal(d1.code, d2.code, "d1.code !== d2.code");
}
@@ -404,6 +411,10 @@ module Harness.Path {
module Harness {
export interface IO {
newLine(): string;
getCurrentDirectory(): string;
useCaseSensitiveFileNames(): boolean;
resolvePath(path: string): string;
readFile(path: string): string;
writeFile(path: string, contents: string): void;
directoryName(path: string): string;
@@ -414,9 +425,15 @@ module Harness {
listFiles(path: string, filter: RegExp, options?: { recursive?: boolean }): string[];
log(text: string): void;
getMemoryUsage?(): number;
args(): string[];
getExecutingFilePath(): string;
exit(exitCode?: number): void;
}
export var IO: IO;
// harness always uses one kind of new line
const harnessNewLine = "\r\n";
module IOImpl {
declare class Enumerator {
public atEnd(): boolean;
@@ -432,13 +449,21 @@ module Harness {
} else {
fso = {};
}
export const args = () => ts.sys.args;
export const getExecutingFilePath = () => ts.sys.getExecutingFilePath();
export const exit = (exitCode: number) => ts.sys.exit(exitCode);
export const resolvePath = (path: string) => ts.sys.resolvePath(path);
export const getCurrentDirectory = () => ts.sys.getCurrentDirectory();
export const newLine = () => harnessNewLine;
export const useCaseSensitiveFileNames = () => ts.sys.useCaseSensitiveFileNames;
export let readFile: typeof IO.readFile = ts.sys.readFile;
export let writeFile: typeof IO.writeFile = ts.sys.writeFile;
export let directoryName: typeof IO.directoryName = fso.GetParentFolderName;
export let directoryExists: typeof IO.directoryExists = fso.FolderExists;
export let fileExists: typeof IO.fileExists = fso.FileExists;
export let log: typeof IO.log = global.WScript && global.WScript.StdOut.WriteLine;
export const readFile: typeof IO.readFile = path => ts.sys.readFile(path);
export const writeFile: typeof IO.writeFile = (path, content) => ts.sys.writeFile(path, content);
export const directoryName: typeof IO.directoryName = fso.GetParentFolderName;
export const directoryExists: typeof IO.directoryExists = fso.FolderExists;
export const fileExists: typeof IO.fileExists = fso.FileExists;
export const log: typeof IO.log = global.WScript && global.WScript.StdOut.WriteLine;
export function createDirectory(path: string) {
if (directoryExists(path)) {
@@ -493,11 +518,19 @@ module Harness {
} else {
fs = pathModule = {};
}
export const resolvePath = (path: string) => ts.sys.resolvePath(path);
export const getCurrentDirectory = () => ts.sys.getCurrentDirectory();
export const newLine = () => harnessNewLine;
export const useCaseSensitiveFileNames = () => ts.sys.useCaseSensitiveFileNames;
export const args = () => ts.sys.args;
export const getExecutingFilePath = () => ts.sys.getExecutingFilePath();
export const exit = (exitCode: number) => ts.sys.exit(exitCode);
export let readFile: typeof IO.readFile = ts.sys.readFile;
export let writeFile: typeof IO.writeFile = ts.sys.writeFile;
export let fileExists: typeof IO.fileExists = fs.existsSync;
export let log: typeof IO.log = s => console.log(s);
export const readFile: typeof IO.readFile = path => ts.sys.readFile(path);
export const writeFile: typeof IO.writeFile = (path, content) => ts.sys.writeFile(path, content);
export const fileExists: typeof IO.fileExists = fs.existsSync;
export const log: typeof IO.log = s => console.log(s);
export function createDirectory(path: string) {
if (!directoryExists(path)) {
@@ -562,9 +595,13 @@ module Harness {
export module Network {
let serverRoot = "http://localhost:8888/";
// Unused?
let newLine = "\r\n";
let currentDirectory = () => "";
export const newLine = () => harnessNewLine;
export const useCaseSensitiveFileNames = () => false;
export const getCurrentDirectory = () => "";
export const args = () => <string[]>[];
export const getExecutingFilePath = () => "";
export const exit = (exitCode: number) => {};
let supportsCodePage = () => false;
module Http {
@@ -616,6 +653,7 @@ module Harness {
xhr.send(contents);
}
catch (e) {
log(`XHR Error: ${e}`);
return { status: 500, responseText: null };
}
@@ -655,6 +693,7 @@ module Harness {
return dirPath;
}
export let directoryName: typeof IO.directoryName = Utils.memoize(directoryNameImpl);
export const resolvePath = (path: string) => directoryName(path);
export function fileExists(path: string): boolean {
let response = Http.getFileFromServerSync(serverRoot + path);
@@ -840,7 +879,7 @@ module Harness {
export let fourslashSourceFile: ts.SourceFile;
export function getCanonicalFileName(fileName: string): string {
return ts.sys.useCaseSensitiveFileNames ? fileName : fileName.toLowerCase();
return Harness.IO.useCaseSensitiveFileNames() ? fileName : fileName.toLowerCase();
}
export function createCompilerHost(
@@ -858,7 +897,7 @@ module Harness {
}
let filemap: { [fileName: string]: ts.SourceFile; } = {};
let getCurrentDirectory = currentDirectory === undefined ? ts.sys.getCurrentDirectory : () => currentDirectory;
let getCurrentDirectory = currentDirectory === undefined ? Harness.IO.getCurrentDirectory : () => currentDirectory;
// Register input files
function register(file: { unitName: string; content: string; }) {
@@ -895,7 +934,7 @@ module Harness {
let newLine =
newLineKind === ts.NewLineKind.CarriageReturnLineFeed ? carriageReturnLineFeed :
newLineKind === ts.NewLineKind.LineFeed ? lineFeed :
ts.sys.newLine;
Harness.IO.newLine();
return {
getCurrentDirectory,
@@ -988,7 +1027,7 @@ module Harness {
// Treat them as library files, so include them in build, but not in baselines.
let includeBuiltFiles: { unitName: string; content: string }[] = [];
let useCaseSensitiveFileNames = ts.sys.useCaseSensitiveFileNames;
let useCaseSensitiveFileNames = Harness.IO.useCaseSensitiveFileNames();
this.settings.forEach(setCompilerOptionForSetting);
let fileOutputs: GeneratedFile[] = [];
@@ -1006,11 +1045,9 @@ module Harness {
let errors = ts.getPreEmitDiagnostics(program).concat(emitResult.diagnostics);
this.lastErrors = errors;
let result = new CompilerResult(fileOutputs, errors, program, ts.sys.getCurrentDirectory(), emitResult.sourceMaps);
let result = new CompilerResult(fileOutputs, errors, program, Harness.IO.getCurrentDirectory(), emitResult.sourceMaps);
onComplete(result, program);
// reset what newline means in case the last test changed it
ts.sys.newLine = newLine;
return options;
function setCompilerOptionForSetting(setting: Harness.TestCaseParser.CompilerSetting) {
@@ -1025,6 +1062,13 @@ module Harness {
options.module = ts.ModuleKind.UMD;
} else if (setting.value.toLowerCase() === "commonjs") {
options.module = ts.ModuleKind.CommonJS;
if (options.moduleResolution === undefined) {
// TODO: currently we have relative module names pretty much in all tests that use CommonJS module target.
// Such names could never be resolved in Node however classic resolution strategy still can handle them.
// Changing all module names to relative will be a major overhaul in code (but we'll do this anyway) so as a temporary measure
// we'll use ts.ModuleResolutionKind.Classic for CommonJS modules.
options.moduleResolution = ts.ModuleResolutionKind.Classic;
}
} else if (setting.value.toLowerCase() === "system") {
options.module = ts.ModuleKind.System;
} else if (setting.value.toLowerCase() === "unspecified") {
@@ -1036,7 +1080,16 @@ module Harness {
options.module = <any>setting.value;
}
break;
case "moduleresolution":
switch((setting.value || "").toLowerCase()) {
case "classic":
options.moduleResolution = ts.ModuleResolutionKind.Classic;
break;
case "node":
options.moduleResolution = ts.ModuleResolutionKind.NodeJs;
break;
}
break;
case "target":
case "codegentarget":
if (typeof setting.value === "string") {
@@ -1091,6 +1144,10 @@ module Harness {
options.out = setting.value;
break;
case "outfile":
options.outFile = setting.value;
break;
case "outdiroption":
case "outdir":
options.outDir = setting.value;
@@ -1159,6 +1216,10 @@ module Harness {
options.isolatedModules = setting.value === "true";
break;
case "suppressexcesspropertyerrors":
options.suppressExcessPropertyErrors = setting.value === "true";
break;
case "suppressimplicitanyindexerrors":
options.suppressImplicitAnyIndexErrors = setting.value === "true";
break;
@@ -1229,7 +1290,8 @@ module Harness {
assert(sourceFile, "Program has no source file with name '" + fileName + "'");
// Is this file going to be emitted separately
let sourceFileName: string;
if (ts.isExternalModule(sourceFile) || !options.out) {
let outFile = options.outFile || options.out;
if (ts.isExternalModule(sourceFile) || !outFile) {
if (options.outDir) {
let sourceFilePath = ts.getNormalizedAbsolutePath(sourceFile.fileName, result.currentDirectoryForProgram);
sourceFilePath = sourceFilePath.replace(result.program.getCommonSourceDirectory(), "");
@@ -1241,7 +1303,7 @@ module Harness {
}
else {
// Goes to single --out file
sourceFileName = options.out;
sourceFileName = outFile;
}
let dTsFileName = ts.removeFileExtension(sourceFileName) + ".d.ts";
@@ -1273,7 +1335,7 @@ module Harness {
errorOutput += diagnostic.file.fileName + "(" + (lineAndCharacter.line + 1) + "," + (lineAndCharacter.character + 1) + "): ";
}
errorOutput += ts.DiagnosticCategory[diagnostic.category].toLowerCase() + " TS" + diagnostic.code + ": " + ts.flattenDiagnosticMessageText(diagnostic.messageText, ts.sys.newLine) + ts.sys.newLine;
errorOutput += ts.DiagnosticCategory[diagnostic.category].toLowerCase() + " TS" + diagnostic.code + ": " + ts.flattenDiagnosticMessageText(diagnostic.messageText, Harness.IO.newLine()) + Harness.IO.newLine();
});
return errorOutput;
@@ -1282,11 +1344,11 @@ module Harness {
export function getErrorBaseline(inputFiles: { unitName: string; content: string }[], diagnostics: ts.Diagnostic[]) {
diagnostics.sort(ts.compareDiagnostics);
let outputLines: string[] = [];
// Count up all the errors we find so we don't miss any
let totalErrorsReported = 0;
// Count up all errors that were found in files other than lib.d.ts so we don't miss any
let totalErrorsReportedInNonLibraryFiles = 0;
function outputErrorText(error: ts.Diagnostic) {
let message = ts.flattenDiagnosticMessageText(error.messageText, ts.sys.newLine);
let message = ts.flattenDiagnosticMessageText(error.messageText, Harness.IO.newLine());
let errLines = RunnerBase.removeFullPaths(message)
.split("\n")
@@ -1294,8 +1356,15 @@ module Harness {
.filter(s => s.length > 0)
.map(s => "!!! " + ts.DiagnosticCategory[error.category].toLowerCase() + " TS" + error.code + ": " + s);
errLines.forEach(e => outputLines.push(e));
totalErrorsReported++;
// do not count errors from lib.d.ts here, they are computed separately as numLibraryDiagnostics
// if lib.d.ts is explicitly included in input files and there are some errors in it (i.e. because of duplicate identifiers)
// then they will be added twice thus triggering 'total errors' assertion with condition
// 'totalErrorsReportedInNonLibraryFiles + numLibraryDiagnostics + numTest262HarnessDiagnostics, diagnostics.length
if (!error.file || !isLibraryFile(error.file.fileName)) {
totalErrorsReportedInNonLibraryFiles++;
}
}
// Report global errors
@@ -1380,10 +1449,10 @@ module Harness {
});
// Verify we didn't miss any errors in total
assert.equal(totalErrorsReported + numLibraryDiagnostics + numTest262HarnessDiagnostics, diagnostics.length, "total number of errors");
assert.equal(totalErrorsReportedInNonLibraryFiles + numLibraryDiagnostics + numTest262HarnessDiagnostics, diagnostics.length, "total number of errors");
return minimalDiagnosticsToString(diagnostics) +
ts.sys.newLine + ts.sys.newLine + outputLines.join("\r\n");
Harness.IO.newLine() + Harness.IO.newLine() + outputLines.join("\r\n");
}
export function collateOutputs(outputFiles: Harness.Compiler.GeneratedFile[]): string {
@@ -1524,7 +1593,7 @@ module Harness {
"nolib", "sourcemap", "target", "out", "outdir", "noemithelpers", "noemitonerror",
"noimplicitany", "noresolve", "newline", "normalizenewline", "emitbom",
"errortruncation", "usecasesensitivefilenames", "preserveconstenums",
"includebuiltfile", "suppressimplicitanyindexerrors", "stripinternal",
"includebuiltfile", "suppressexcesspropertyerrors", "suppressimplicitanyindexerrors", "stripinternal",
"isolatedmodules", "inlinesourcemap", "maproot", "sourceroot",
"inlinesources", "emitdecoratormetadata", "experimentaldecorators",
"skipdefaultlibcheck", "jsx"];
@@ -1719,7 +1788,7 @@ module Harness {
}
function writeComparison(expected: string, actual: string, relativeFileName: string, actualFileName: string, descriptionForDescribe: string) {
let encoded_actual = (new Buffer(actual)).toString("utf8");
let encoded_actual = Utils.encodeString(actual);
if (expected != encoded_actual) {
// Overwrite & issue error
let errMsg = "The baseline file " + relativeFileName + " has changed";
@@ -1758,11 +1827,11 @@ module Harness {
return filePath.indexOf(Harness.libFolder) === 0;
}
export function getDefaultLibraryFile(): { unitName: string, content: string } {
let libFile = Harness.userSpecifiedRoot + Harness.libFolder + "/" + "lib.d.ts";
export function getDefaultLibraryFile(io: Harness.IO): { unitName: string, content: string } {
let libFile = Harness.userSpecifiedRoot + Harness.libFolder + "lib.d.ts";
return {
unitName: libFile,
content: IO.readFile(libFile)
content: io.readFile(libFile)
};
}
+20 -14
View File
@@ -93,7 +93,7 @@ module Playback {
return run;
}
export interface PlaybackSystem extends ts.System, PlaybackControl { }
export interface PlaybackIO extends Harness.IO, PlaybackControl { }
function createEmptyLog(): IOLog {
return {
@@ -223,8 +223,8 @@ module Playback {
// console.log("Swallowed write operation during replay: " + name);
}
export function wrapSystem(underlying: ts.System): PlaybackSystem {
let wrapper: PlaybackSystem = <any>{};
export function wrapIO(underlying: Harness.IO): PlaybackIO {
let wrapper: PlaybackIO = <any>{};
initWrapper(wrapper, underlying);
wrapper.startReplayFromFile = logFn => {
@@ -239,18 +239,24 @@ module Playback {
recordLog = undefined;
}
};
Object.defineProperty(wrapper, "args", {
get() {
if (replayLog !== undefined) {
return replayLog.arguments;
} else if (recordLog !== undefined) {
recordLog.arguments = underlying.args;
}
return underlying.args;
wrapper.args = () => {
if (replayLog !== undefined) {
return replayLog.arguments;
} else if (recordLog !== undefined) {
recordLog.arguments = underlying.args();
}
});
return underlying.args();
}
wrapper.newLine = () => underlying.newLine();
wrapper.useCaseSensitiveFileNames = () => underlying.useCaseSensitiveFileNames();
wrapper.directoryName = (path): string => { throw new Error("NotSupported"); };
wrapper.createDirectory = path => { throw new Error("NotSupported"); };
wrapper.directoryExists = (path): boolean => { throw new Error("NotSupported"); };
wrapper.deleteFile = path => { throw new Error("NotSupported"); };
wrapper.listFiles = (path, filter, options): string[] => { throw new Error("NotSupported"); };
wrapper.log = text => underlying.log(text);
wrapper.fileExists = recordReplay(wrapper.fileExists, underlying)(
(path) => callAndRecord(underlying.fileExists(path), recordLog.fileExists, { path: path }),
+15 -14
View File
@@ -62,7 +62,7 @@ class ProjectRunner extends RunnerBase {
let testFileText: string = null;
try {
testFileText = ts.sys.readFile(testCaseFileName);
testFileText = Harness.IO.readFile(testCaseFileName);
}
catch (e) {
assert(false, "Unable to open testcase file: " + testCaseFileName + ": " + e.message);
@@ -98,7 +98,7 @@ class ProjectRunner extends RunnerBase {
}
function cleanProjectUrl(url: string) {
let diskProjectPath = ts.normalizeSlashes(ts.sys.resolvePath(testCase.projectRoot));
let diskProjectPath = ts.normalizeSlashes(Harness.IO.resolvePath(testCase.projectRoot));
let projectRootUrl = "file:///" + diskProjectPath;
let normalizedProjectRoot = ts.normalizeSlashes(testCase.projectRoot);
diskProjectPath = diskProjectPath.substr(0, diskProjectPath.lastIndexOf(normalizedProjectRoot));
@@ -122,7 +122,7 @@ class ProjectRunner extends RunnerBase {
}
function getCurrentDirectory() {
return ts.sys.resolvePath(testCase.projectRoot);
return Harness.IO.resolvePath(testCase.projectRoot);
}
function compileProjectFiles(moduleKind: ts.ModuleKind, getInputFiles: () => string[],
@@ -158,11 +158,12 @@ class ProjectRunner extends RunnerBase {
return {
declaration: !!testCase.declaration,
sourceMap: !!testCase.sourceMap,
out: testCase.out,
outFile: testCase.out,
outDir: testCase.outDir,
mapRoot: testCase.resolveMapRoot && testCase.mapRoot ? ts.sys.resolvePath(testCase.mapRoot) : testCase.mapRoot,
sourceRoot: testCase.resolveSourceRoot && testCase.sourceRoot ? ts.sys.resolvePath(testCase.sourceRoot) : testCase.sourceRoot,
mapRoot: testCase.resolveMapRoot && testCase.mapRoot ? Harness.IO.resolvePath(testCase.mapRoot) : testCase.mapRoot,
sourceRoot: testCase.resolveSourceRoot && testCase.sourceRoot ? Harness.IO.resolvePath(testCase.sourceRoot) : testCase.sourceRoot,
module: moduleKind,
moduleResolution: ts.ModuleResolutionKind.Classic, // currently all tests use classic module resolution kind, this will change in the future
noResolve: testCase.noResolve,
rootDir: testCase.rootDir
};
@@ -190,8 +191,8 @@ class ProjectRunner extends RunnerBase {
writeFile,
getCurrentDirectory,
getCanonicalFileName: Harness.Compiler.getCanonicalFileName,
useCaseSensitiveFileNames: () => ts.sys.useCaseSensitiveFileNames,
getNewLine: () => ts.sys.newLine,
useCaseSensitiveFileNames: () => Harness.IO.useCaseSensitiveFileNames(),
getNewLine: () => Harness.IO.newLine(),
fileExists: fileName => getSourceFile(fileName, ts.ScriptTarget.ES5) !== undefined,
readFile: fileName => Harness.IO.readFile(fileName)
};
@@ -216,7 +217,7 @@ class ProjectRunner extends RunnerBase {
function getSourceFileText(fileName: string): string {
let text: string = undefined;
try {
text = ts.sys.readFile(ts.isRootedDiskPath(fileName)
text = Harness.IO.readFile(ts.isRootedDiskPath(fileName)
? fileName
: ts.normalizeSlashes(testCase.projectRoot) + "/" + ts.normalizeSlashes(fileName));
}
@@ -263,14 +264,14 @@ class ProjectRunner extends RunnerBase {
// Actual writing of file as in tc.ts
function ensureDirectoryStructure(directoryname: string) {
if (directoryname) {
if (!ts.sys.directoryExists(directoryname)) {
if (!Harness.IO.directoryExists(directoryname)) {
ensureDirectoryStructure(ts.getDirectoryPath(directoryname));
ts.sys.createDirectory(directoryname);
Harness.IO.createDirectory(directoryname);
}
}
}
ensureDirectoryStructure(ts.getDirectoryPath(ts.normalizePath(outputFilePath)));
ts.sys.writeFile(outputFilePath, data, writeByteOrderMark);
Harness.IO.writeFile(outputFilePath, data);
outputFiles.push({ emittedFileName: fileName, code: data, fileName: diskRelativeName, writeByteOrderMark: writeByteOrderMark });
}
@@ -299,7 +300,7 @@ class ProjectRunner extends RunnerBase {
allInputFiles.unshift(findOutpuDtsFile(outputDtsFileName));
}
else {
let outputDtsFileName = ts.removeFileExtension(compilerOptions.out) + ".d.ts";
let outputDtsFileName = ts.removeFileExtension(compilerOptions.outFile|| compilerOptions.out) + ".d.ts";
let outputDtsFile = findOutpuDtsFile(outputDtsFileName);
if (!ts.contains(allInputFiles, outputDtsFile)) {
allInputFiles.unshift(outputDtsFile);
@@ -391,7 +392,7 @@ class ProjectRunner extends RunnerBase {
Harness.Baseline.runBaseline("Baseline of emitted result (" + moduleNameToString(compilerResult.moduleKind) + "): " + testCaseFileName, getBaselineFolder(compilerResult.moduleKind) + outputFile.fileName, () => {
try {
return ts.sys.readFile(getProjectOutputFolder(outputFile.fileName, compilerResult.moduleKind));
return Harness.IO.readFile(getProjectOutputFolder(outputFile.fileName, compilerResult.moduleKind));
}
catch (e) {
return undefined;
-2
View File
@@ -106,6 +106,4 @@ if (runners.length === 0) {
// runners.push(new GeneratedFourslashRunner());
}
ts.sys.newLine = "\r\n";
runTests(runners);
+17 -17
View File
@@ -4,18 +4,18 @@
/// <reference path="..\compiler\commandLineParser.ts"/>
module RWC {
function runWithIOLog(ioLog: IOLog, fn: () => void) {
let oldSys = ts.sys;
function runWithIOLog(ioLog: IOLog, fn: (oldIO: Harness.IO) => void) {
let oldIO = Harness.IO;
let wrappedSys = Playback.wrapSystem(ts.sys);
wrappedSys.startReplayFromData(ioLog);
ts.sys = wrappedSys;
let wrappedIO = Playback.wrapIO(oldIO);
wrappedIO.startReplayFromData(ioLog);
Harness.IO = wrappedIO;
try {
fn();
fn(oldIO);
} finally {
wrappedSys.endReplay();
ts.sys = oldSys;
wrappedIO.endReplay();
Harness.IO = oldIO;
}
}
@@ -32,7 +32,6 @@ module RWC {
let baseName = /(.*)\/(.*).json/.exec(ts.normalizeSlashes(jsonPath))[2];
let currentDirectory: string;
let useCustomLibraryFile: boolean;
after(() => {
// Mocha holds onto the closure environment of the describe callback even after the test is done.
// Therefore we have to clean out large objects after the test is done.
@@ -57,7 +56,7 @@ module RWC {
currentDirectory = ioLog.currentDirectory;
useCustomLibraryFile = ioLog.useCustomLibraryFile;
runWithIOLog(ioLog, () => {
opts = ts.parseCommandLine(ioLog.arguments);
opts = ts.parseCommandLine(ioLog.arguments, fileName => Harness.IO.readFile(fileName));
assert.equal(opts.errors.length, 0);
// To provide test coverage of output javascript file,
@@ -65,7 +64,7 @@ module RWC {
opts.options.noEmitOnError = false;
});
runWithIOLog(ioLog, () => {
runWithIOLog(ioLog, oldIO => {
harnessCompiler.reset();
// Load the files
@@ -77,7 +76,7 @@ module RWC {
let isInInputList = (resolvedPath: string) => (inputFile: { unitName: string; content: string; }) => inputFile.unitName === resolvedPath;
for (let fileRead of ioLog.filesRead) {
// Check if the file is already added into the set of input files.
const resolvedPath = ts.normalizeSlashes(ts.sys.resolvePath(fileRead.path));
const resolvedPath = ts.normalizeSlashes(Harness.IO.resolvePath(fileRead.path));
let inInputList = ts.forEach(inputFiles, isInInputList(resolvedPath));
if (!Harness.isLibraryFile(fileRead.path)) {
@@ -97,7 +96,8 @@ module RWC {
inputFiles.push(getHarnessCompilerInputUnit(fileRead.path));
}
else {
inputFiles.push(Harness.getDefaultLibraryFile());
// set the flag to put default library to the beginning of the list
inputFiles.unshift(Harness.getDefaultLibraryFile(oldIO));
}
}
}
@@ -118,13 +118,13 @@ module RWC {
});
function getHarnessCompilerInputUnit(fileName: string) {
let unitName = ts.normalizeSlashes(ts.sys.resolvePath(fileName));
let unitName = ts.normalizeSlashes(Harness.IO.resolvePath(fileName));
let content: string = null;
try {
content = ts.sys.readFile(unitName);
content = Harness.IO.readFile(unitName);
}
catch (e) {
content = ts.sys.readFile(fileName);
content = Harness.IO.readFile(fileName);
}
return { unitName, content };
}
@@ -187,7 +187,7 @@ module RWC {
}
return Harness.Compiler.minimalDiagnosticsToString(declFileCompilationResult.declResult.errors) +
ts.sys.newLine + ts.sys.newLine +
Harness.IO.newLine() + Harness.IO.newLine() +
Harness.Compiler.getErrorBaseline(declFileCompilationResult.declInputFiles.concat(declFileCompilationResult.declOtherFiles), declFileCompilationResult.declResult.errors);
}, false, baselineOpts);
}
+2646 -5
View File
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -8,4 +8,4 @@ interface NodeList {
interface NodeListOf<TNode extends Node> {
[Symbol.iterator](): IterableIterator<TNode>
}
}
+36 -13
View File
@@ -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<Element>;
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<Element>;
insertAdjacentElement(position: string, insertedElement: Element): Element;
insertAdjacentHTML(where: string, html: string): void;
insertAdjacentText(where: string, text: string): void;
@@ -6865,7 +6865,7 @@ interface IDBDatabase extends EventTarget {
createObjectStore(name: string, optionalParameters?: any): IDBObjectStore;
deleteObjectStore(name: string): void;
transaction(storeNames: any, mode?: string): IDBTransaction;
addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void;
addEventListener(type: "abort", listener: (ev: Event) => any, useCapture?: boolean): void;
addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void;
addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
}
@@ -6986,7 +6986,7 @@ interface IDBTransaction extends EventTarget {
READ_ONLY: string;
READ_WRITE: string;
VERSION_CHANGE: string;
addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void;
addEventListener(type: "abort", listener: (ev: Event) => any, useCapture?: boolean): void;
addEventListener(type: "complete", listener: (ev: Event) => any, useCapture?: boolean): void;
addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void;
addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
@@ -7016,11 +7016,14 @@ interface ImageData {
width: number;
}
declare var ImageData: {
interface ImageDataConstructor {
prototype: ImageData;
new(): ImageData;
new(width: number, height: number): ImageData;
new(array: Uint8ClampedArray, width: number, height: number): ImageData;
}
declare var ImageData: ImageDataConstructor;
interface KeyboardEvent extends UIEvent {
altKey: boolean;
char: string;
@@ -7703,7 +7706,7 @@ interface MessageEvent extends Event {
declare var MessageEvent: {
prototype: MessageEvent;
new(): MessageEvent;
new(type: string, eventInitDict?: MessageEventInit): MessageEvent;
}
interface MessagePort extends EventTarget {
@@ -8445,7 +8448,7 @@ interface ProgressEvent extends Event {
declare var ProgressEvent: {
prototype: ProgressEvent;
new(): ProgressEvent;
new(type: string, eventInitDict?: ProgressEventInit): ProgressEvent;
}
interface Range {
@@ -12169,7 +12172,7 @@ interface XMLHttpRequest extends EventTarget, XMLHttpRequestEventTarget {
LOADING: number;
OPENED: number;
UNSENT: number;
addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void;
addEventListener(type: "abort", listener: (ev: Event) => any, useCapture?: boolean): void;
addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void;
addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void;
addEventListener(type: "loadend", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void;
@@ -12439,7 +12442,7 @@ interface MSBaseReader {
DONE: number;
EMPTY: number;
LOADING: number;
addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void;
addEventListener(type: "abort", listener: (ev: Event) => any, useCapture?: boolean): void;
addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void;
addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void;
addEventListener(type: "loadend", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void;
@@ -12595,7 +12598,7 @@ interface XMLHttpRequestEventTarget {
onloadstart: (ev: Event) => any;
onprogress: (ev: ProgressEvent) => any;
ontimeout: (ev: ProgressEvent) => any;
addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void;
addEventListener(type: "abort", listener: (ev: Event) => any, useCapture?: boolean): void;
addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void;
addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void;
addEventListener(type: "loadend", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void;
@@ -12617,12 +12620,32 @@ interface BlobPropertyBag {
endings?: string;
}
interface FilePropertyBag {
type?: string;
lastModified?: number;
}
interface EventListenerObject {
handleEvent(evt: Event): void;
}
declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject;
interface MessageEventInit extends EventInit {
data?: any;
origin?: string;
lastEventId?: string;
channel?: string;
source?: any;
ports?: MessagePort[];
}
interface ProgressEventInit extends EventInit {
lengthComputable?: boolean;
loaded?: number;
total?: number;
}
interface ErrorEventHandler {
(message: string, filename?: string, lineno?: number, colno?: number, error?:Error): void;
}
@@ -12952,4 +12975,4 @@ declare function addEventListener(type: "unload", listener: (ev: Event) => any,
declare function addEventListener(type: "volumechange", listener: (ev: Event) => any, useCapture?: boolean): void;
declare function addEventListener(type: "waiting", listener: (ev: Event) => any, useCapture?: boolean): void;
declare function addEventListener(type: "wheel", listener: (ev: WheelEvent) => any, useCapture?: boolean): void;
declare function addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
declare function addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
+56 -2505
View File
File diff suppressed because it is too large Load Diff
-2305
View File
File diff suppressed because it is too large Load Diff
+30 -2
View File
@@ -88,6 +88,7 @@ declare module Intl {
timeZoneName?: string;
formatMatcher?: string;
hour12?: boolean;
timeZone?: string;
}
interface ResolvedDateTimeFormatOptions {
@@ -157,17 +158,44 @@ interface Number {
interface Date {
/**
* Converts a date to a string by using the current or specified locale.
* Converts a date and time to a string by using the current or specified locale.
* @param locales An array of locale strings that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used.
* @param options An object that contains one or more properties that specify comparison options.
*/
toLocaleString(locales?: string[], options?: Intl.DateTimeFormatOptions): string;
/**
* Converts a date to a string by using the current or specified locale.
* @param locales An array of locale strings that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used.
* @param options An object that contains one or more properties that specify comparison options.
*/
toLocaleDateString(locales?: string[], options?: Intl.DateTimeFormatOptions): string;
/**
* Converts a time to a string by using the current or specified locale.
* @param locale Locale tag. If you omit this parameter, the default locale of the JavaScript runtime is used.
* @param options An object that contains one or more properties that specify comparison options.
*/
toLocaleTimeString(locale?: string[], options?: Intl.DateTimeFormatOptions): string;
/**
* Converts a date and time to a string by using the current or specified locale.
* @param locale Locale tag. If you omit this parameter, the default locale of the JavaScript runtime is used.
* @param options An object that contains one or more properties that specify comparison options.
*/
toLocaleString(locale?: string, options?: Intl.DateTimeFormatOptions): string;
/**
* Converts a date to a string by using the current or specified locale.
* @param locale Locale tag. If you omit this parameter, the default locale of the JavaScript runtime is used.
* @param options An object that contains one or more properties that specify comparison options.
*/
toLocaleString(locale?: string, options?: Intl.DateTimeFormatOptions): string;
toLocaleDateString(locale?: string, options?: Intl.DateTimeFormatOptions): string;
/**
* Converts a time to a string by using the current or specified locale.
* @param locale Locale tag. If you omit this parameter, the default locale of the JavaScript runtime is used.
* @param options An object that contains one or more properties that specify comparison options.
*/
toLocaleTimeString(locale?: string, options?: Intl.DateTimeFormatOptions): string;
}
+141 -20
View File
@@ -3,10 +3,28 @@
/// IE Worker APIs
/////////////////////////////
interface EventInit {
bubbles?: boolean;
cancelable?: boolean;
}
interface EventListener {
(evt: Event): void;
}
interface AudioBuffer {
duration: number;
length: number;
numberOfChannels: number;
sampleRate: number;
getChannelData(channel: number): any;
}
declare var AudioBuffer: {
prototype: AudioBuffer;
new(): AudioBuffer;
}
interface Blob {
size: number;
type: string;
@@ -60,6 +78,21 @@ declare var Console: {
new(): Console;
}
interface Coordinates {
accuracy: number;
altitude: number;
altitudeAccuracy: number;
heading: number;
latitude: number;
longitude: number;
speed: number;
}
declare var Coordinates: {
prototype: Coordinates;
new(): Coordinates;
}
interface DOMError {
name: string;
toString(): string;
@@ -210,7 +243,7 @@ interface File extends Blob {
declare var File: {
prototype: File;
new(): File;
new (parts: (ArrayBuffer | ArrayBufferView | Blob | string)[], filename: string, properties?: FilePropertyBag): File;
}
interface FileList {
@@ -281,7 +314,7 @@ interface IDBDatabase extends EventTarget {
createObjectStore(name: string, optionalParameters?: any): IDBObjectStore;
deleteObjectStore(name: string): void;
transaction(storeNames: any, mode?: string): IDBTransaction;
addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void;
addEventListener(type: "abort", listener: (ev: Event) => any, useCapture?: boolean): void;
addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void;
addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
}
@@ -402,7 +435,7 @@ interface IDBTransaction extends EventTarget {
READ_ONLY: string;
READ_WRITE: string;
VERSION_CHANGE: string;
addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void;
addEventListener(type: "abort", listener: (ev: Event) => any, useCapture?: boolean): void;
addEventListener(type: "complete", listener: (ev: Event) => any, useCapture?: boolean): void;
addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void;
addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
@@ -432,11 +465,14 @@ interface ImageData {
width: number;
}
declare var ImageData: {
interface ImageDataConstructor {
prototype: ImageData;
new(): ImageData;
new(width: number, height: number): ImageData;
new(array: Uint8ClampedArray, width: number, height: number): ImageData;
}
declare var ImageData: ImageDataConstructor;
interface MSApp {
clearTemporaryWebDataAsync(): MSAppAsyncOperation;
createBlobFromRandomAccessStream(type: string, seeker: any): Blob;
@@ -460,6 +496,29 @@ interface MSApp {
}
declare var MSApp: MSApp;
interface MSAppAsyncOperation extends EventTarget {
error: DOMError;
oncomplete: (ev: Event) => any;
onerror: (ev: Event) => any;
readyState: number;
result: any;
start(): void;
COMPLETED: number;
ERROR: number;
STARTED: number;
addEventListener(type: "complete", listener: (ev: Event) => any, useCapture?: boolean): void;
addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void;
addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
}
declare var MSAppAsyncOperation: {
prototype: MSAppAsyncOperation;
new(): MSAppAsyncOperation;
COMPLETED: number;
ERROR: number;
STARTED: number;
}
interface MSBlobBuilder {
append(data: any, endings?: string): void;
getBlob(contentType?: string): Blob;
@@ -496,6 +555,18 @@ declare var MSStreamReader: {
new(): MSStreamReader;
}
interface MediaQueryList {
matches: boolean;
media: string;
addListener(listener: MediaQueryListListener): void;
removeListener(listener: MediaQueryListListener): void;
}
declare var MediaQueryList: {
prototype: MediaQueryList;
new(): MediaQueryList;
}
interface MessageChannel {
port1: MessagePort;
port2: MessagePort;
@@ -516,7 +587,7 @@ interface MessageEvent extends Event {
declare var MessageEvent: {
prototype: MessageEvent;
new(): MessageEvent;
new(type: string, eventInitDict?: MessageEventInit): MessageEvent;
}
interface MessagePort extends EventTarget {
@@ -533,6 +604,33 @@ declare var MessagePort: {
new(): MessagePort;
}
interface Position {
coords: Coordinates;
timestamp: number;
}
declare var Position: {
prototype: Position;
new(): Position;
}
interface PositionError {
code: number;
message: string;
toString(): string;
PERMISSION_DENIED: number;
POSITION_UNAVAILABLE: number;
TIMEOUT: number;
}
declare var PositionError: {
prototype: PositionError;
new(): PositionError;
PERMISSION_DENIED: number;
POSITION_UNAVAILABLE: number;
TIMEOUT: number;
}
interface ProgressEvent extends Event {
lengthComputable: boolean;
loaded: number;
@@ -542,7 +640,7 @@ interface ProgressEvent extends Event {
declare var ProgressEvent: {
prototype: ProgressEvent;
new(): ProgressEvent;
new(type: string, eventInitDict?: ProgressEventInit): ProgressEvent;
}
interface WebSocket extends EventTarget {
@@ -620,7 +718,7 @@ interface XMLHttpRequest extends EventTarget, XMLHttpRequestEventTarget {
LOADING: number;
OPENED: number;
UNSENT: number;
addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void;
addEventListener(type: "abort", listener: (ev: Event) => any, useCapture?: boolean): void;
addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void;
addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void;
addEventListener(type: "loadend", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void;
@@ -642,6 +740,15 @@ declare var XMLHttpRequest: {
create(): XMLHttpRequest;
}
interface XMLHttpRequestUpload extends EventTarget, XMLHttpRequestEventTarget {
addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
}
declare var XMLHttpRequestUpload: {
prototype: XMLHttpRequestUpload;
new(): XMLHttpRequestUpload;
}
interface AbstractWorker {
onerror: (ev: Event) => any;
addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void;
@@ -661,7 +768,7 @@ interface MSBaseReader {
DONE: number;
EMPTY: number;
LOADING: number;
addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void;
addEventListener(type: "abort", listener: (ev: Event) => any, useCapture?: boolean): void;
addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void;
addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void;
addEventListener(type: "loadend", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void;
@@ -702,7 +809,7 @@ interface XMLHttpRequestEventTarget {
onloadstart: (ev: Event) => any;
onprogress: (ev: ProgressEvent) => any;
ontimeout: (ev: ProgressEvent) => any;
addEventListener(type: "abort", listener: (ev: UIEvent) => any, useCapture?: boolean): void;
addEventListener(type: "abort", listener: (ev: Event) => any, useCapture?: boolean): void;
addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void;
addEventListener(type: "load", listener: (ev: Event) => any, useCapture?: boolean): void;
addEventListener(type: "loadend", listener: (ev: ProgressEvent) => any, useCapture?: boolean): void;
@@ -788,23 +895,37 @@ interface WorkerUtils extends Object, WindowBase64 {
}
interface NodeListOf<TNode extends Node> extends NodeList {
length: number;
item(index: number): TNode;
[index: number]: TNode;
}
interface BlobPropertyBag {
type?: string;
endings?: string;
}
interface FilePropertyBag {
type?: string;
lastModified?: number;
}
interface EventListenerObject {
handleEvent(evt: Event): void;
}
declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject;
interface MessageEventInit extends EventInit {
data?: any;
origin?: string;
lastEventId?: string;
channel?: string;
source?: any;
ports?: MessagePort[];
}
interface ProgressEventInit extends EventInit {
lengthComputable?: boolean;
loaded?: number;
total?: number;
}
interface ErrorEventHandler {
(message: string, filename?: string, lineno?: number, colno?: number, error?:Error): void;
}
@@ -820,11 +941,11 @@ interface MediaQueryListListener {
interface MSLaunchUriCallback {
(): void;
}
interface FrameRequestCallback {
(time: number): void;
interface MSUnsafeFunctionCallback {
(): any;
}
interface MutationCallback {
(mutations: MutationRecord[], observer: MutationObserver): void;
interface MSExecAtPriorityFunctionCallback {
(...args: any[]): any;
}
interface DecodeSuccessCallback {
(decodedData: AudioBuffer): void;
+186 -57
View File
@@ -224,6 +224,14 @@ namespace ts.server {
this.roots.push(info);
}
}
removeRoot(info: ScriptInfo) {
var scriptInfo = ts.lookUp(this.filenameToScript, info.fileName);
if (scriptInfo) {
this.filenameToScript[info.fileName] = undefined;
this.roots = copyListRemovingItem(info, this.roots);
}
}
saveTo(filename: string, tmpfilename: string) {
var script = this.getScriptInfo(filename);
@@ -345,6 +353,7 @@ namespace ts.server {
export class Project {
compilerService: CompilerService;
projectFilename: string;
projectFileWatcher: FileWatcher;
program: ts.Program;
filenameToSourceFile: ts.Map<ts.SourceFile> = {};
updateGraphSeq = 0;
@@ -352,7 +361,7 @@ namespace ts.server {
openRefCount = 0;
constructor(public projectService: ProjectService, public projectOptions?: ProjectOptions) {
this.compilerService = new CompilerService(this,projectOptions && projectOptions.compilerOptions);
this.compilerService = new CompilerService(this, projectOptions && projectOptions.compilerOptions);
}
addOpenRef() {
@@ -423,6 +432,12 @@ namespace ts.server {
info.defaultProject = this;
this.compilerService.host.addRoot(info);
}
// remove a root file from project
removeRoot(info: ScriptInfo) {
info.defaultProject = undefined;
this.compilerService.host.removeRoot(info);
}
filesToString() {
var strBuilder = "";
@@ -517,6 +532,12 @@ namespace ts.server {
}
}
watchedProjectConfigFileChanged(project: Project) {
this.log("Config File Changed: " + project.projectFilename);
this.updateConfiguredProject(project);
this.updateProjectStructure();
}
log(msg: string, type = "Err") {
this.psLogger.msg(msg, type);
}
@@ -594,16 +615,29 @@ namespace ts.server {
this.configuredProjects = configuredProjects;
}
removeConfiguredProject(project: Project) {
project.projectFileWatcher.close();
this.configuredProjects = copyListRemovingItem(project, this.configuredProjects);
let fileNames = project.getFileNames();
for (let fileName of fileNames) {
let info = this.getScriptInfo(fileName);
if (info.defaultProject == project) {
info.defaultProject = undefined;
}
}
}
setConfiguredProjectRoot(info: ScriptInfo) {
for (var i = 0, len = this.configuredProjects.length; i < len; i++) {
let configuredProject = this.configuredProjects[i];
if (configuredProject.isRoot(info)) {
info.defaultProject = configuredProject;
configuredProject.addOpenRef();
return true;
}
}
return false;
for (var i = 0, len = this.configuredProjects.length; i < len; i++) {
let configuredProject = this.configuredProjects[i];
if (configuredProject.isRoot(info)) {
info.defaultProject = configuredProject;
configuredProject.addOpenRef();
return true;
}
}
return false;
}
addOpenFile(info: ScriptInfo) {
@@ -647,7 +681,6 @@ namespace ts.server {
/**
* Remove this file from the set of open, non-configured files.
* @param info The file that has been closed or newly configured
* @param openedByConfig True if info has become a root of a configured project
*/
closeOpenFile(info: ScriptInfo) {
var openFileRoots: ScriptInfo[] = [];
@@ -736,18 +769,42 @@ namespace ts.server {
return referencingProjects;
}
reloadProjects() {
// First check if there is new tsconfig file added for inferred project roots
for (let info of this.openFileRoots) {
this.openOrUpdateConfiguredProjectForFile(info.fileName);
}
this.updateProjectStructure();
}
/**
* This function is to update the project structure for every projects.
* It is called on the premise that all the configured projects are
* up to date.
*/
updateProjectStructure() {
this.log("updating project structure from ...", "Info");
this.printProjects();
let unattachedOpenFiles: ScriptInfo[] = [];
let openFileRootsConfigured: ScriptInfo[] = [];
for (let info of this.openFileRootsConfigured) {
let project = info.defaultProject;
if (!project || !(project.getSourceFile(info))) {
info.defaultProject = undefined;
unattachedOpenFiles.push(info);
}
else {
openFileRootsConfigured.push(info);
}
}
this.openFileRootsConfigured = openFileRootsConfigured;
// First loop through all open files that are referenced by projects but are not
// project roots. For each referenced file, see if the default project still
// references that file. If so, then just keep the file in the referenced list.
// If not, add the file to an unattached list, to be rechecked later.
var openFilesReferenced: ScriptInfo[] = [];
var unattachedOpenFiles: ScriptInfo[] = [];
for (var i = 0, len = this.openFilesReferenced.length; i < len; i++) {
var referencedFile = this.openFilesReferenced[i];
referencedFile.defaultProject.updateGraph();
@@ -857,32 +914,40 @@ namespace ts.server {
* Open file whose contents is managed by the client
* @param filename is absolute pathname
*/
openClientFile(fileName: string) {
var searchPath = ts.normalizePath(getDirectoryPath(fileName));
this.log("Search path: " + searchPath,"Info");
var configFileName = this.findConfigFile(searchPath);
if (configFileName) {
this.log("Config file name: " + configFileName, "Info");
} else {
this.log("no config file");
}
if (configFileName && (!this.configProjectIsActive(configFileName))) {
var configResult = this.openConfigFile(configFileName, fileName);
if (!configResult.success) {
this.log("Error opening config file " + configFileName + " " + configResult.errorMsg);
}
else {
this.log("Opened configuration file " + configFileName,"Info");
this.configuredProjects.push(configResult.project);
}
}
this.openOrUpdateConfiguredProjectForFile(fileName);
var info = this.openFile(fileName, true);
this.addOpenFile(info);
this.printProjects();
return info;
}
openOrUpdateConfiguredProjectForFile(fileName: string) {
let searchPath = ts.normalizePath(getDirectoryPath(fileName));
this.log("Search path: " + searchPath, "Info");
let configFileName = this.findConfigFile(searchPath);
if (configFileName) {
this.log("Config file name: " + configFileName, "Info");
let project = this.findConfiguredProjectByConfigFile(configFileName);
if (!project) {
var configResult = this.openConfigFile(configFileName, fileName);
if (!configResult.success) {
this.log("Error opening config file " + configFileName + " " + configResult.errorMsg);
}
else {
this.log("Opened configuration file " + configFileName, "Info");
this.configuredProjects.push(configResult.project);
}
}
else {
this.updateConfiguredProject(project);
}
}
else {
this.log("No config files found.");
}
}
/**
* Close file whose contents is managed by the client
* @param filename is absolute pathname
@@ -935,7 +1000,7 @@ namespace ts.server {
for (var i = 0, len = this.configuredProjects.length; i < len; i++) {
var project = this.configuredProjects[i];
project.updateGraph();
this.psLogger.info("Project (configured) " + (i+this.inferredProjects.length).toString());
this.psLogger.info("Project (configured) " + (i + this.inferredProjects.length).toString());
this.psLogger.info(project.filesToString());
this.psLogger.info("-----------------------------------------------");
}
@@ -959,49 +1024,113 @@ namespace ts.server {
}
configProjectIsActive(fileName: string) {
for (var i = 0, len = this.configuredProjects.length; i < len; i++) {
if (this.configuredProjects[i].projectFilename == fileName) {
return true;
}
}
return false;
return this.findConfiguredProjectByConfigFile(fileName) === undefined;
}
openConfigFile(configFilename: string, clientFileName?: string): ProjectOpenResult {
findConfiguredProjectByConfigFile(configFileName: string) {
for (var i = 0, len = this.configuredProjects.length; i < len; i++) {
if (this.configuredProjects[i].projectFilename == configFileName) {
return this.configuredProjects[i];
}
}
return undefined;
}
configFileToProjectOptions(configFilename: string): { succeeded: boolean, projectOptions?: ProjectOptions, error?: ProjectOpenResult } {
configFilename = ts.normalizePath(configFilename);
// file references will be relative to dirPath (or absolute)
var dirPath = ts.getDirectoryPath(configFilename);
var contents = this.host.readFile(configFilename)
var rawConfig: { config?: ProjectOptions; error?: Diagnostic; } = ts.parseConfigFileText(configFilename, contents);
if (rawConfig.error) {
return rawConfig.error;
return { succeeded: false, error: rawConfig.error };
}
else {
var parsedCommandLine = ts.parseConfigFile(rawConfig.config, this.host, dirPath);
if (parsedCommandLine.errors && (parsedCommandLine.errors.length > 0)) {
return { errorMsg: "tsconfig option errors" };
return { succeeded: false, error: { errorMsg: "tsconfig option errors" } };
}
else if (parsedCommandLine.fileNames) {
else if (parsedCommandLine.fileNames == null) {
return { succeeded: false, error: { errorMsg: "no files found" } }
}
else {
var projectOptions: ProjectOptions = {
files: parsedCommandLine.fileNames,
compilerOptions: parsedCommandLine.options
};
var proj = this.createProject(configFilename, projectOptions);
for (var i = 0, len = parsedCommandLine.fileNames.length; i < len; i++) {
var rootFilename = parsedCommandLine.fileNames[i];
if (this.host.fileExists(rootFilename)) {
var info = this.openFile(rootFilename, clientFileName == rootFilename);
proj.addRoot(info);
}
else {
return { errorMsg: "specified file " + rootFilename + " not found" };
}
return { succeeded: true, projectOptions };
}
}
}
openConfigFile(configFilename: string, clientFileName?: string): ProjectOpenResult {
let { succeeded, projectOptions, error } = this.configFileToProjectOptions(configFilename);
if (!succeeded) {
return error;
}
else {
let proj = this.createProject(configFilename, projectOptions);
for (let i = 0, len = projectOptions.files.length; i < len; i++) {
let rootFilename = projectOptions.files[i];
if (this.host.fileExists(rootFilename)) {
let info = this.openFile(rootFilename, /*openedByClient*/ clientFileName == rootFilename);
proj.addRoot(info);
}
proj.finishGraph();
return { success: true, project: proj };
else {
return { errorMsg: "specified file " + rootFilename + " not found" };
}
}
proj.finishGraph();
proj.projectFileWatcher = this.host.watchFile(configFilename, _ => this.watchedProjectConfigFileChanged(proj));
return { success: true, project: proj };
}
}
updateConfiguredProject(project: Project) {
if (!this.host.fileExists(project.projectFilename)) {
this.log("Config file deleted");
this.removeConfiguredProject(project);
}
else {
let { succeeded, projectOptions, error } = this.configFileToProjectOptions(project.projectFilename);
if (!succeeded) {
return error;
}
else {
return { errorMsg: "no files found" };
let oldFileNames = project.compilerService.host.roots.map(info => info.fileName);
let newFileNames = projectOptions.files;
let fileNamesToRemove = oldFileNames.filter(f => newFileNames.indexOf(f) < 0);
let fileNamesToAdd = newFileNames.filter(f => oldFileNames.indexOf(f) < 0);
for (let fileName of fileNamesToRemove) {
let info = this.getScriptInfo(fileName);
project.removeRoot(info);
}
for (let fileName of fileNamesToAdd) {
let info = this.getScriptInfo(fileName);
if (!info) {
info = this.openFile(fileName, false);
}
else {
// if the root file was opened by client, it would belong to either
// openFileRoots or openFileReferenced.
if (info.isOpen) {
if (this.openFileRoots.indexOf(info) >= 0) {
this.openFileRoots = copyListRemovingItem(info, this.openFileRoots);
}
if (this.openFilesReferenced.indexOf(info) >= 0) {
this.openFilesReferenced = copyListRemovingItem(info, this.openFilesReferenced);
}
this.openFileRootsConfigured.push(info);
}
}
project.addRoot(info);
}
project.setProjectOptions(projectOptions);
project.finishGraph();
}
}
}
+6
View File
@@ -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
+9
View File
@@ -100,6 +100,7 @@ namespace ts.server {
export const SignatureHelp = "signatureHelp";
export const TypeDefinition = "typeDefinition";
export const ProjectInfo = "projectInfo";
export const ReloadProjects = "reloadProjects";
export const Unknown = "unknown";
}
@@ -226,6 +227,10 @@ namespace ts.server {
this.syntacticCheck(file, project);
this.semanticCheck(file, project);
}
private reloadProjects() {
this.projectService.reloadProjects();
}
private updateProjectStructure(seq: number, matchSeq: (seq: number) => boolean, ms = 1500) {
setTimeout(() => {
@@ -1033,6 +1038,10 @@ namespace ts.server {
var { file, needFileNameList } = <protocol.ProjectInfoRequestArgs>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]) {
+46
View File
@@ -213,6 +213,26 @@ namespace ts.formatting {
public NoSpaceBetweenYieldKeywordAndStar: Rule;
public SpaceBetweenYieldOrYieldStarAndOperand: Rule;
// Async-await
public SpaceBetweenAsyncAndFunctionKeyword: Rule;
public NoSpaceBetweenAsyncAndFunctionKeyword: Rule;
public SpaceAfterAwaitKeyword: Rule;
public NoSpaceAfterAwaitKeyword: Rule;
// Type alias declaration
public SpaceAfterTypeKeyword: Rule;
public NoSpaceAfterTypeKeyword: Rule;
// Tagged template string
public SpaceBetweenTagAndTemplateString: Rule;
public NoSpaceBetweenTagAndTemplateString: Rule;
// Union type
public SpaceBeforeBar: Rule;
public NoSpaceBeforeBar: Rule;
public SpaceAfterBar: Rule;
public NoSpaceAfterBar: Rule;
constructor() {
///
/// Common Rules
@@ -360,6 +380,27 @@ namespace ts.formatting {
this.NoSpaceBetweenYieldKeywordAndStar = new Rule(RuleDescriptor.create1(SyntaxKind.YieldKeyword, SyntaxKind.AsteriskToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), RuleAction.Delete));
this.SpaceBetweenYieldOrYieldStarAndOperand = new Rule(RuleDescriptor.create4(Shared.TokenRange.FromTokens([SyntaxKind.YieldKeyword, SyntaxKind.AsteriskToken]), Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), RuleAction.Space));
// Async-await
this.SpaceBetweenAsyncAndFunctionKeyword = new Rule(RuleDescriptor.create1(SyntaxKind.AsyncKeyword, SyntaxKind.FunctionKeyword), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space));
this.NoSpaceBetweenAsyncAndFunctionKeyword = new Rule(RuleDescriptor.create1(SyntaxKind.AsyncKeyword, SyntaxKind.FunctionKeyword), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete));
this.SpaceAfterAwaitKeyword = new Rule(RuleDescriptor.create3(SyntaxKind.AwaitKeyword, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space));
this.NoSpaceAfterAwaitKeyword = new Rule(RuleDescriptor.create3(SyntaxKind.AwaitKeyword, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete));
// Type alias declaration
this.SpaceAfterTypeKeyword = new Rule(RuleDescriptor.create3(SyntaxKind.TypeKeyword, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space));
this.NoSpaceAfterTypeKeyword = new Rule(RuleDescriptor.create3(SyntaxKind.TypeKeyword, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete));
// template string
this.SpaceBetweenTagAndTemplateString = new Rule(RuleDescriptor.create3(SyntaxKind.Identifier, Shared.TokenRange.FromTokens([SyntaxKind.NoSubstitutionTemplateLiteral, SyntaxKind.TemplateHead])), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space));
this.NoSpaceBetweenTagAndTemplateString = new Rule(RuleDescriptor.create3(SyntaxKind.Identifier, Shared.TokenRange.FromTokens([SyntaxKind.NoSubstitutionTemplateLiteral, SyntaxKind.TemplateHead])), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete));
// union type
this.SpaceBeforeBar = new Rule(RuleDescriptor.create3(SyntaxKind.BarToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space));
this.NoSpaceBeforeBar = new Rule(RuleDescriptor.create3(SyntaxKind.BarToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete));
this.SpaceAfterBar = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.BarToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space));
this.NoSpaceAfterBar = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.BarToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete));
// These rules are higher in priority than user-configurable rules.
this.HighPriorityCommonRules =
[
@@ -386,6 +427,11 @@ namespace ts.formatting {
this.NoSpaceBeforeOpenParenInFuncCall,
this.SpaceBeforeBinaryKeywordOperator, this.SpaceAfterBinaryKeywordOperator,
this.SpaceAfterVoidOperator,
this.SpaceBetweenAsyncAndFunctionKeyword, this.NoSpaceBetweenAsyncAndFunctionKeyword,
this.SpaceAfterAwaitKeyword, this.NoSpaceAfterAwaitKeyword,
this.SpaceAfterTypeKeyword, this.NoSpaceAfterTypeKeyword,
this.SpaceBetweenTagAndTemplateString, this.NoSpaceBetweenTagAndTemplateString,
this.SpaceBeforeBar, this.NoSpaceBeforeBar, this.SpaceAfterBar, this.NoSpaceAfterBar,
// TypeScript-specific rules
this.NoSpaceAfterConstructor, this.NoSpaceAfterModuleImport,
+11 -2
View File
@@ -408,6 +408,7 @@ namespace ts.formatting {
case SyntaxKind.ClassDeclaration:
case SyntaxKind.InterfaceDeclaration:
case SyntaxKind.EnumDeclaration:
case SyntaxKind.TypeAliasDeclaration:
case SyntaxKind.ArrayLiteralExpression:
case SyntaxKind.Block:
case SyntaxKind.ModuleBlock:
@@ -431,6 +432,16 @@ namespace ts.formatting {
case SyntaxKind.JsxElement:
case SyntaxKind.JsxOpeningElement:
case SyntaxKind.JsxExpression:
case SyntaxKind.MethodSignature:
case SyntaxKind.CallSignature:
case SyntaxKind.ConstructSignature:
case SyntaxKind.Parameter:
case SyntaxKind.FunctionType:
case SyntaxKind.ConstructorType:
case SyntaxKind.UnionType:
case SyntaxKind.ParenthesizedType:
case SyntaxKind.TaggedTemplateExpression:
case SyntaxKind.AwaitExpression:
return true;
}
return false;
@@ -450,8 +461,6 @@ namespace ts.formatting {
case SyntaxKind.FunctionDeclaration:
case SyntaxKind.FunctionExpression:
case SyntaxKind.MethodDeclaration:
case SyntaxKind.MethodSignature:
case SyntaxKind.CallSignature:
case SyntaxKind.ArrowFunction:
case SyntaxKind.Constructor:
case SyntaxKind.GetAccessor:
+142 -23
View File
@@ -132,6 +132,46 @@ namespace ts {
let scanner: Scanner = createScanner(ScriptTarget.Latest, /*skipTrivia*/ true);
let emptyArray: any[] = [];
const jsDocTagNames = [
"augments",
"author",
"argument",
"borrows",
"class",
"constant",
"constructor",
"constructs",
"default",
"deprecated",
"description",
"event",
"example",
"extends",
"field",
"fileOverview",
"function",
"ignore",
"inner",
"lends",
"link",
"memberOf",
"name",
"namespace",
"param",
"private",
"property",
"public",
"requires",
"returns",
"see",
"since",
"static",
"throws",
"type",
"version"
];
let jsDocCompletionEntries: CompletionEntry[];
function createNode(kind: SyntaxKind, pos: number, end: number, flags: NodeFlags, parent?: Node): NodeObject {
let node = <NodeObject> new (getNodeConstructor(kind))();
@@ -1842,9 +1882,8 @@ namespace ts {
getCanonicalFileName: fileName => fileName,
getCurrentDirectory: () => "",
getNewLine: () => newLine,
// these two methods should never be called in transpile scenarios since 'noResolve' is set to 'true'
fileExists: (fileName): boolean => { throw new Error("Should never be called."); },
readFile: (fileName): string => { throw new Error("Should never be called."); }
fileExists: (fileName): boolean => fileName === inputFileName,
readFile: (fileName): string => ""
};
let program = createProgram([inputFileName], options, compilerHost);
@@ -2972,6 +3011,8 @@ namespace ts {
let sourceFile = getValidSourceFile(fileName);
let isJavaScriptFile = isJavaScript(fileName);
let isJsDocTagName = false;
let start = new Date().getTime();
let currentToken = getTokenAtPosition(sourceFile, position);
log("getCompletionData: Get current token: " + (new Date().getTime() - start));
@@ -2982,8 +3023,44 @@ namespace ts {
log("getCompletionData: Is inside comment: " + (new Date().getTime() - start));
if (insideComment) {
log("Returning an empty list because completion was inside a comment.");
return undefined;
// The current position is next to the '@' sign, when no tag name being provided yet.
// Provide a full list of tag names
if (hasDocComment(sourceFile, position) && sourceFile.text.charCodeAt(position - 1) === CharacterCodes.at) {
isJsDocTagName = true;
}
// Completion should work inside certain JsDoc tags. For example:
// /** @type {number | string} */
// Completion should work in the brackets
let insideJsDocTagExpression = false;
let tag = getJsDocTagAtPosition(sourceFile, position);
if (tag) {
if (tag.tagName.pos <= position && position <= tag.tagName.end) {
isJsDocTagName = true;
}
switch (tag.kind) {
case SyntaxKind.JSDocTypeTag:
case SyntaxKind.JSDocParameterTag:
case SyntaxKind.JSDocReturnTag:
let tagWithExpression = <JSDocTypeTag | JSDocParameterTag | JSDocReturnTag>tag;
if (tagWithExpression.typeExpression) {
insideJsDocTagExpression = tagWithExpression.typeExpression.pos < position && position < tagWithExpression.typeExpression.end;
}
break;
}
}
if (isJsDocTagName) {
return { symbols: undefined, isMemberCompletion: false, isNewIdentifierLocation: false, location: undefined, isRightOfDot: false, isJsDocTagName };
}
if (!insideJsDocTagExpression) {
// Proceed if the current position is in jsDoc tag expression; otherwise it is a normal
// comment or the plain text part of a jsDoc comment, so no completion should be available
log("Returning an empty list because completion was inside a regular comment or plain text part of a JsDoc comment.");
return undefined;
}
}
start = new Date().getTime();
@@ -3069,7 +3146,7 @@ namespace ts {
log("getCompletionData: Semantic work: " + (new Date().getTime() - semanticStart));
return { symbols, isMemberCompletion, isNewIdentifierLocation, location, isRightOfDot: (isRightOfDot || isRightOfOpenTag) };
return { symbols, isMemberCompletion, isNewIdentifierLocation, location, isRightOfDot: (isRightOfDot || isRightOfOpenTag), isJsDocTagName };
function getTypeScriptMemberSymbols(): void {
// Right of dot member completion list
@@ -3512,10 +3589,11 @@ namespace ts {
containingNodeKind === SyntaxKind.EnumDeclaration || // enum a { foo, |
isFunction(containingNodeKind) ||
containingNodeKind === SyntaxKind.ClassDeclaration || // class A<T, |
containingNodeKind === SyntaxKind.FunctionDeclaration || // function A<T, |
containingNodeKind === SyntaxKind.ClassExpression || // var C = class D<T, |
containingNodeKind === SyntaxKind.InterfaceDeclaration || // interface A<T, |
containingNodeKind === SyntaxKind.ArrayBindingPattern; // var [x, y|
containingNodeKind === SyntaxKind.ArrayBindingPattern || // var [x, y|
containingNodeKind === SyntaxKind.TypeAliasDeclaration; // type Map, K, |
case SyntaxKind.DotToken:
return containingNodeKind === SyntaxKind.ArrayBindingPattern; // var [.|
@@ -3542,8 +3620,9 @@ namespace ts {
case SyntaxKind.LessThanToken:
return containingNodeKind === SyntaxKind.ClassDeclaration || // class A< |
containingNodeKind === SyntaxKind.FunctionDeclaration || // function A< |
containingNodeKind === SyntaxKind.ClassExpression || // var C = class D< |
containingNodeKind === SyntaxKind.InterfaceDeclaration || // interface A< |
containingNodeKind === SyntaxKind.TypeAliasDeclaration || // type List< |
isFunction(containingNodeKind);
case SyntaxKind.StaticKeyword:
@@ -3709,9 +3788,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());
@@ -3725,7 +3809,7 @@ namespace ts {
}
// Add keywords if this is not a member completion list
if (!isMemberCompletion) {
if (!isMemberCompletion && !isJsDocTagName) {
addRange(entries, keywordCompletions);
}
@@ -3758,6 +3842,17 @@ 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.
// We would like to only show things that can be added after a dot, so for instance numeric properties can
@@ -4088,6 +4183,7 @@ namespace ts {
displayParts.push(keywordPart(SyntaxKind.TypeKeyword));
displayParts.push(spacePart());
addFullSymbolName(symbol);
writeTypeParametersOfSymbol(symbol, sourceFile);
displayParts.push(spacePart());
displayParts.push(operatorPart(SyntaxKind.EqualsToken));
displayParts.push(spacePart());
@@ -4128,16 +4224,29 @@ namespace ts {
}
else {
// Method/function type parameter
let signatureDeclaration = <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 = <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> = T[]; // Both T will go through same code path
let declaration = <TypeAliasDeclaration>getDeclarationOfKind(symbol, SyntaxKind.TypeParameter).parent;
displayParts.push(keywordPart(SyntaxKind.TypeKeyword));
displayParts.push(spacePart());
addFullSymbolName(declaration.symbol);
writeTypeParametersOfSymbol(declaration.symbol, sourceFile);
}
else if (signatureDeclaration.kind !== SyntaxKind.CallSignature && signatureDeclaration.name) {
addFullSymbolName(signatureDeclaration.symbol);
}
addRange(displayParts, signatureToDisplayParts(typeChecker, signature, sourceFile, TypeFormatFlags.WriteTypeArgumentsOfSignature));
}
}
if (symbolFlags & SymbolFlags.EnumMember) {
@@ -4371,10 +4480,19 @@ namespace ts {
// and in either case the symbol has a construct signature definition, i.e. class
if (isNewExpressionTarget(location) || location.kind === SyntaxKind.ConstructorKeyword) {
if (symbol.flags & SymbolFlags.Class) {
let classDeclaration = <ClassDeclaration>symbol.getDeclarations()[0];
Debug.assert(classDeclaration && classDeclaration.kind === SyntaxKind.ClassDeclaration);
// Find the first class-like declaration and try to get the construct signature.
for (let declaration of symbol.getDeclarations()) {
if (isClassLike(declaration)) {
return tryAddSignature(declaration.members,
/*selectConstructors*/ true,
symbolKind,
symbolName,
containerName,
result);
}
}
return tryAddSignature(classDeclaration.members, /*selectConstructors*/ true, symbolKind, symbolName, containerName, result);
Debug.fail("Expected declaration to have at least one class-like declaration");
}
}
return false;
@@ -5767,6 +5885,7 @@ namespace ts {
result.push(getReferenceEntryFromNode(node));
}
break;
case SyntaxKind.ClassExpression:
case SyntaxKind.ClassDeclaration:
// Make sure the container belongs to the same class
// and has the appropriate static modifier from the original container.
+1 -1
View File
@@ -1097,4 +1097,4 @@ module TypeScript.Services {
}
/* @internal */
let toolsVersion = "1.5";
const toolsVersion = "1.6";
+33 -1
View File
@@ -469,6 +469,39 @@ namespace ts {
}
}
/**
* Get the corresponding JSDocTag node if the position is in a jsDoc comment
*/
export function getJsDocTagAtPosition(sourceFile: SourceFile, position: number): JSDocTag {
let node = ts.getTokenAtPosition(sourceFile, position);
if (isToken(node)) {
switch (node.kind) {
case SyntaxKind.VarKeyword:
case SyntaxKind.LetKeyword:
case SyntaxKind.ConstKeyword:
// if the current token is var, let or const, skip the VariableDeclarationList
node = node.parent === undefined ? undefined : node.parent.parent;
break;
default:
node = node.parent;
break;
}
}
if (node) {
let jsDocComment = node.jsDocComment;
if (jsDocComment) {
for (let tag of jsDocComment.tags) {
if (tag.pos <= position && position <= tag.end) {
return tag;
}
}
}
}
return undefined;
}
function nodeHasTokens(n: Node): boolean {
// If we have a token or node that has a non-zero width, it must have tokens.
// Note, that getWidth() does not take trivia into account.
@@ -640,7 +673,6 @@ namespace ts {
else if (flags & SymbolFlags.TypeAlias) { return SymbolDisplayPartKind.aliasName; }
else if (flags & SymbolFlags.Alias) { return SymbolDisplayPartKind.aliasName; }
return SymbolDisplayPartKind.text;
}
}
@@ -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))
@@ -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
@@ -1,4 +1,4 @@
tests/cases/compiler/arrayCast.ts(3,1): error TS2352: Neither type '{ foo: string; }[]' nor type '{ id: number; }[]' is assignable to the other.
tests/cases/compiler/arrayCast.ts(3,23): error TS2352: Neither type '{ foo: string; }[]' nor type '{ id: number; }[]' is assignable to the other.
Type '{ foo: string; }' is not assignable to type '{ id: number; }'.
Object literal may only specify known properties, and 'foo' does not exist in type '{ id: number; }'.
@@ -7,7 +7,7 @@ tests/cases/compiler/arrayCast.ts(3,1): error TS2352: Neither type '{ foo: strin
// Should fail. Even though the array is contextually typed with { id: number }[], it still
// has type { foo: string }[], which is not assignable to { id: number }[].
<{ id: number; }[]>[{ foo: "s" }];
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~
!!! error TS2352: Neither type '{ foo: string; }[]' nor type '{ id: number; }[]' is assignable to the other.
!!! error TS2352: Type '{ foo: string; }' is not assignable to type '{ id: number; }'.
!!! error TS2352: Object literal may only specify known properties, and 'foo' does not exist in type '{ id: number; }'.
@@ -1,8 +1,8 @@
tests/cases/compiler/arrayLiteralTypeInference.ts(13,5): error TS2322: Type '({ id: number; trueness: boolean; } | { id: number; name: string; })[]' is not assignable to type 'Action[]'.
tests/cases/compiler/arrayLiteralTypeInference.ts(14,14): error TS2322: Type '({ id: number; trueness: boolean; } | { id: number; name: string; })[]' is not assignable to type 'Action[]'.
Type '{ id: number; trueness: boolean; } | { id: number; name: string; }' is not assignable to type 'Action'.
Type '{ id: number; trueness: boolean; }' is not assignable to type 'Action'.
Object literal may only specify known properties, and 'trueness' does not exist in type 'Action'.
tests/cases/compiler/arrayLiteralTypeInference.ts(29,5): error TS2322: Type '({ id: number; trueness: boolean; } | { id: number; name: string; })[]' is not assignable to type '{ id: number; }[]'.
tests/cases/compiler/arrayLiteralTypeInference.ts(31,18): error TS2322: Type '({ id: number; trueness: boolean; } | { id: number; name: string; })[]' is not assignable to type '{ id: number; }[]'.
Type '{ id: number; trueness: boolean; } | { id: number; name: string; }' is not assignable to type '{ id: number; }'.
Type '{ id: number; trueness: boolean; }' is not assignable to type '{ id: number; }'.
Object literal may only specify known properties, and 'trueness' does not exist in type '{ id: number; }'.
@@ -22,12 +22,12 @@ tests/cases/compiler/arrayLiteralTypeInference.ts(29,5): error TS2322: Type '({
}
var x1: Action[] = [
~~
{ id: 2, trueness: false },
~~~~~~~~~~~~~~~
!!! error TS2322: Type '({ id: number; trueness: boolean; } | { id: number; name: string; })[]' is not assignable to type 'Action[]'.
!!! error TS2322: Type '{ id: number; trueness: boolean; } | { id: number; name: string; }' is not assignable to type 'Action'.
!!! error TS2322: Type '{ id: number; trueness: boolean; }' is not assignable to type 'Action'.
!!! error TS2322: Object literal may only specify known properties, and 'trueness' does not exist in type 'Action'.
{ id: 2, trueness: false },
{ id: 3, name: "three" }
]
@@ -43,13 +43,13 @@ tests/cases/compiler/arrayLiteralTypeInference.ts(29,5): error TS2322: Type '({
]
var z1: { id: number }[] =
~~
[
{ id: 2, trueness: false },
~~~~~~~~~~~~~~~
!!! error TS2322: Type '({ id: number; trueness: boolean; } | { id: number; name: string; })[]' is not assignable to type '{ id: number; }[]'.
!!! error TS2322: Type '{ id: number; trueness: boolean; } | { id: number; name: string; }' is not assignable to type '{ id: number; }'.
!!! error TS2322: Type '{ id: number; trueness: boolean; }' is not assignable to type '{ id: number; }'.
!!! error TS2322: Object literal may only specify known properties, and 'trueness' does not exist in type '{ id: number; }'.
[
{ id: 2, trueness: false },
{ id: 3, name: "three" }
]
@@ -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
@@ -1,4 +1,4 @@
tests/cases/conformance/expressions/arrayLiterals/arrayLiterals.ts(24,5): error TS2322: Type '({ a: string; b: number; c: string; } | { a: string; b: number; c: number; })[]' is not assignable to type '{ [n: number]: { a: string; b: number; }; }'.
tests/cases/conformance/expressions/arrayLiterals/arrayLiterals.ts(24,77): error TS2322: Type '({ a: string; b: number; c: string; } | { a: string; b: number; c: number; })[]' is not assignable to type '{ [n: number]: { a: string; b: number; }; }'.
Index signatures are incompatible.
Type '{ a: string; b: number; c: string; } | { a: string; b: number; c: number; }' is not assignable to type '{ a: string; b: number; }'.
Type '{ a: string; b: number; c: string; }' is not assignable to type '{ a: string; b: number; }'.
@@ -30,7 +30,7 @@ tests/cases/conformance/expressions/arrayLiterals/arrayLiterals.ts(24,5): error
// Contextual type C with numeric index signature makes array literal of EveryType E of type BCT(E,C)[]
var context1: { [n: number]: { a: string; b: number; }; } = [{ a: '', b: 0, c: '' }, { a: "", b: 3, c: 0 }];
~~~~~~~~
~~~~~
!!! error TS2322: Type '({ a: string; b: number; c: string; } | { a: string; b: number; c: number; })[]' is not assignable to type '{ [n: number]: { a: string; b: number; }; }'.
!!! error TS2322: Index signatures are incompatible.
!!! error TS2322: Type '{ a: string; b: number; c: string; } | { a: string; b: number; c: number; }' is not assignable to type '{ a: string; b: number; }'.
@@ -72,14 +72,14 @@ var temp2: [number[], string[]] = [[1, 2, 3], ["hello", "string"]];
interface myArray extends Array<Number> { }
>myArray : Symbol(myArray, Decl(arrayLiterals2ES6.ts, 40, 67))
>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1455, 1))
>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 4091, 1))
>Number : Symbol(Number, Decl(lib.d.ts, 456, 40), Decl(lib.d.ts, 518, 11))
interface myArray2 extends Array<Number|String> { }
>myArray2 : Symbol(myArray2, Decl(arrayLiterals2ES6.ts, 42, 43))
>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 1455, 1))
>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11), Decl(lib.d.ts, 4091, 1))
>Number : Symbol(Number, Decl(lib.d.ts, 456, 40), Decl(lib.d.ts, 518, 11))
>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 1573, 1))
>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11), Decl(lib.d.ts, 4209, 1))
var d0 = [1, true, ...temp, ]; // has type (string|number|boolean)[]
>d0 : Symbol(d0, Decl(arrayLiterals2ES6.ts, 44, 3))
@@ -77,8 +77,8 @@ var myDerivedList: DerivedList<number>;
>DerivedList : DerivedList<U>
var as = [list, myDerivedList]; // List<number>[]
>as : (List<number> | DerivedList<number>)[]
>[list, myDerivedList] : (List<number> | DerivedList<number>)[]
>as : List<number>[]
>[list, myDerivedList] : List<number>[]
>list : List<number>
>myDerivedList : DerivedList<number>
@@ -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: { <T>(x: T): number; (x: string): string;};
var b2: { <T>(x: T): number; (x: string): string; };
var c2: { (x: number): number; <T>(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.
@@ -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: { <T>(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: { <T>(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; <T>(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))
@@ -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: { <T>(x: T): number; (x: string): string;};
>a2 : { <T>(x: T): number; (x: string): string; }
>T : T
>x : T
>T : T
>x : string
var b2: { <T>(x: T): number; (x: string): string; };
>b2 : { <T>(x: T): number; (x: string): string; }
>T : T
>x : T
>T : T
>x : string
var c2: { (x: number): number; <T>(x: T): any; };
>c2 : { (x: number): number; <T>(x: T): any; }
>x : number
>T : T
>x : T
>T : T
var z2 = [a2, b2, c2];
>z2 : { (x: number): number; <T>(x: T): any; }[]
>[a2, b2, c2] : { (x: number): number; <T>(x: T): any; }[]
>a2 : { <T>(x: T): number; (x: string): string; }
>b2 : { <T>(x: T): number; (x: string): string; }
>c2 : { (x: number): number; <T>(x: T): any; }
var r6 = z2[0];
>r6 : { (x: number): number; <T>(x: T): any; }
>z2[0] : { (x: number): number; <T>(x: T): any; }
>z2 : { (x: number): number; <T>(x: T): any; }[]
>0 : number
var r7 = r6(''); // any not string
>r7 : any
>r6('') : any
>r6 : { (x: number): number; <T>(x: T): any; }
>'' : string
@@ -1,8 +1,8 @@
tests/cases/compiler/assignmentCompatBug2.ts(1,5): error TS2322: Type '{ a: number; }' is not assignable to type '{ b: number; }'.
tests/cases/compiler/assignmentCompatBug2.ts(1,27): error TS2322: Type '{ a: number; }' is not assignable to type '{ b: number; }'.
Object literal may only specify known properties, and 'a' does not exist in type '{ b: number; }'.
tests/cases/compiler/assignmentCompatBug2.ts(3,1): error TS2322: Type '{ a: number; }' is not assignable to type '{ b: number; }'.
tests/cases/compiler/assignmentCompatBug2.ts(3,8): error TS2322: Type '{ a: number; }' is not assignable to type '{ b: number; }'.
Object literal may only specify known properties, and 'a' does not exist in type '{ b: number; }'.
tests/cases/compiler/assignmentCompatBug2.ts(5,1): error TS2322: Type '{ b: number; a: number; }' is not assignable to type '{ b: number; }'.
tests/cases/compiler/assignmentCompatBug2.ts(5,13): error TS2322: Type '{ b: number; a: number; }' is not assignable to type '{ b: number; }'.
Object literal may only specify known properties, and 'a' does not exist in type '{ b: number; }'.
tests/cases/compiler/assignmentCompatBug2.ts(15,1): error TS2322: Type '{ f: (n: number) => number; g: (s: string) => number; }' is not assignable to type '{ f(n: number): number; g(s: string): number; m: number; n?: number; k?(a: any): any; }'.
Property 'm' is missing in type '{ f: (n: number) => number; g: (s: string) => number; }'.
@@ -14,17 +14,17 @@ tests/cases/compiler/assignmentCompatBug2.ts(33,1): error TS2322: Type '{ f: (n:
==== tests/cases/compiler/assignmentCompatBug2.ts (6 errors) ====
var b2: { b: number;} = { a: 0 }; // error
~~
~~~~
!!! error TS2322: Type '{ a: number; }' is not assignable to type '{ b: number; }'.
!!! error TS2322: Object literal may only specify known properties, and 'a' does not exist in type '{ b: number; }'.
b2 = { a: 0 }; // error
~~
~~~~
!!! error TS2322: Type '{ a: number; }' is not assignable to type '{ b: number; }'.
!!! error TS2322: Object literal may only specify known properties, and 'a' does not exist in type '{ b: number; }'.
b2 = {b: 0, a: 0 };
~~
~~~~
!!! error TS2322: Type '{ b: number; a: number; }' is not assignable to type '{ b: number; }'.
!!! error TS2322: Object literal may only specify known properties, and 'a' does not exist in type '{ b: number; }'.
@@ -1,4 +1,4 @@
tests/cases/compiler/assignmentCompatBug5.ts(2,6): error TS2345: Argument of type '{ b: number; }' is not assignable to parameter of type '{ a: number; }'.
tests/cases/compiler/assignmentCompatBug5.ts(2,8): error TS2345: Argument of type '{ b: number; }' is not assignable to parameter of type '{ a: number; }'.
Object literal may only specify known properties, and 'b' does not exist in type '{ a: number; }'.
tests/cases/compiler/assignmentCompatBug5.ts(5,6): error TS2345: Argument of type 'string[]' is not assignable to parameter of type 'number[]'.
Type 'string' is not assignable to type 'number'.
@@ -12,7 +12,7 @@ tests/cases/compiler/assignmentCompatBug5.ts(9,6): error TS2345: Argument of typ
==== tests/cases/compiler/assignmentCompatBug5.ts (4 errors) ====
function foo1(x: { a: number; }) { }
foo1({ b: 5 });
~~~~~~~~
~~~~
!!! error TS2345: Argument of type '{ b: number; }' is not assignable to parameter of type '{ a: number; }'.
!!! error TS2345: Object literal may only specify known properties, and 'b' does not exist in type '{ a: number; }'.
@@ -2,6 +2,6 @@
var foo = async (): Promise<void> => {
>foo : Symbol(foo, Decl(asyncArrowFunction1_es6.ts, 1, 3))
>Promise : Symbol(Promise, Decl(lib.d.ts, 4832, 1), Decl(lib.d.ts, 4918, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11))
};
@@ -2,16 +2,16 @@
type MyPromise<T> = Promise<T>;
>MyPromise : Symbol(MyPromise, Decl(asyncAwait_es6.ts, 0, 0), Decl(asyncAwait_es6.ts, 1, 11))
>T : Symbol(T, Decl(asyncAwait_es6.ts, 0, 15))
>Promise : Symbol(Promise, Decl(lib.d.ts, 4832, 1), Decl(lib.d.ts, 4918, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11))
>T : Symbol(T, Decl(asyncAwait_es6.ts, 0, 15))
declare var MyPromise: typeof Promise;
>MyPromise : Symbol(MyPromise, Decl(asyncAwait_es6.ts, 0, 0), Decl(asyncAwait_es6.ts, 1, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, 4832, 1), Decl(lib.d.ts, 4918, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11))
declare var p: Promise<number>;
>p : Symbol(p, Decl(asyncAwait_es6.ts, 2, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, 4832, 1), Decl(lib.d.ts, 4918, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11))
declare var mp: MyPromise<number>;
>mp : Symbol(mp, Decl(asyncAwait_es6.ts, 3, 11))
@@ -22,7 +22,7 @@ async function f0() { }
async function f1(): Promise<void> { }
>f1 : Symbol(f1, Decl(asyncAwait_es6.ts, 5, 23))
>Promise : Symbol(Promise, Decl(lib.d.ts, 4832, 1), Decl(lib.d.ts, 4918, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11))
async function f3(): MyPromise<void> { }
>f3 : Symbol(f3, Decl(asyncAwait_es6.ts, 6, 38))
@@ -33,7 +33,7 @@ let f4 = async function() { }
let f5 = async function(): Promise<void> { }
>f5 : Symbol(f5, Decl(asyncAwait_es6.ts, 10, 3))
>Promise : Symbol(Promise, Decl(lib.d.ts, 4832, 1), Decl(lib.d.ts, 4918, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11))
let f6 = async function(): MyPromise<void> { }
>f6 : Symbol(f6, Decl(asyncAwait_es6.ts, 11, 3))
@@ -44,7 +44,7 @@ let f7 = async () => { };
let f8 = async (): Promise<void> => { };
>f8 : Symbol(f8, Decl(asyncAwait_es6.ts, 14, 3))
>Promise : Symbol(Promise, Decl(lib.d.ts, 4832, 1), Decl(lib.d.ts, 4918, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11))
let f9 = async (): MyPromise<void> => { };
>f9 : Symbol(f9, Decl(asyncAwait_es6.ts, 15, 3))
@@ -60,7 +60,7 @@ let f11 = async () => mp;
let f12 = async (): Promise<number> => mp;
>f12 : Symbol(f12, Decl(asyncAwait_es6.ts, 18, 3))
>Promise : Symbol(Promise, Decl(lib.d.ts, 4832, 1), Decl(lib.d.ts, 4918, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11))
>mp : Symbol(mp, Decl(asyncAwait_es6.ts, 3, 11))
let f13 = async (): MyPromise<number> => p;
@@ -76,7 +76,7 @@ let o = {
async m2(): Promise<void> { },
>m2 : Symbol(m2, Decl(asyncAwait_es6.ts, 22, 16))
>Promise : Symbol(Promise, Decl(lib.d.ts, 4832, 1), Decl(lib.d.ts, 4918, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11))
async m3(): MyPromise<void> { }
>m3 : Symbol(m3, Decl(asyncAwait_es6.ts, 23, 31))
@@ -92,7 +92,7 @@ class C {
async m2(): Promise<void> { }
>m2 : Symbol(m2, Decl(asyncAwait_es6.ts, 28, 15))
>Promise : Symbol(Promise, Decl(lib.d.ts, 4832, 1), Decl(lib.d.ts, 4918, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11))
async m3(): MyPromise<void> { }
>m3 : Symbol(m3, Decl(asyncAwait_es6.ts, 29, 30))
@@ -103,7 +103,7 @@ class C {
static async m5(): Promise<void> { }
>m5 : Symbol(C.m5, Decl(asyncAwait_es6.ts, 31, 22))
>Promise : Symbol(Promise, Decl(lib.d.ts, 4832, 1), Decl(lib.d.ts, 4918, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11))
static async m6(): MyPromise<void> { }
>m6 : Symbol(C.m6, Decl(asyncAwait_es6.ts, 32, 37))
@@ -1,5 +1,5 @@
=== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration11_es6.ts ===
async function await(): Promise<void> {
>await : Symbol(await, Decl(asyncFunctionDeclaration11_es6.ts, 0, 0))
>Promise : Symbol(Promise, Decl(lib.d.ts, 4832, 1), Decl(lib.d.ts, 4918, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11))
}
@@ -1,7 +1,7 @@
=== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration14_es6.ts ===
async function foo(): Promise<void> {
>foo : Symbol(foo, Decl(asyncFunctionDeclaration14_es6.ts, 0, 0))
>Promise : Symbol(Promise, Decl(lib.d.ts, 4832, 1), Decl(lib.d.ts, 4918, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11))
return;
}
@@ -1,5 +1,5 @@
=== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration1_es6.ts ===
async function foo(): Promise<void> {
>foo : Symbol(foo, Decl(asyncFunctionDeclaration1_es6.ts, 0, 0))
>Promise : Symbol(Promise, Decl(lib.d.ts, 4832, 1), Decl(lib.d.ts, 4918, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11))
}
@@ -4,11 +4,11 @@ declare var a: boolean;
declare var p: Promise<boolean>;
>p : Symbol(p, Decl(awaitBinaryExpression1_es6.ts, 1, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, 4832, 1), Decl(lib.d.ts, 4918, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11))
async function func(): Promise<void> {
>func : Symbol(func, Decl(awaitBinaryExpression1_es6.ts, 1, 32))
>Promise : Symbol(Promise, Decl(lib.d.ts, 4832, 1), Decl(lib.d.ts, 4918, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11))
"before";
var b = await p || a;
@@ -4,11 +4,11 @@ declare var a: boolean;
declare var p: Promise<boolean>;
>p : Symbol(p, Decl(awaitBinaryExpression2_es6.ts, 1, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, 4832, 1), Decl(lib.d.ts, 4918, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11))
async function func(): Promise<void> {
>func : Symbol(func, Decl(awaitBinaryExpression2_es6.ts, 1, 32))
>Promise : Symbol(Promise, Decl(lib.d.ts, 4832, 1), Decl(lib.d.ts, 4918, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11))
"before";
var b = await p && a;
@@ -4,11 +4,11 @@ declare var a: number;
declare var p: Promise<number>;
>p : Symbol(p, Decl(awaitBinaryExpression3_es6.ts, 1, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, 4832, 1), Decl(lib.d.ts, 4918, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11))
async function func(): Promise<void> {
>func : Symbol(func, Decl(awaitBinaryExpression3_es6.ts, 1, 31))
>Promise : Symbol(Promise, Decl(lib.d.ts, 4832, 1), Decl(lib.d.ts, 4918, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11))
"before";
var b = await p + a;
@@ -4,11 +4,11 @@ declare var a: boolean;
declare var p: Promise<boolean>;
>p : Symbol(p, Decl(awaitBinaryExpression4_es6.ts, 1, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, 4832, 1), Decl(lib.d.ts, 4918, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11))
async function func(): Promise<void> {
>func : Symbol(func, Decl(awaitBinaryExpression4_es6.ts, 1, 32))
>Promise : Symbol(Promise, Decl(lib.d.ts, 4832, 1), Decl(lib.d.ts, 4918, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11))
"before";
var b = await p, a;
@@ -4,11 +4,11 @@ declare var a: boolean;
declare var p: Promise<boolean>;
>p : Symbol(p, Decl(awaitBinaryExpression5_es6.ts, 1, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, 4832, 1), Decl(lib.d.ts, 4918, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11))
async function func(): Promise<void> {
>func : Symbol(func, Decl(awaitBinaryExpression5_es6.ts, 1, 32))
>Promise : Symbol(Promise, Decl(lib.d.ts, 4832, 1), Decl(lib.d.ts, 4918, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11))
"before";
var o: { a: boolean; };
@@ -4,7 +4,7 @@ declare var a: boolean;
declare var p: Promise<boolean>;
>p : Symbol(p, Decl(awaitCallExpression1_es6.ts, 1, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, 4832, 1), Decl(lib.d.ts, 4918, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11))
declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void;
>fn : Symbol(fn, Decl(awaitCallExpression1_es6.ts, 1, 32))
@@ -21,14 +21,14 @@ declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; };
declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>;
>pfn : Symbol(pfn, Decl(awaitCallExpression1_es6.ts, 4, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, 4832, 1), Decl(lib.d.ts, 4918, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11))
>arg0 : Symbol(arg0, Decl(awaitCallExpression1_es6.ts, 4, 28))
>arg1 : Symbol(arg1, Decl(awaitCallExpression1_es6.ts, 4, 42))
>arg2 : Symbol(arg2, Decl(awaitCallExpression1_es6.ts, 4, 57))
declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>;
>po : Symbol(po, Decl(awaitCallExpression1_es6.ts, 5, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, 4832, 1), Decl(lib.d.ts, 4918, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11))
>fn : Symbol(fn, Decl(awaitCallExpression1_es6.ts, 5, 25))
>arg0 : Symbol(arg0, Decl(awaitCallExpression1_es6.ts, 5, 29))
>arg1 : Symbol(arg1, Decl(awaitCallExpression1_es6.ts, 5, 43))
@@ -36,7 +36,7 @@ declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void;
async function func(): Promise<void> {
>func : Symbol(func, Decl(awaitCallExpression1_es6.ts, 5, 84))
>Promise : Symbol(Promise, Decl(lib.d.ts, 4832, 1), Decl(lib.d.ts, 4918, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11))
"before";
var b = fn(a, a, a);
@@ -4,7 +4,7 @@ declare var a: boolean;
declare var p: Promise<boolean>;
>p : Symbol(p, Decl(awaitCallExpression2_es6.ts, 1, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, 4832, 1), Decl(lib.d.ts, 4918, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11))
declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void;
>fn : Symbol(fn, Decl(awaitCallExpression2_es6.ts, 1, 32))
@@ -21,14 +21,14 @@ declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; };
declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>;
>pfn : Symbol(pfn, Decl(awaitCallExpression2_es6.ts, 4, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, 4832, 1), Decl(lib.d.ts, 4918, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11))
>arg0 : Symbol(arg0, Decl(awaitCallExpression2_es6.ts, 4, 28))
>arg1 : Symbol(arg1, Decl(awaitCallExpression2_es6.ts, 4, 42))
>arg2 : Symbol(arg2, Decl(awaitCallExpression2_es6.ts, 4, 57))
declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>;
>po : Symbol(po, Decl(awaitCallExpression2_es6.ts, 5, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, 4832, 1), Decl(lib.d.ts, 4918, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11))
>fn : Symbol(fn, Decl(awaitCallExpression2_es6.ts, 5, 25))
>arg0 : Symbol(arg0, Decl(awaitCallExpression2_es6.ts, 5, 29))
>arg1 : Symbol(arg1, Decl(awaitCallExpression2_es6.ts, 5, 43))
@@ -36,7 +36,7 @@ declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void;
async function func(): Promise<void> {
>func : Symbol(func, Decl(awaitCallExpression2_es6.ts, 5, 84))
>Promise : Symbol(Promise, Decl(lib.d.ts, 4832, 1), Decl(lib.d.ts, 4918, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11))
"before";
var b = fn(await p, a, a);
@@ -4,7 +4,7 @@ declare var a: boolean;
declare var p: Promise<boolean>;
>p : Symbol(p, Decl(awaitCallExpression3_es6.ts, 1, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, 4832, 1), Decl(lib.d.ts, 4918, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11))
declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void;
>fn : Symbol(fn, Decl(awaitCallExpression3_es6.ts, 1, 32))
@@ -21,14 +21,14 @@ declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; };
declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>;
>pfn : Symbol(pfn, Decl(awaitCallExpression3_es6.ts, 4, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, 4832, 1), Decl(lib.d.ts, 4918, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11))
>arg0 : Symbol(arg0, Decl(awaitCallExpression3_es6.ts, 4, 28))
>arg1 : Symbol(arg1, Decl(awaitCallExpression3_es6.ts, 4, 42))
>arg2 : Symbol(arg2, Decl(awaitCallExpression3_es6.ts, 4, 57))
declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>;
>po : Symbol(po, Decl(awaitCallExpression3_es6.ts, 5, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, 4832, 1), Decl(lib.d.ts, 4918, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11))
>fn : Symbol(fn, Decl(awaitCallExpression3_es6.ts, 5, 25))
>arg0 : Symbol(arg0, Decl(awaitCallExpression3_es6.ts, 5, 29))
>arg1 : Symbol(arg1, Decl(awaitCallExpression3_es6.ts, 5, 43))
@@ -36,7 +36,7 @@ declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void;
async function func(): Promise<void> {
>func : Symbol(func, Decl(awaitCallExpression3_es6.ts, 5, 84))
>Promise : Symbol(Promise, Decl(lib.d.ts, 4832, 1), Decl(lib.d.ts, 4918, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11))
"before";
var b = fn(a, await p, a);
@@ -4,7 +4,7 @@ declare var a: boolean;
declare var p: Promise<boolean>;
>p : Symbol(p, Decl(awaitCallExpression4_es6.ts, 1, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, 4832, 1), Decl(lib.d.ts, 4918, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11))
declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void;
>fn : Symbol(fn, Decl(awaitCallExpression4_es6.ts, 1, 32))
@@ -21,14 +21,14 @@ declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; };
declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>;
>pfn : Symbol(pfn, Decl(awaitCallExpression4_es6.ts, 4, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, 4832, 1), Decl(lib.d.ts, 4918, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11))
>arg0 : Symbol(arg0, Decl(awaitCallExpression4_es6.ts, 4, 28))
>arg1 : Symbol(arg1, Decl(awaitCallExpression4_es6.ts, 4, 42))
>arg2 : Symbol(arg2, Decl(awaitCallExpression4_es6.ts, 4, 57))
declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>;
>po : Symbol(po, Decl(awaitCallExpression4_es6.ts, 5, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, 4832, 1), Decl(lib.d.ts, 4918, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11))
>fn : Symbol(fn, Decl(awaitCallExpression4_es6.ts, 5, 25))
>arg0 : Symbol(arg0, Decl(awaitCallExpression4_es6.ts, 5, 29))
>arg1 : Symbol(arg1, Decl(awaitCallExpression4_es6.ts, 5, 43))
@@ -36,7 +36,7 @@ declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void;
async function func(): Promise<void> {
>func : Symbol(func, Decl(awaitCallExpression4_es6.ts, 5, 84))
>Promise : Symbol(Promise, Decl(lib.d.ts, 4832, 1), Decl(lib.d.ts, 4918, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11))
"before";
var b = (await pfn)(a, a, a);
@@ -4,7 +4,7 @@ declare var a: boolean;
declare var p: Promise<boolean>;
>p : Symbol(p, Decl(awaitCallExpression5_es6.ts, 1, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, 4832, 1), Decl(lib.d.ts, 4918, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11))
declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void;
>fn : Symbol(fn, Decl(awaitCallExpression5_es6.ts, 1, 32))
@@ -21,14 +21,14 @@ declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; };
declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>;
>pfn : Symbol(pfn, Decl(awaitCallExpression5_es6.ts, 4, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, 4832, 1), Decl(lib.d.ts, 4918, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11))
>arg0 : Symbol(arg0, Decl(awaitCallExpression5_es6.ts, 4, 28))
>arg1 : Symbol(arg1, Decl(awaitCallExpression5_es6.ts, 4, 42))
>arg2 : Symbol(arg2, Decl(awaitCallExpression5_es6.ts, 4, 57))
declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>;
>po : Symbol(po, Decl(awaitCallExpression5_es6.ts, 5, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, 4832, 1), Decl(lib.d.ts, 4918, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11))
>fn : Symbol(fn, Decl(awaitCallExpression5_es6.ts, 5, 25))
>arg0 : Symbol(arg0, Decl(awaitCallExpression5_es6.ts, 5, 29))
>arg1 : Symbol(arg1, Decl(awaitCallExpression5_es6.ts, 5, 43))
@@ -36,7 +36,7 @@ declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void;
async function func(): Promise<void> {
>func : Symbol(func, Decl(awaitCallExpression5_es6.ts, 5, 84))
>Promise : Symbol(Promise, Decl(lib.d.ts, 4832, 1), Decl(lib.d.ts, 4918, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11))
"before";
var b = o.fn(a, a, a);
@@ -4,7 +4,7 @@ declare var a: boolean;
declare var p: Promise<boolean>;
>p : Symbol(p, Decl(awaitCallExpression6_es6.ts, 1, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, 4832, 1), Decl(lib.d.ts, 4918, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11))
declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void;
>fn : Symbol(fn, Decl(awaitCallExpression6_es6.ts, 1, 32))
@@ -21,14 +21,14 @@ declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; };
declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>;
>pfn : Symbol(pfn, Decl(awaitCallExpression6_es6.ts, 4, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, 4832, 1), Decl(lib.d.ts, 4918, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11))
>arg0 : Symbol(arg0, Decl(awaitCallExpression6_es6.ts, 4, 28))
>arg1 : Symbol(arg1, Decl(awaitCallExpression6_es6.ts, 4, 42))
>arg2 : Symbol(arg2, Decl(awaitCallExpression6_es6.ts, 4, 57))
declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>;
>po : Symbol(po, Decl(awaitCallExpression6_es6.ts, 5, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, 4832, 1), Decl(lib.d.ts, 4918, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11))
>fn : Symbol(fn, Decl(awaitCallExpression6_es6.ts, 5, 25))
>arg0 : Symbol(arg0, Decl(awaitCallExpression6_es6.ts, 5, 29))
>arg1 : Symbol(arg1, Decl(awaitCallExpression6_es6.ts, 5, 43))
@@ -36,7 +36,7 @@ declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void;
async function func(): Promise<void> {
>func : Symbol(func, Decl(awaitCallExpression6_es6.ts, 5, 84))
>Promise : Symbol(Promise, Decl(lib.d.ts, 4832, 1), Decl(lib.d.ts, 4918, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11))
"before";
var b = o.fn(await p, a, a);
@@ -4,7 +4,7 @@ declare var a: boolean;
declare var p: Promise<boolean>;
>p : Symbol(p, Decl(awaitCallExpression7_es6.ts, 1, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, 4832, 1), Decl(lib.d.ts, 4918, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11))
declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void;
>fn : Symbol(fn, Decl(awaitCallExpression7_es6.ts, 1, 32))
@@ -21,14 +21,14 @@ declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; };
declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>;
>pfn : Symbol(pfn, Decl(awaitCallExpression7_es6.ts, 4, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, 4832, 1), Decl(lib.d.ts, 4918, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11))
>arg0 : Symbol(arg0, Decl(awaitCallExpression7_es6.ts, 4, 28))
>arg1 : Symbol(arg1, Decl(awaitCallExpression7_es6.ts, 4, 42))
>arg2 : Symbol(arg2, Decl(awaitCallExpression7_es6.ts, 4, 57))
declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>;
>po : Symbol(po, Decl(awaitCallExpression7_es6.ts, 5, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, 4832, 1), Decl(lib.d.ts, 4918, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11))
>fn : Symbol(fn, Decl(awaitCallExpression7_es6.ts, 5, 25))
>arg0 : Symbol(arg0, Decl(awaitCallExpression7_es6.ts, 5, 29))
>arg1 : Symbol(arg1, Decl(awaitCallExpression7_es6.ts, 5, 43))
@@ -36,7 +36,7 @@ declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void;
async function func(): Promise<void> {
>func : Symbol(func, Decl(awaitCallExpression7_es6.ts, 5, 84))
>Promise : Symbol(Promise, Decl(lib.d.ts, 4832, 1), Decl(lib.d.ts, 4918, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11))
"before";
var b = o.fn(a, await p, a);
@@ -4,7 +4,7 @@ declare var a: boolean;
declare var p: Promise<boolean>;
>p : Symbol(p, Decl(awaitCallExpression8_es6.ts, 1, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, 4832, 1), Decl(lib.d.ts, 4918, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11))
declare function fn(arg0: boolean, arg1: boolean, arg2: boolean): void;
>fn : Symbol(fn, Decl(awaitCallExpression8_es6.ts, 1, 32))
@@ -21,14 +21,14 @@ declare var o: { fn(arg0: boolean, arg1: boolean, arg2: boolean): void; };
declare var pfn: Promise<{ (arg0: boolean, arg1: boolean, arg2: boolean): void; }>;
>pfn : Symbol(pfn, Decl(awaitCallExpression8_es6.ts, 4, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, 4832, 1), Decl(lib.d.ts, 4918, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11))
>arg0 : Symbol(arg0, Decl(awaitCallExpression8_es6.ts, 4, 28))
>arg1 : Symbol(arg1, Decl(awaitCallExpression8_es6.ts, 4, 42))
>arg2 : Symbol(arg2, Decl(awaitCallExpression8_es6.ts, 4, 57))
declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void; }>;
>po : Symbol(po, Decl(awaitCallExpression8_es6.ts, 5, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, 4832, 1), Decl(lib.d.ts, 4918, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11))
>fn : Symbol(fn, Decl(awaitCallExpression8_es6.ts, 5, 25))
>arg0 : Symbol(arg0, Decl(awaitCallExpression8_es6.ts, 5, 29))
>arg1 : Symbol(arg1, Decl(awaitCallExpression8_es6.ts, 5, 43))
@@ -36,7 +36,7 @@ declare var po: Promise<{ fn(arg0: boolean, arg1: boolean, arg2: boolean): void;
async function func(): Promise<void> {
>func : Symbol(func, Decl(awaitCallExpression8_es6.ts, 5, 84))
>Promise : Symbol(Promise, Decl(lib.d.ts, 4832, 1), Decl(lib.d.ts, 4918, 11))
>Promise : Symbol(Promise, Decl(lib.d.ts, 5041, 1), Decl(lib.d.ts, 5127, 11))
"before";
var b = (await po).fn(a, a, a);
@@ -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
@@ -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
@@ -94,7 +94,7 @@ xa[1].foo(1, 2, ...a, "abc");
>a : Symbol(a, Decl(callWithSpreadES6.ts, 8, 3))
(<Function>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))
@@ -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]
@@ -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))
@@ -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
@@ -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
@@ -1,6 +1,6 @@
tests/cases/compiler/constEnumErrors.ts(1,12): error TS2300: Duplicate identifier 'E'.
tests/cases/compiler/constEnumErrors.ts(5,8): error TS2300: Duplicate identifier 'E'.
tests/cases/compiler/constEnumErrors.ts(12,9): error TS2651: A member initializer in a 'const' enum declaration cannot reference members declared after it, including members defined in other 'const' enums.
tests/cases/compiler/constEnumErrors.ts(12,9): error TS2651: A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums.
tests/cases/compiler/constEnumErrors.ts(14,9): error TS2474: In 'const' enum declarations member initializer must be constant expression.
tests/cases/compiler/constEnumErrors.ts(15,10): error TS2474: In 'const' enum declarations member initializer must be constant expression.
tests/cases/compiler/constEnumErrors.ts(22,13): error TS2476: A const enum member can only be accessed using a string literal.
@@ -31,7 +31,7 @@ tests/cases/compiler/constEnumErrors.ts(42,9): error TS2478: 'const' enum member
// forward reference to the element of the same enum
X = Y,
~
!!! error TS2651: A member initializer in a 'const' enum declaration cannot reference members declared after it, including members defined in other 'const' enums.
!!! error TS2651: A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums.
// forward reference to the element of the same enum
Y = E1.Z,
~~~~
@@ -1,4 +1,4 @@
tests/cases/compiler/contextualTyping12.ts(1,13): error TS2322: Type '({ id: number; } | { id: number; name: string; })[]' is not assignable to type '{ id: number; }[]'.
tests/cases/compiler/contextualTyping12.ts(1,57): error TS2322: Type '({ id: number; } | { id: number; name: string; })[]' is not assignable to type '{ id: number; }[]'.
Type '{ id: number; } | { id: number; name: string; }' is not assignable to type '{ id: number; }'.
Type '{ id: number; name: string; }' is not assignable to type '{ id: number; }'.
Object literal may only specify known properties, and 'name' does not exist in type '{ id: number; }'.
@@ -6,7 +6,7 @@ tests/cases/compiler/contextualTyping12.ts(1,13): error TS2322: Type '({ id: num
==== tests/cases/compiler/contextualTyping12.ts (1 errors) ====
class foo { public bar:{id:number;}[] = [{id:1}, {id:2, name:"foo"}]; }
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~
!!! error TS2322: Type '({ id: number; } | { id: number; name: string; })[]' is not assignable to type '{ id: number; }[]'.
!!! error TS2322: Type '{ id: number; } | { id: number; name: string; }' is not assignable to type '{ id: number; }'.
!!! error TS2322: Type '{ id: number; name: string; }' is not assignable to type '{ id: number; }'.
@@ -1,9 +1,9 @@
tests/cases/compiler/contextualTyping17.ts(1,33): error TS2322: Type '{ id: number; name: string; }' is not assignable to type '{ id: number; }'.
tests/cases/compiler/contextualTyping17.ts(1,47): error TS2322: Type '{ id: number; name: string; }' is not assignable to type '{ id: number; }'.
Object literal may only specify known properties, and 'name' does not exist in type '{ id: number; }'.
==== tests/cases/compiler/contextualTyping17.ts (1 errors) ====
var foo: {id:number;} = {id:4}; foo = {id: 5, name:"foo"};
~~~
~~~~~~~~~~
!!! error TS2322: Type '{ id: number; name: string; }' is not assignable to type '{ id: number; }'.
!!! error TS2322: Object literal may only specify known properties, and 'name' does not exist in type '{ id: number; }'.
@@ -1,9 +1,9 @@
tests/cases/compiler/contextualTyping2.ts(1,5): error TS2322: Type '{ id: number; name: string; }' is not assignable to type '{ id: number; }'.
tests/cases/compiler/contextualTyping2.ts(1,32): error TS2322: Type '{ id: number; name: string; }' is not assignable to type '{ id: number; }'.
Object literal may only specify known properties, and 'name' does not exist in type '{ id: number; }'.
==== tests/cases/compiler/contextualTyping2.ts (1 errors) ====
var foo: {id:number;} = {id:4, name:"foo"};
~~~
~~~~~~~~~~
!!! error TS2322: Type '{ id: number; name: string; }' is not assignable to type '{ id: number; }'.
!!! error TS2322: Object literal may only specify known properties, and 'name' does not exist in type '{ id: number; }'.
@@ -1,4 +1,4 @@
tests/cases/compiler/contextualTyping20.ts(1,36): error TS2322: Type '({ id: number; } | { id: number; name: string; })[]' is not assignable to type '{ id: number; }[]'.
tests/cases/compiler/contextualTyping20.ts(1,58): error TS2322: Type '({ id: number; } | { id: number; name: string; })[]' is not assignable to type '{ id: number; }[]'.
Type '{ id: number; } | { id: number; name: string; }' is not assignable to type '{ id: number; }'.
Type '{ id: number; name: string; }' is not assignable to type '{ id: number; }'.
Object literal may only specify known properties, and 'name' does not exist in type '{ id: number; }'.
@@ -6,7 +6,7 @@ tests/cases/compiler/contextualTyping20.ts(1,36): error TS2322: Type '({ id: num
==== tests/cases/compiler/contextualTyping20.ts (1 errors) ====
var foo:{id:number;}[] = [{id:1}]; foo = [{id:1}, {id:2, name:"foo"}];
~~~
~~~~~~~~~~
!!! error TS2322: Type '({ id: number; } | { id: number; name: string; })[]' is not assignable to type '{ id: number; }[]'.
!!! error TS2322: Type '{ id: number; } | { id: number; name: string; }' is not assignable to type '{ id: number; }'.
!!! error TS2322: Type '{ id: number; name: string; }' is not assignable to type '{ id: number; }'.
@@ -1,9 +1,9 @@
tests/cases/compiler/contextualTyping4.ts(1,13): error TS2322: Type '{ id: number; name: string; }' is not assignable to type '{ id: number; }'.
tests/cases/compiler/contextualTyping4.ts(1,46): error TS2322: Type '{ id: number; name: string; }' is not assignable to type '{ id: number; }'.
Object literal may only specify known properties, and 'name' does not exist in type '{ id: number; }'.
==== tests/cases/compiler/contextualTyping4.ts (1 errors) ====
class foo { public bar:{id:number;} = {id:5, name:"foo"}; }
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~
!!! error TS2322: Type '{ id: number; name: string; }' is not assignable to type '{ id: number; }'.
!!! error TS2322: Object literal may only specify known properties, and 'name' does not exist in type '{ id: number; }'.
@@ -1,4 +1,4 @@
tests/cases/compiler/contextualTyping9.ts(1,5): error TS2322: Type '({ id: number; } | { id: number; name: string; })[]' is not assignable to type '{ id: number; }[]'.
tests/cases/compiler/contextualTyping9.ts(1,42): error TS2322: Type '({ id: number; } | { id: number; name: string; })[]' is not assignable to type '{ id: number; }[]'.
Type '{ id: number; } | { id: number; name: string; }' is not assignable to type '{ id: number; }'.
Type '{ id: number; name: string; }' is not assignable to type '{ id: number; }'.
Object literal may only specify known properties, and 'name' does not exist in type '{ id: number; }'.
@@ -6,7 +6,7 @@ tests/cases/compiler/contextualTyping9.ts(1,5): error TS2322: Type '({ id: numbe
==== tests/cases/compiler/contextualTyping9.ts (1 errors) ====
var foo:{id:number;}[] = [{id:1}, {id:2, name:"foo"}];
~~~
~~~~~~~~~~
!!! error TS2322: Type '({ id: number; } | { id: number; name: string; })[]' is not assignable to type '{ id: number; }[]'.
!!! error TS2322: Type '{ id: number; } | { id: number; name: string; }' is not assignable to type '{ id: number; }'.
!!! error TS2322: Type '{ id: number; name: string; }' is not assignable to type '{ id: number; }'.
@@ -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
@@ -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 {
}
@@ -0,0 +1,5 @@
=== tests/cases/compiler/declFileClassExtendsNull.ts ===
class ExtendsNull extends null {
>ExtendsNull : Symbol(ExtendsNull, Decl(declFileClassExtendsNull.ts, 0, 0))
}
@@ -0,0 +1,6 @@
=== tests/cases/compiler/declFileClassExtendsNull.ts ===
class ExtendsNull extends null {
>ExtendsNull : ExtendsNull
>null : null
}
@@ -34,6 +34,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var service_1 = require("./service");
var MyComponent = (function () {
function MyComponent(Service) {
this.Service = Service;

Some files were not shown because too many files have changed in this diff Show More