Merge branch 'master' into migrateMapsAndSets

# Conflicts:
#	src/compiler/checker.ts
#	src/compiler/commandLineParser.ts
#	src/compiler/core.ts
#	src/compiler/moduleNameResolver.ts
#	src/compiler/transformers/declarations.ts
#	src/compiler/tsbuildPublic.ts
#	src/compiler/types.ts
#	src/compiler/utilities.ts
#	src/harness/client.ts
#	src/server/editorServices.ts
#	src/server/typingsCache.ts
#	src/server/utilities.ts
#	src/services/codefixes/convertToAsyncFunction.ts
#	src/services/documentRegistry.ts
#	src/services/importTracker.ts
#	src/services/refactorProvider.ts
#	src/services/refactors/extractSymbol.ts
#	src/testRunner/unittests/programApi.ts
#	src/typingsInstallerCore/typingsInstaller.ts
#	tests/baselines/reference/api/tsserverlibrary.d.ts
#	tests/baselines/reference/api/typescript.d.ts
This commit is contained in:
Ron Buckton
2020-07-07 13:53:46 -07:00
292 changed files with 5919 additions and 3351 deletions
+18
View File
@@ -0,0 +1,18 @@
{
"problemMatcher": [
{
"owner": "tsc",
"pattern": [
{
"regexp": "^(?:\\s+\\d+\\>)?([^\\s].*)\\((\\d+),(\\d+)\\)\\s*:\\s+(error|warning|info)\\s+(\\w{1,2}\\d+)\\s*:\\s*(.*)$",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"code": 5,
"message": 6
}
]
}
]
}
+13 -6
View File
@@ -30,12 +30,19 @@ jobs:
run: |
npm uninstall typescript --no-save
npm uninstall tslint --no-save
- name: npm install and test
run: |
npm install
npm update
npm test
- run: npm install
- run: npm update
# Re: https://github.com/actions/setup-node/pull/125
- name: Register Problem Matcher for TSC
run: echo "##[add-matcher].github/tsc.json"
- name: Tests
run: npm test -- --no-lint
- name: Linter
run: npm run lint:ci
- name: Validate the browser can import TypeScript
run: gulp test-browser-integration
+3 -2
View File
@@ -350,11 +350,12 @@ const lintFoldEnd = async () => { if (fold.isTravis()) console.log(fold.end("lin
/** @type { (folder: string) => { (): Promise<any>; displayName?: string } } */
const eslint = (folder) => async () => {
const formatter = cmdLineOptions.ci ? "stylish" : "autolinkable-stylish";
const args = [
"node_modules/eslint/bin/eslint",
"--cache",
"--cache-location", `${folder}/.eslintcache`,
"--format", "autolinkable-stylish",
"--format", formatter,
"--rulesdir", "scripts/eslint/built/rules",
"--ext", ".ts",
];
@@ -367,7 +368,7 @@ const eslint = (folder) => async () => {
log(`Linting: ${args.join(" ")}`);
return exec(process.execPath, args);
}
};
const lintScripts = eslint("scripts");
lintScripts.displayName = "lint-scripts";
File diff suppressed because it is too large Load Diff
-223
View File
@@ -1,223 +0,0 @@
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/// <reference no-default-lib="true"/>
interface ReadonlyArray<T> {
/**
* Calls a defined callback function on each element of an array. Then, flattens the result into
* a new array.
* This is identical to a map followed by flat with depth 1.
*
* @param callback A function that accepts up to three arguments. The flatMap method calls the
* callback function one time for each element in the array.
* @param thisArg An object to which the this keyword can refer in the callback function. If
* thisArg is omitted, undefined is used as the this value.
*/
flatMap<U, This = undefined> (
callback: (this: This, value: T, index: number, array: T[]) => U|ReadonlyArray<U>,
thisArg?: This
): U[]
/**
* Returns a new array with all sub-array elements concatenated into it recursively up to the
* specified depth.
*
* @param depth The maximum recursion depth
*/
flat<U>(this:
ReadonlyArray<U[][][][]> |
ReadonlyArray<ReadonlyArray<U[][][]>> |
ReadonlyArray<ReadonlyArray<U[][]>[]> |
ReadonlyArray<ReadonlyArray<U[]>[][]> |
ReadonlyArray<ReadonlyArray<U>[][][]> |
ReadonlyArray<ReadonlyArray<ReadonlyArray<U[][]>>> |
ReadonlyArray<ReadonlyArray<ReadonlyArray<U>[][]>> |
ReadonlyArray<ReadonlyArray<ReadonlyArray<U>>[][]> |
ReadonlyArray<ReadonlyArray<ReadonlyArray<U>[]>[]> |
ReadonlyArray<ReadonlyArray<ReadonlyArray<U[]>>[]> |
ReadonlyArray<ReadonlyArray<ReadonlyArray<U[]>[]>> |
ReadonlyArray<ReadonlyArray<ReadonlyArray<ReadonlyArray<U[]>>>> |
ReadonlyArray<ReadonlyArray<ReadonlyArray<ReadonlyArray<U>[]>>> |
ReadonlyArray<ReadonlyArray<ReadonlyArray<ReadonlyArray<U>>[]>> |
ReadonlyArray<ReadonlyArray<ReadonlyArray<ReadonlyArray<U>>>[]> |
ReadonlyArray<ReadonlyArray<ReadonlyArray<ReadonlyArray<ReadonlyArray<U>>>>>,
depth: 4): U[];
/**
* Returns a new array with all sub-array elements concatenated into it recursively up to the
* specified depth.
*
* @param depth The maximum recursion depth
*/
flat<U>(this:
ReadonlyArray<U[][][]> |
ReadonlyArray<ReadonlyArray<U>[][]> |
ReadonlyArray<ReadonlyArray<U[]>[]> |
ReadonlyArray<ReadonlyArray<U[][]>> |
ReadonlyArray<ReadonlyArray<ReadonlyArray<U[]>>> |
ReadonlyArray<ReadonlyArray<ReadonlyArray<U>[]>> |
ReadonlyArray<ReadonlyArray<ReadonlyArray<U>>[]> |
ReadonlyArray<ReadonlyArray<ReadonlyArray<ReadonlyArray<U>>>>,
depth: 3): U[];
/**
* Returns a new array with all sub-array elements concatenated into it recursively up to the
* specified depth.
*
* @param depth The maximum recursion depth
*/
flat<U>(this:
ReadonlyArray<U[][]> |
ReadonlyArray<ReadonlyArray<U[]>> |
ReadonlyArray<ReadonlyArray<U>[]> |
ReadonlyArray<ReadonlyArray<ReadonlyArray<U>>>,
depth: 2): U[];
/**
* Returns a new array with all sub-array elements concatenated into it recursively up to the
* specified depth.
*
* @param depth The maximum recursion depth
*/
flat<U>(this:
ReadonlyArray<U[]> |
ReadonlyArray<ReadonlyArray<U>>,
depth?: 1
): U[];
/**
* Returns a new array with all sub-array elements concatenated into it recursively up to the
* specified depth.
*
* @param depth The maximum recursion depth
*/
flat<U>(this:
ReadonlyArray<U>,
depth: 0
): U[];
/**
* Returns a new array with all sub-array elements concatenated into it recursively up to the
* specified depth. If no depth is provided, flat method defaults to the depth of 1.
*
* @param depth The maximum recursion depth
*/
flat<U>(depth?: number): any[];
}
interface Array<T> {
/**
* Calls a defined callback function on each element of an array. Then, flattens the result into
* a new array.
* This is identical to a map followed by flat with depth 1.
*
* @param callback A function that accepts up to three arguments. The flatMap method calls the
* callback function one time for each element in the array.
* @param thisArg An object to which the this keyword can refer in the callback function. If
* thisArg is omitted, undefined is used as the this value.
*/
flatMap<U, This = undefined> (
callback: (this: This, value: T, index: number, array: T[]) => U|ReadonlyArray<U>,
thisArg?: This
): U[]
/**
* Returns a new array with all sub-array elements concatenated into it recursively up to the
* specified depth.
*
* @param depth The maximum recursion depth
*/
flat<U>(this: U[][][][][][][][], depth: 7): U[];
/**
* Returns a new array with all sub-array elements concatenated into it recursively up to the
* specified depth.
*
* @param depth The maximum recursion depth
*/
flat<U>(this: U[][][][][][][], depth: 6): U[];
/**
* Returns a new array with all sub-array elements concatenated into it recursively up to the
* specified depth.
*
* @param depth The maximum recursion depth
*/
flat<U>(this: U[][][][][][], depth: 5): U[];
/**
* Returns a new array with all sub-array elements concatenated into it recursively up to the
* specified depth.
*
* @param depth The maximum recursion depth
*/
flat<U>(this: U[][][][][], depth: 4): U[];
/**
* Returns a new array with all sub-array elements concatenated into it recursively up to the
* specified depth.
*
* @param depth The maximum recursion depth
*/
flat<U>(this: U[][][][], depth: 3): U[];
/**
* Returns a new array with all sub-array elements concatenated into it recursively up to the
* specified depth.
*
* @param depth The maximum recursion depth
*/
flat<U>(this: U[][][], depth: 2): U[];
/**
* Returns a new array with all sub-array elements concatenated into it recursively up to the
* specified depth.
*
* @param depth The maximum recursion depth
*/
flat<U>(this: U[][], depth?: 1): U[];
/**
* Returns a new array with all sub-array elements concatenated into it recursively up to the
* specified depth.
*
* @param depth The maximum recursion depth
*/
flat<U>(this: U[], depth: 0): U[];
/**
* Returns a new array with all sub-array elements concatenated into it recursively up to the
* specified depth. If no depth is provided, flat method defaults to the depth of 1.
*
* @param depth The maximum recursion depth
*/
flat<U>(depth?: number): any[];
}
-44
View File
@@ -1,44 +0,0 @@
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/// <reference no-default-lib="true"/>
/// <reference lib="es2015.symbol" />
/// <reference lib="es2015.iterable" />
interface SymbolConstructor {
/**
* A method that returns the default async iterator for an object. Called by the semantics of
* the for-await-of statement.
*/
readonly asyncIterator: symbol;
}
interface AsyncIterator<T> {
next(value?: any): Promise<IteratorResult<T>>;
return?(value?: any): Promise<IteratorResult<T>>;
throw?(e?: any): Promise<IteratorResult<T>>;
}
interface AsyncIterable<T> {
[Symbol.asyncIterator](): AsyncIterator<T>;
}
interface AsyncIterableIterator<T> extends AsyncIterator<T> {
[Symbol.asyncIterator](): AsyncIterableIterator<T>;
}
-629
View File
@@ -1,629 +0,0 @@
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/// <reference no-default-lib="true"/>
interface BigInt {
/**
* Returns a string representation of an object.
* @param radix Specifies a radix for converting numeric values to strings.
*/
toString(radix?: number): string;
/** Returns a string representation appropriate to the host environment's current locale. */
toLocaleString(): string;
/** Returns the primitive value of the specified object. */
valueOf(): bigint;
readonly [Symbol.toStringTag]: "BigInt";
}
interface BigIntConstructor {
(value?: any): bigint;
readonly prototype: BigInt;
/**
* Interprets the low bits of a BigInt as a 2's-complement signed integer.
* All higher bits are discarded.
* @param bits The number of low bits to use
* @param int The BigInt whose bits to extract
*/
asIntN(bits: number, int: bigint): bigint;
/**
* Interprets the low bits of a BigInt as an unsigned integer.
* All higher bits are discarded.
* @param bits The number of low bits to use
* @param int The BigInt whose bits to extract
*/
asUintN(bits: number, int: bigint): bigint;
}
declare var BigInt: BigIntConstructor;
/**
* A typed array of 64-bit signed integer values. The contents are initialized to 0. If the
* requested number of bytes could not be allocated, an exception is raised.
*/
interface BigInt64Array {
/** The size in bytes of each element in the array. */
readonly BYTES_PER_ELEMENT: number;
/** The ArrayBuffer instance referenced by the array. */
readonly buffer: ArrayBufferLike;
/** The length in bytes of the array. */
readonly byteLength: number;
/** The offset in bytes of the array. */
readonly byteOffset: number;
/**
* Returns the this object after copying a section of the array identified by start and end
* to the same array starting at position target
* @param target If target is negative, it is treated as length+target where length is the
* length of the array.
* @param start If start is negative, it is treated as length+start. If end is negative, it
* is treated as length+end.
* @param end If not specified, length of the this object is used as its default value.
*/
copyWithin(target: number, start: number, end?: number): this;
/** Yields index, value pairs for every entry in the array. */
entries(): IterableIterator<[number, bigint]>;
/**
* 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 the array 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: bigint, index: number, array: BigInt64Array) => 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: bigint, start?: number, end?: number): this;
/**
* 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: bigint, index: number, array: BigInt64Array) => any, thisArg?: any): BigInt64Array;
/**
* 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: bigint, index: number, array: BigInt64Array) => boolean, thisArg?: any): bigint | undefined;
/**
* Returns the index of the first element in the array where predicate is true, and -1
* otherwise.
* @param predicate find calls predicate once for each element of the array, in ascending
* order, until it finds one where predicate returns true. If such an element is found,
* findIndex immediately returns that element index. Otherwise, findIndex returns -1.
* @param thisArg If provided, it will be used as the this value for each invocation of
* predicate. If it is not provided, undefined is used instead.
*/
findIndex(predicate: (value: bigint, index: number, array: BigInt64Array) => 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: bigint, index: number, array: BigInt64Array) => void, thisArg?: any): void;
/**
* Determines whether an array includes a certain element, returning true or false as appropriate.
* @param searchElement The element to search for.
* @param fromIndex The position in this array at which to begin searching for searchElement.
*/
includes(searchElement: bigint, fromIndex?: number): boolean;
/**
* 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: bigint, 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;
/** Yields each index in the array. */
keys(): IterableIterator<number>;
/**
* 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: bigint, fromIndex?: number): number;
/** The length of the array. */
readonly length: number;
/**
* Calls a defined callback function on each element of an array, and returns an array that
* contains the results.
* @param callbackfn A function that accepts up to three arguments. The map method calls the
* callbackfn function one time for each element in the array.
* @param thisArg An object to which the this keyword can refer in the callbackfn function.
* If thisArg is omitted, undefined is used as the this value.
*/
map(callbackfn: (value: bigint, index: number, array: BigInt64Array) => bigint, thisArg?: any): BigInt64Array;
/**
* 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: bigint, currentValue: bigint, currentIndex: number, array: BigInt64Array) => bigint): bigint;
/**
* 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: bigint, currentIndex: number, array: BigInt64Array) => 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: bigint, currentValue: bigint, currentIndex: number, array: BigInt64Array) => bigint): bigint;
/**
* 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: bigint, currentIndex: number, array: BigInt64Array) => U, initialValue: U): U;
/** Reverses the elements in the array. */
reverse(): this;
/**
* Sets a value or an array of values.
* @param array A typed or untyped array of values to set.
* @param offset The index in the current array at which the values are to be written.
*/
set(array: ArrayLike<bigint>, 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): BigInt64Array;
/**
* 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 the array 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: bigint, index: number, array: BigInt64Array) => boolean, thisArg?: any): boolean;
/**
* Sorts the array.
* @param compareFn The function used to determine the order of the elements. If omitted, the elements are sorted in ascending order.
*/
sort(compareFn?: (a: bigint, b: bigint) => number | bigint): this;
/**
* Gets a new BigInt64Array 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): BigInt64Array;
/** Converts the array to a string by using the current locale. */
toLocaleString(): string;
/** Returns a string representation of the array. */
toString(): string;
/** Yields each value in the array. */
values(): IterableIterator<bigint>;
[Symbol.iterator](): IterableIterator<bigint>;
readonly [Symbol.toStringTag]: "BigInt64Array";
[index: number]: bigint;
}
interface BigInt64ArrayConstructor {
readonly prototype: BigInt64Array;
new(length?: number): BigInt64Array;
new(array: Iterable<bigint>): BigInt64Array;
new(buffer: ArrayBufferLike, byteOffset?: number, length?: number): BigInt64Array;
/** The size in bytes of each element in the array. */
readonly BYTES_PER_ELEMENT: number;
/**
* Returns a new array from a set of elements.
* @param items A set of elements to include in the new array object.
*/
of(...items: bigint[]): BigInt64Array;
/**
* 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<bigint>): BigInt64Array;
from<U>(arrayLike: ArrayLike<U>, mapfn: (v: U, k: number) => bigint, thisArg?: any): BigInt64Array;
}
declare var BigInt64Array: BigInt64ArrayConstructor;
/**
* A typed array of 64-bit unsigned integer values. The contents are initialized to 0. If the
* requested number of bytes could not be allocated, an exception is raised.
*/
interface BigUint64Array {
/** The size in bytes of each element in the array. */
readonly BYTES_PER_ELEMENT: number;
/** The ArrayBuffer instance referenced by the array. */
readonly buffer: ArrayBufferLike;
/** The length in bytes of the array. */
readonly byteLength: number;
/** The offset in bytes of the array. */
readonly byteOffset: number;
/**
* Returns the this object after copying a section of the array identified by start and end
* to the same array starting at position target
* @param target If target is negative, it is treated as length+target where length is the
* length of the array.
* @param start If start is negative, it is treated as length+start. If end is negative, it
* is treated as length+end.
* @param end If not specified, length of the this object is used as its default value.
*/
copyWithin(target: number, start: number, end?: number): this;
/** Yields index, value pairs for every entry in the array. */
entries(): IterableIterator<[number, bigint]>;
/**
* 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 the array 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: bigint, index: number, array: BigUint64Array) => 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: bigint, start?: number, end?: number): this;
/**
* 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: bigint, index: number, array: BigUint64Array) => any, thisArg?: any): BigUint64Array;
/**
* 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: bigint, index: number, array: BigUint64Array) => boolean, thisArg?: any): bigint | undefined;
/**
* Returns the index of the first element in the array where predicate is true, and -1
* otherwise.
* @param predicate find calls predicate once for each element of the array, in ascending
* order, until it finds one where predicate returns true. If such an element is found,
* findIndex immediately returns that element index. Otherwise, findIndex returns -1.
* @param thisArg If provided, it will be used as the this value for each invocation of
* predicate. If it is not provided, undefined is used instead.
*/
findIndex(predicate: (value: bigint, index: number, array: BigUint64Array) => 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: bigint, index: number, array: BigUint64Array) => void, thisArg?: any): void;
/**
* Determines whether an array includes a certain element, returning true or false as appropriate.
* @param searchElement The element to search for.
* @param fromIndex The position in this array at which to begin searching for searchElement.
*/
includes(searchElement: bigint, fromIndex?: number): boolean;
/**
* 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: bigint, 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;
/** Yields each index in the array. */
keys(): IterableIterator<number>;
/**
* 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: bigint, fromIndex?: number): number;
/** The length of the array. */
readonly length: number;
/**
* Calls a defined callback function on each element of an array, and returns an array that
* contains the results.
* @param callbackfn A function that accepts up to three arguments. The map method calls the
* callbackfn function one time for each element in the array.
* @param thisArg An object to which the this keyword can refer in the callbackfn function.
* If thisArg is omitted, undefined is used as the this value.
*/
map(callbackfn: (value: bigint, index: number, array: BigUint64Array) => bigint, thisArg?: any): BigUint64Array;
/**
* 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: bigint, currentValue: bigint, currentIndex: number, array: BigUint64Array) => bigint): bigint;
/**
* 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: bigint, currentIndex: number, array: BigUint64Array) => 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: bigint, currentValue: bigint, currentIndex: number, array: BigUint64Array) => bigint): bigint;
/**
* 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: bigint, currentIndex: number, array: BigUint64Array) => U, initialValue: U): U;
/** Reverses the elements in the array. */
reverse(): this;
/**
* Sets a value or an array of values.
* @param array A typed or untyped array of values to set.
* @param offset The index in the current array at which the values are to be written.
*/
set(array: ArrayLike<bigint>, 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): BigUint64Array;
/**
* 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 the array 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: bigint, index: number, array: BigUint64Array) => boolean, thisArg?: any): boolean;
/**
* Sorts the array.
* @param compareFn The function used to determine the order of the elements. If omitted, the elements are sorted in ascending order.
*/
sort(compareFn?: (a: bigint, b: bigint) => number | bigint): this;
/**
* Gets a new BigUint64Array 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): BigUint64Array;
/** Converts the array to a string by using the current locale. */
toLocaleString(): string;
/** Returns a string representation of the array. */
toString(): string;
/** Yields each value in the array. */
values(): IterableIterator<bigint>;
[Symbol.iterator](): IterableIterator<bigint>;
readonly [Symbol.toStringTag]: "BigUint64Array";
[index: number]: bigint;
}
interface BigUint64ArrayConstructor {
readonly prototype: BigUint64Array;
new(length?: number): BigUint64Array;
new(array: Iterable<bigint>): BigUint64Array;
new(buffer: ArrayBufferLike, byteOffset?: number, length?: number): BigUint64Array;
/** The size in bytes of each element in the array. */
readonly BYTES_PER_ELEMENT: number;
/**
* Returns a new array from a set of elements.
* @param items A set of elements to include in the new array object.
*/
of(...items: bigint[]): BigUint64Array;
/**
* 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<bigint>): BigUint64Array;
from<U>(arrayLike: ArrayLike<U>, mapfn: (v: U, k: number) => bigint, thisArg?: any): BigUint64Array;
}
declare var BigUint64Array: BigUint64ArrayConstructor;
interface DataView {
/**
* Gets the BigInt64 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.
*/
getBigInt64(byteOffset: number, littleEndian?: boolean): bigint;
/**
* Gets the BigUint64 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.
*/
getBigUint64(byteOffset: number, littleEndian?: boolean): bigint;
/**
* Stores a BigInt64 value at the specified byte offset from the start of the view.
* @param byteOffset The place in the buffer at which the value should be set.
* @param value The value to set.
* @param littleEndian If false or undefined, a big-endian value should be written,
* otherwise a little-endian value should be written.
*/
setBigInt64(byteOffset: number, value: bigint, littleEndian?: boolean): void;
/**
* Stores a BigUint64 value at the specified byte offset from the start of the view.
* @param byteOffset The place in the buffer at which the value should be set.
* @param value The value to set.
* @param littleEndian If false or undefined, a big-endian value should be written,
* otherwise a little-endian value should be written.
*/
setBigUint64(byteOffset: number, value: bigint, littleEndian?: boolean): void;
}
-26
View File
@@ -1,26 +0,0 @@
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/// <reference no-default-lib="true"/>
interface Symbol {
/**
* expose the [[Description]] internal slot of a symbol directly
*/
readonly description: string;
}
+1 -1
View File
@@ -54,7 +54,7 @@
"@types/through2": "latest",
"@types/travis-fold": "latest",
"@types/xml2js": "^0.4.0",
"@typescript-eslint/eslint-plugin": "^3.4.1-alpha.1",
"@typescript-eslint/eslint-plugin": "^3.6.1-alpha.1",
"@typescript-eslint/experimental-utils": "^3.4.1-alpha.1",
"@typescript-eslint/parser": "^3.4.1-alpha.1",
"async": "latest",
+322
View File
@@ -0,0 +1,322 @@
// @ts-check
// This script does two things:
//
// - Listens to changes to the built version of TypeScript (via a filewatcher on `built/local/typescriptServices.js`)
// these trigger creating monaco-typescript compatible builds of TypeScript at `internal/lib/typescriptServices.js§
//
// - Creates a HTTP server which the playground uses. The webserver almost exclusively re-directs requests to
// the latest stable version of monaco-typescript, but specifically overrides requests for the TypeScript js
// file to the version created in the above step.
//
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
const path = require('path');
const fs = require('fs');
const child_process = require('child_process');
const http = require('http');
const url = require('url');
function updateTSDist() {
// This code is a direct port of a script from monaco-typescript
// https://github.com/microsoft/monaco-typescript/blob/master/scripts/importTypescript.js
// Currently based on 778ace1 on Apr 25 2020
const generatedNote = `//
// **NOTE**: Do not edit directly! This file is generated using \`npm run import-typescript\`
//
`;
const TYPESCRIPT_LIB_SOURCE = path.join(__dirname, '../built/local');
const TYPESCRIPT_LIB_DESTINATION = path.join(__dirname, '../internal/lib');
(function () {
try {
fs.statSync(TYPESCRIPT_LIB_DESTINATION);
} catch (err) {
fs.mkdirSync(TYPESCRIPT_LIB_DESTINATION);
}
importLibs();
const npmLsOutput = JSON.parse(child_process.execSync("npm ls typescript --depth=0 --json=true").toString());
const typeScriptDependencyVersion = npmLsOutput.dependencies.typescript.version;
fs.writeFileSync(
path.join(TYPESCRIPT_LIB_DESTINATION, 'typescriptServicesMetadata.ts'),
`${generatedNote}
export const typescriptVersion = "${typeScriptDependencyVersion}";\n`
);
var tsServices = fs.readFileSync(path.join(TYPESCRIPT_LIB_SOURCE, 'typescriptServices.js')).toString();
// Ensure we never run into the node system...
// (this also removes require calls that trick webpack into shimming those modules...)
tsServices = (
tsServices.replace(/\n ts\.sys =([^]*)\n \}\)\(\);/m, `\n // MONACOCHANGE\n ts.sys = undefined;\n // END MONACOCHANGE`)
);
// Eliminate more require() calls...
tsServices = tsServices.replace(/^( +)etwModule = require\(.*$/m, '$1// MONACOCHANGE\n$1etwModule = undefined;\n$1// END MONACOCHANGE');
tsServices = tsServices.replace(/^( +)var result = ts\.sys\.require\(.*$/m, '$1// MONACOCHANGE\n$1var result = undefined;\n$1// END MONACOCHANGE');
// Flag any new require calls (outside comments) so they can be corrected preemptively.
// To avoid missing cases (or using an even more complex regex), temporarily remove comments
// about require() and then check for lines actually calling require().
// \/[*/] matches the start of a comment (single or multi-line).
// ^\s+\*[^/] matches (presumably) a later line of a multi-line comment.
const tsServicesNoCommentedRequire = tsServices.replace(/(\/[*/]|^\s+\*[^/]).*\brequire\(.*/gm, '');
const linesWithRequire = tsServicesNoCommentedRequire.match(/^.*?\brequire\(.*$/gm)
// Allow error messages to include references to require() in their strings
const runtimeRequires = linesWithRequire && linesWithRequire.filter(l => !l.includes(": diag("))
if (runtimeRequires && runtimeRequires.length) {
console.error('Found new require() calls on the following lines. These should be removed to avoid breaking webpack builds.\n');
console.error(linesWithRequire.join('\n'));
process.exit(1);
}
// Make sure process.args don't get called in the browser, this
// should only happen in TS 2.6.2
const beforeProcess = `ts.perfLogger.logInfoEvent("Starting TypeScript v" + ts.versionMajorMinor + " with command line: " + JSON.stringify(process.argv));`
const afterProcess = `// MONACOCHANGE\n ts.perfLogger.logInfoEvent("Starting TypeScript v" + ts.versionMajorMinor + " with command line: " + JSON.stringify([]));\n// END MONACOCHANGE`
tsServices = tsServices.replace(beforeProcess, afterProcess);
var tsServices_amd = generatedNote + tsServices +
`
// MONACOCHANGE
// Defining the entire module name because r.js has an issue and cannot bundle this file
// correctly with an anonymous define call
define("vs/language/typescript/lib/typescriptServices", [], function() { return ts; });
// END MONACOCHANGE
`;
fs.writeFileSync(path.join(TYPESCRIPT_LIB_DESTINATION, 'typescriptServices-amd.js'), tsServices_amd);
var tsServices_esm = generatedNote + tsServices +
`
// MONACOCHANGE
export var createClassifier = ts.createClassifier;
export var createLanguageService = ts.createLanguageService;
export var displayPartsToString = ts.displayPartsToString;
export var EndOfLineState = ts.EndOfLineState;
export var flattenDiagnosticMessageText = ts.flattenDiagnosticMessageText;
export var IndentStyle = ts.IndentStyle;
export var ScriptKind = ts.ScriptKind;
export var ScriptTarget = ts.ScriptTarget;
export var TokenClass = ts.TokenClass;
// END MONACOCHANGE
`;
fs.writeFileSync(path.join(TYPESCRIPT_LIB_DESTINATION, 'typescriptServices.js'), tsServices_esm);
var dtsServices = fs.readFileSync(path.join(TYPESCRIPT_LIB_SOURCE, 'typescriptServices.d.ts')).toString();
dtsServices +=
`
// MONACOCHANGE
export = ts;
// END MONACOCHANGE
`;
fs.writeFileSync(path.join(TYPESCRIPT_LIB_DESTINATION, 'typescriptServices.d.ts'), generatedNote + dtsServices);
})();
function importLibs() {
function getFileName(name) {
return (name === '' ? 'lib.d.ts' : `lib.${name}.d.ts`);
}
function getVariableName(name) {
return (name === '' ? 'lib_dts' : `lib_${name.replace(/\./g, '_')}_dts`);
}
function readLibFile(name) {
var srcPath = path.join(TYPESCRIPT_LIB_SOURCE, getFileName(name));
return fs.readFileSync(srcPath).toString();
}
var queue = [];
var in_queue = {};
var enqueue = function (name) {
if (in_queue[name]) {
return;
}
in_queue[name] = true;
queue.push(name);
};
enqueue('');
enqueue('es2015');
var result = [];
while (queue.length > 0) {
var name = queue.shift();
var contents = readLibFile(name);
var lines = contents.split(/\r\n|\r|\n/);
var output = '';
var writeOutput = function (text) {
if (output.length === 0) {
output = text;
} else {
output += ` + ${text}`;
}
};
var outputLines = [];
var flushOutputLines = function () {
writeOutput(`"${escapeText(outputLines.join('\n'))}"`);
outputLines = [];
};
var deps = [];
for (let i = 0; i < lines.length; i++) {
let m = lines[i].match(/\/\/\/\s*<reference\s*lib="([^"]+)"/);
if (m) {
flushOutputLines();
writeOutput(getVariableName(m[1]));
deps.push(getVariableName(m[1]));
enqueue(m[1]);
continue;
}
outputLines.push(lines[i]);
}
flushOutputLines();
result.push({
name: getVariableName(name),
deps: deps,
output: output
});
}
var strResult = `/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
${generatedNote}`;
// Do a topological sort
while (result.length > 0) {
for (let i = result.length - 1; i >= 0; i--) {
if (result[i].deps.length === 0) {
// emit this node
strResult += `\nexport const ${result[i].name}: string = ${result[i].output};\n`;
// mark dep as resolved
for (let j = 0; j < result.length; j++) {
for (let k = 0; k < result[j].deps.length; k++) {
if (result[j].deps[k] === result[i].name) {
result[j].deps.splice(k, 1);
break;
}
}
}
// remove from result
result.splice(i, 1);
break;
}
}
}
strResult += `
/** This is the DTS which is used when the target is ES6 or below */
export const lib_es5_bundled_dts = lib_dts;
/** This is the DTS which is used by default in monaco-typescript, and when the target is 2015 or above */
export const lib_es2015_bundled_dts = lib_es2015_dts + "" + lib_dom_dts + "" + lib_webworker_importscripts_dts + "" + lib_scripthost_dts + "";
`
var dstPath = path.join(TYPESCRIPT_LIB_DESTINATION, 'lib.ts');
fs.writeFileSync(dstPath, strResult);
}
/**
* Escape text such that it can be used in a javascript string enclosed by double quotes (")
*/
function escapeText(text) {
// See http://www.javascriptkit.com/jsref/escapesequence.shtml
var _backspace = '\b'.charCodeAt(0);
var _formFeed = '\f'.charCodeAt(0);
var _newLine = '\n'.charCodeAt(0);
var _nullChar = 0;
var _carriageReturn = '\r'.charCodeAt(0);
var _tab = '\t'.charCodeAt(0);
var _verticalTab = '\v'.charCodeAt(0);
var _backslash = '\\'.charCodeAt(0);
var _doubleQuote = '"'.charCodeAt(0);
var startPos = 0, chrCode, replaceWith = null, resultPieces = [];
for (var i = 0, len = text.length; i < len; i++) {
chrCode = text.charCodeAt(i);
switch (chrCode) {
case _backspace:
replaceWith = '\\b';
break;
case _formFeed:
replaceWith = '\\f';
break;
case _newLine:
replaceWith = '\\n';
break;
case _nullChar:
replaceWith = '\\0';
break;
case _carriageReturn:
replaceWith = '\\r';
break;
case _tab:
replaceWith = '\\t';
break;
case _verticalTab:
replaceWith = '\\v';
break;
case _backslash:
replaceWith = '\\\\';
break;
case _doubleQuote:
replaceWith = '\\"';
break;
}
if (replaceWith !== null) {
resultPieces.push(text.substring(startPos, i));
resultPieces.push(replaceWith);
startPos = i + 1;
replaceWith = null;
}
}
resultPieces.push(text.substring(startPos, len));
return resultPieces.join('');
}
/// End of import
}
const services = path.join(__dirname, '../built/local/typescriptServices.js');
fs.watchFile(services, () =>{
console.log("Updating the monaco build")
updateTSDist()
})
http.createServer(function (req, res) {
const incoming = url.parse(req.url)
if (incoming.path.endsWith("typescriptServices.js")) {
// Use the built version
res.writeHead(200, {"Content-Type": "text/javascript"});
const amdPath = path.join(__dirname, '../internal/lib/typescriptServices-amd.js');
res.write(fs.readFileSync(amdPath))
} else {
// Redirect to the TS CDN
res.writeHead(302, {
'Location': `https://typescript.azureedge.net/cdn/3.9.2/monaco/${incoming.path}`
});
}
res.end();
}).listen(5615);
console.log("Starting servers\n")
console.log(" - [✓] file watcher: " + services)
console.log(" - [✓] http server: http://localhost:5615")
console.log("\n\nGet started: http://www.staging-typescript.org/play?ts=dev")
+2 -2
View File
@@ -47,8 +47,8 @@ and then running \`npm install\`.
});
// Temporarily disable until we get access controls set up right
// Send a ping to https://github.com/orta/make-monaco-builds#pull-request-builds
await gh.request("POST /repos/orta/make-monaco-builds/dispatches", { event_type: process.env.SOURCE_ISSUE, headers: { Accept: "application/vnd.github.everest-preview+json" }});
// Send a ping to https://github.com/microsoft/typescript-make-monaco-builds#pull-request-builds
await gh.request("POST /repos/microsoft/typescript-make-monaco-builds/dispatches", { event_type: process.env.SOURCE_ISSUE, headers: { Accept: "application/vnd.github.everest-preview+json" }});
}
main().catch(async e => {
+5 -1
View File
@@ -3,7 +3,6 @@
import childProcess = require("child_process");
import fs = require("fs-extra");
import path = require("path");
import removeInternal = require("remove-internal");
import glob = require("glob");
const root = path.join(__dirname, "..");
@@ -15,6 +14,7 @@ async function produceLKG() {
console.log(`Building LKG from ${source} to ${dest}`);
await copyLibFiles();
await copyLocalizedDiagnostics();
await copyTypesMap();
await buildProtocol();
await copyScriptOutputs();
await copyDeclarationOutputs();
@@ -40,6 +40,10 @@ async function copyLocalizedDiagnostics() {
}
}
async function copyTypesMap() {
await copyFromBuiltLocal("typesMap.json"); // Cannot accommodate copyright header
}
async function buildProtocol() {
const protocolScript = path.join(__dirname, "buildProtocol.js");
if (!fs.existsSync(protocolScript)) {
+8 -7
View File
@@ -15,7 +15,7 @@ namespace ts {
referenced: boolean;
}
export function getModuleInstanceState(node: ModuleDeclaration, visited?: Map<number, ModuleInstanceState | undefined>): ModuleInstanceState {
export function getModuleInstanceState(node: ModuleDeclaration, visited?: ESMap<number, ModuleInstanceState | undefined>): ModuleInstanceState {
if (node.body && !node.body.parent) {
// getModuleInstanceStateForAliasTarget needs to walk up the parent chain, so parent pointers must be set on this tree already
setParent(node.body, node);
@@ -35,7 +35,7 @@ namespace ts {
return result;
}
function getModuleInstanceStateWorker(node: Node, visited: Map<number, ModuleInstanceState | undefined>): ModuleInstanceState {
function getModuleInstanceStateWorker(node: Node, visited: ESMap<number, ModuleInstanceState | undefined>): ModuleInstanceState {
// A module is uninstantiated if it contains only
switch (node.kind) {
// 1. interface declarations, type alias declarations
@@ -107,7 +107,7 @@ namespace ts {
return ModuleInstanceState.Instantiated;
}
function getModuleInstanceStateForAliasTarget(specifier: ExportSpecifier, visited: Map<number, ModuleInstanceState | undefined>) {
function getModuleInstanceStateForAliasTarget(specifier: ExportSpecifier, visited: ESMap<number, ModuleInstanceState | undefined>) {
const name = specifier.propertyName || specifier.name;
let p: Node | undefined = specifier.parent;
while (p) {
@@ -537,10 +537,6 @@ namespace ts {
symbol.parent = parent;
}
if (node.flags & NodeFlags.Deprecated) {
symbol.flags |= SymbolFlags.Deprecated;
}
return symbol;
}
@@ -1245,6 +1241,11 @@ namespace ts {
if (currentReturnTarget && returnLabel.antecedents) {
addAntecedent(currentReturnTarget, createReduceLabel(finallyLabel, returnLabel.antecedents, currentFlow));
}
// If we have an outer exception target (i.e. a containing try-finally or try-catch-finally), add a
// control flow that goes back through the finally blok and back through each possible exception source.
if (currentExceptionTarget && exceptionLabel.antecedents) {
addAntecedent(currentExceptionTarget, createReduceLabel(finallyLabel, exceptionLabel.antecedents, currentFlow));
}
// If the end of the finally block is reachable, but the end of the try and catch blocks are not,
// convert the current flow to unreachable. For example, 'try { return 1; } finally { ... }' should
// result in an unreachable current control flow.
+8 -8
View File
@@ -24,7 +24,7 @@ namespace ts {
/**
* Cache of bind and check diagnostics for files with their Path being the key
*/
semanticDiagnosticsPerFile?: ReadonlyMap<Path, readonly ReusableDiagnostic[] | readonly Diagnostic[]> | undefined;
semanticDiagnosticsPerFile?: ReadonlyESMap<Path, readonly ReusableDiagnostic[] | readonly Diagnostic[]> | undefined;
/**
* The map has key by source file's path that has been changed
*/
@@ -41,7 +41,7 @@ namespace ts {
* Map of file signatures, with key being file path, calculated while getting current changed file's affected files
* These will be committed whenever the iteration through affected files of current changed file is complete
*/
currentAffectedFilesSignatures?: ReadonlyMap<Path, string> | undefined;
currentAffectedFilesSignatures?: ReadonlyESMap<Path, string> | undefined;
/**
* Newly computed visible to outside referencedSet
*/
@@ -65,7 +65,7 @@ namespace ts {
/**
* Files pending to be emitted kind.
*/
affectedFilesPendingEmitKind?: ReadonlyMap<Path, BuilderFileEmit> | undefined;
affectedFilesPendingEmitKind?: ReadonlyESMap<Path, BuilderFileEmit> | undefined;
/**
* Current index to retrieve pending affected file
*/
@@ -89,7 +89,7 @@ namespace ts {
/**
* Cache of bind and check diagnostics for files with their Path being the key
*/
semanticDiagnosticsPerFile: Map<Path, readonly Diagnostic[]> | undefined;
semanticDiagnosticsPerFile: ESMap<Path, readonly Diagnostic[]> | undefined;
/**
* The map has key by source file's path that has been changed
*/
@@ -110,7 +110,7 @@ namespace ts {
* Map of file signatures, with key being file path, calculated while getting current changed file's affected files
* These will be committed whenever the iteration through affected files of current changed file is complete
*/
currentAffectedFilesSignatures: Map<Path, string> | undefined;
currentAffectedFilesSignatures: ESMap<Path, string> | undefined;
/**
* Newly computed visible to outside referencedSet
*/
@@ -142,7 +142,7 @@ namespace ts {
/**
* Files pending to be emitted kind.
*/
affectedFilesPendingEmitKind: Map<Path, BuilderFileEmit> | undefined;
affectedFilesPendingEmitKind: ESMap<Path, BuilderFileEmit> | undefined;
/**
* Current index to retrieve pending affected file
*/
@@ -154,7 +154,7 @@ namespace ts {
/**
* Already seen emitted files
*/
seenEmittedFiles: Map<Path, BuilderFileEmit> | undefined;
seenEmittedFiles: ESMap<Path, BuilderFileEmit> | undefined;
/**
* true if program has been emitted
*/
@@ -1140,7 +1140,7 @@ namespace ts {
}
}
function getMapOfReferencedSet(mapLike: MapLike<readonly string[]> | undefined, toPath: (path: string) => Path): ReadonlyMap<Path, BuilderState.ReferencedSet> | undefined {
function getMapOfReferencedSet(mapLike: MapLike<readonly string[]> | undefined, toPath: (path: string) => Path): ReadonlyESMap<Path, BuilderState.ReferencedSet> | undefined {
if (!mapLike) return undefined;
const map = new Map<Path, BuilderState.ReferencedSet>();
// Copies keys/values from template. Note that for..in will not throw if
+12 -12
View File
@@ -15,36 +15,36 @@ namespace ts {
/**
* Information of the file eg. its version, signature etc
*/
fileInfos: ReadonlyMap<Path, BuilderState.FileInfo>;
fileInfos: ReadonlyESMap<Path, BuilderState.FileInfo>;
/**
* Contains the map of ReferencedSet=Referenced files of the file if module emit is enabled
* Otherwise undefined
* Thus non undefined value indicates, module emit
*/
readonly referencedMap?: ReadonlyMap<Path, BuilderState.ReferencedSet> | undefined;
readonly referencedMap?: ReadonlyESMap<Path, BuilderState.ReferencedSet> | undefined;
/**
* Contains the map of exported modules ReferencedSet=exported module files from the file if module emit is enabled
* Otherwise undefined
*/
readonly exportedModulesMap?: ReadonlyMap<Path, BuilderState.ReferencedSet> | undefined;
readonly exportedModulesMap?: ReadonlyESMap<Path, BuilderState.ReferencedSet> | undefined;
}
export interface BuilderState {
/**
* Information of the file eg. its version, signature etc
*/
fileInfos: Map<Path, BuilderState.FileInfo>;
fileInfos: ESMap<Path, BuilderState.FileInfo>;
/**
* Contains the map of ReferencedSet=Referenced files of the file if module emit is enabled
* Otherwise undefined
* Thus non undefined value indicates, module emit
*/
readonly referencedMap: ReadonlyMap<Path, BuilderState.ReferencedSet> | undefined;
readonly referencedMap: ReadonlyESMap<Path, BuilderState.ReferencedSet> | undefined;
/**
* Contains the map of exported modules ReferencedSet=exported module files from the file if module emit is enabled
* Otherwise undefined
*/
readonly exportedModulesMap: Map<Path, BuilderState.ReferencedSet> | undefined;
readonly exportedModulesMap: ESMap<Path, BuilderState.ReferencedSet> | undefined;
/**
* Map of files that have already called update signature.
* That means hence forth these files are assumed to have
@@ -83,7 +83,7 @@ namespace ts {
* Exported modules to from declaration emit being computed.
* This can contain false in the affected file path to specify that there are no exported module(types from other modules) for this file
*/
export type ComputingExportedModulesMap = Map<Path, ReferencedSet | false>;
export type ComputingExportedModulesMap = ESMap<Path, ReferencedSet | false>;
/**
* Get the referencedFile from the imported module symbol
@@ -192,7 +192,7 @@ namespace ts {
/**
* Returns true if oldState is reusable, that is the emitKind = module/non module has not changed
*/
export function canReuseOldState(newReferencedMap: ReadonlyMap<Path, ReferencedSet> | undefined, oldState: Readonly<ReusableBuilderState> | undefined) {
export function canReuseOldState(newReferencedMap: ReadonlyESMap<Path, ReferencedSet> | undefined, oldState: Readonly<ReusableBuilderState> | undefined) {
return oldState && !oldState.referencedMap === !newReferencedMap;
}
@@ -258,7 +258,7 @@ namespace ts {
/**
* Gets the files affected by the path from the program
*/
export function getFilesAffectedBy(state: BuilderState, programOfThisState: Program, path: Path, cancellationToken: CancellationToken | undefined, computeHash: ComputeHash, cacheToUpdateSignature?: Map<Path, string>, exportedModulesMapCache?: ComputingExportedModulesMap): readonly SourceFile[] {
export function getFilesAffectedBy(state: BuilderState, programOfThisState: Program, path: Path, cancellationToken: CancellationToken | undefined, computeHash: ComputeHash, cacheToUpdateSignature?: ESMap<Path, string>, exportedModulesMapCache?: ComputingExportedModulesMap): readonly SourceFile[] {
// Since the operation could be cancelled, the signatures are always stored in the cache
// They will be committed once it is safe to use them
// eg when calling this api from tsserver, if there is no cancellation of the operation
@@ -285,7 +285,7 @@ namespace ts {
* Updates the signatures from the cache into state's fileinfo signatures
* This should be called whenever it is safe to commit the state of the builder
*/
export function updateSignaturesFromCache(state: BuilderState, signatureCache: Map<Path, string>) {
export function updateSignaturesFromCache(state: BuilderState, signatureCache: ESMap<Path, string>) {
signatureCache.forEach((signature, path) => updateSignatureOfFile(state, signature, path));
}
@@ -297,7 +297,7 @@ namespace ts {
/**
* Returns if the shape of the signature has changed since last emit
*/
export function updateShapeSignature(state: Readonly<BuilderState>, programOfThisState: Program, sourceFile: SourceFile, cacheToUpdateSignature: Map<Path, string>, cancellationToken: CancellationToken | undefined, computeHash: ComputeHash, exportedModulesMapCache?: ComputingExportedModulesMap) {
export function updateShapeSignature(state: Readonly<BuilderState>, programOfThisState: Program, sourceFile: SourceFile, cacheToUpdateSignature: ESMap<Path, string>, cancellationToken: CancellationToken | undefined, computeHash: ComputeHash, exportedModulesMapCache?: ComputingExportedModulesMap) {
Debug.assert(!!sourceFile);
Debug.assert(!exportedModulesMapCache || !!state.exportedModulesMap, "Compute visible to outside map only if visibleToOutsideReferencedMap present in the state");
@@ -518,7 +518,7 @@ namespace ts {
/**
* When program emits modular code, gets the files affected by the sourceFile whose shape has changed
*/
function getFilesAffectedByUpdatedShapeWhenModuleEmit(state: BuilderState, programOfThisState: Program, sourceFileWithUpdatedShape: SourceFile, cacheToUpdateSignature: Map<Path, string>, cancellationToken: CancellationToken | undefined, computeHash: ComputeHash | undefined, exportedModulesMapCache: ComputingExportedModulesMap | undefined) {
function getFilesAffectedByUpdatedShapeWhenModuleEmit(state: BuilderState, programOfThisState: Program, sourceFileWithUpdatedShape: SourceFile, cacheToUpdateSignature: ESMap<Path, string>, cancellationToken: CancellationToken | undefined, computeHash: ComputeHash | undefined, exportedModulesMapCache: ComputingExportedModulesMap | undefined) {
if (isFileAffectingGlobalScope(sourceFileWithUpdatedShape)) {
return getAllFilesExcludingDefaultLibraryFile(state, programOfThisState, sourceFileWithUpdatedShape);
}
+168 -97
View File
@@ -134,7 +134,7 @@ namespace ts {
EmptyObjectFacts = All,
}
const typeofEQFacts: ReadonlyMap<string, TypeFacts> = new Map(getEntries({
const typeofEQFacts: ReadonlyESMap<string, TypeFacts> = new Map(getEntries({
string: TypeFacts.TypeofEQString,
number: TypeFacts.TypeofEQNumber,
bigint: TypeFacts.TypeofEQBigInt,
@@ -145,7 +145,7 @@ namespace ts {
function: TypeFacts.TypeofEQFunction
}));
const typeofNEFacts: ReadonlyMap<string, TypeFacts> = new Map(getEntries({
const typeofNEFacts: ReadonlyESMap<string, TypeFacts> = new Map(getEntries({
string: TypeFacts.TypeofNEString,
number: TypeFacts.TypeofNENumber,
bigint: TypeFacts.TypeofNEBigInt,
@@ -826,10 +826,10 @@ namespace ts {
readonly firstFile: SourceFile;
readonly secondFile: SourceFile;
/** Key is symbol name. */
readonly conflictingSymbols: Map<string, DuplicateInfoForSymbol>;
readonly conflictingSymbols: ESMap<string, DuplicateInfoForSymbol>;
}
/** Key is "/path/to/a.ts|/path/to/b.ts". */
let amalgamatedDuplicates: Map<string, DuplicateInfoForFiles> | undefined;
let amalgamatedDuplicates: ESMap<string, DuplicateInfoForFiles> | undefined;
const reverseMappedCache = new Map<string, Type | undefined>();
let inInferTypeForHomomorphicMappedType = false;
let ambientModulesCache: Symbol[] | undefined;
@@ -839,7 +839,7 @@ namespace ts {
* This is only used if there is no exact match.
*/
let patternAmbientModules: PatternAmbientModule[];
let patternAmbientModuleAugmentations: Map<string, Symbol> | undefined;
let patternAmbientModuleAugmentations: ESMap<string, Symbol> | undefined;
let globalObjectType: ObjectType;
let globalFunctionType: ObjectType;
@@ -907,7 +907,7 @@ namespace ts {
const mergedSymbols: Symbol[] = [];
const symbolLinks: SymbolLinks[] = [];
const nodeLinks: NodeLinks[] = [];
const flowLoopCaches: Map<string, Type>[] = [];
const flowLoopCaches: ESMap<string, Type>[] = [];
const flowLoopNodes: FlowNode[] = [];
const flowLoopKeys: string[] = [];
const flowLoopTypes: Type[][] = [];
@@ -923,7 +923,7 @@ namespace ts {
const diagnostics = createDiagnosticCollection();
const suggestionDiagnostics = createDiagnosticCollection();
const typeofTypesByName: ReadonlyMap<string, Type> = new Map(getEntries({
const typeofTypesByName: ReadonlyESMap<string, Type> = new Map(getEntries({
string: stringType,
number: numberType,
bigint: bigintType,
@@ -3753,7 +3753,7 @@ namespace ts {
return rightMeaning === SymbolFlags.Value ? SymbolFlags.Value : SymbolFlags.Namespace;
}
function getAccessibleSymbolChain(symbol: Symbol | undefined, enclosingDeclaration: Node | undefined, meaning: SymbolFlags, useOnlyExternalAliasing: boolean, visitedSymbolTablesMap: Map<SymbolId, SymbolTable[]> = new Map()): Symbol[] | undefined {
function getAccessibleSymbolChain(symbol: Symbol | undefined, enclosingDeclaration: Node | undefined, meaning: SymbolFlags, useOnlyExternalAliasing: boolean, visitedSymbolTablesMap: ESMap<SymbolId, SymbolTable[]> = new Map()): Symbol[] | undefined {
if (!(symbol && !isPropertyOrMethodDeclarationSymbol(symbol))) {
return undefined;
}
@@ -5878,7 +5878,7 @@ namespace ts {
const enclosingDeclaration = context.enclosingDeclaration!;
let results: Statement[] = [];
const visitedSymbols = new Set<number>();
let deferredPrivates: Map<SymbolId, Symbol> | undefined;
let deferredPrivates: ESMap<SymbolId, Symbol> | undefined;
const oldcontext = context;
context = {
...oldcontext,
@@ -7188,15 +7188,15 @@ namespace ts {
// State
encounteredError: boolean;
visitedTypes: Set<number> | undefined;
symbolDepth: Map<string, number> | undefined;
symbolDepth: ESMap<string, number> | undefined;
inferTypeParameters: TypeParameter[] | undefined;
approximateLength: number;
truncating?: boolean;
typeParameterSymbolList?: Set<number>;
typeParameterNames?: Map<TypeId, Identifier>;
typeParameterNames?: ESMap<TypeId, Identifier>;
typeParameterNamesByText?: Set<string>;
usedSymbolNames?: Set<string>;
remappedSymbolNames?: Map<SymbolId, string>;
remappedSymbolNames?: ESMap<SymbolId, string>;
}
function isDefaultBindingContext(location: Node) {
@@ -7827,7 +7827,7 @@ namespace ts {
return addOptionality(type, isOptional);
}
if (isPropertyDeclaration(declaration) && (noImplicitAny || isInJSFile(declaration))) {
if (isPropertyDeclaration(declaration) && !hasStaticModifier(declaration) && (noImplicitAny || isInJSFile(declaration))) {
// We have a property declaration with no type annotation or initializer, in noImplicitAny mode or a .js file.
// Use control flow analysis of this.xxx assignments in the constructor to determine the type of the property.
const constructor = findConstructorDeclaration(declaration.parent);
@@ -9783,7 +9783,7 @@ namespace ts {
const restParams = map(elementTypes, (t, i) => {
// Lookup the label from the individual tuple passed in before falling back to the signature `rest` parameter name
const tupleLabelName = !!associatedNames && getTupleElementLabel(associatedNames[i]);
const name = tupleLabelName || getParameterNameAtPosition(sig, restIndex + i);
const name = tupleLabelName || getParameterNameAtPosition(sig, restIndex + i, restType);
const flags = restType.target.elementFlags[i];
const checkFlags = flags & ElementFlags.Variable ? CheckFlags.RestParameter :
flags & ElementFlags.Optional ? CheckFlags.OptionalParameter : 0;
@@ -10255,22 +10255,32 @@ namespace ts {
// Otherwise, for type string create a string index signature.
if (isTypeUsableAsPropertyName(t)) {
const propName = getPropertyNameFromType(t);
const modifiersProp = getPropertyOfType(modifiersType, propName);
const isOptional = !!(templateModifiers & MappedTypeModifiers.IncludeOptional ||
!(templateModifiers & MappedTypeModifiers.ExcludeOptional) && modifiersProp && modifiersProp.flags & SymbolFlags.Optional);
const isReadonly = !!(templateModifiers & MappedTypeModifiers.IncludeReadonly ||
!(templateModifiers & MappedTypeModifiers.ExcludeReadonly) && modifiersProp && isReadonlySymbol(modifiersProp));
const stripOptional = strictNullChecks && !isOptional && modifiersProp && modifiersProp.flags & SymbolFlags.Optional;
const prop = <MappedSymbol>createSymbol(SymbolFlags.Property | (isOptional ? SymbolFlags.Optional : 0), propName,
CheckFlags.Mapped | (isReadonly ? CheckFlags.Readonly : 0) | (stripOptional ? CheckFlags.StripOptional : 0));
prop.mappedType = type;
prop.mapper = templateMapper;
if (modifiersProp) {
prop.syntheticOrigin = modifiersProp;
prop.declarations = modifiersProp.declarations;
// String enum members from separate enums with identical values
// are distinct types with the same property name. Make the resulting
// property symbol's name type be the union of those enum member types.
const existingProp = members.get(propName) as MappedSymbol | undefined;
if (existingProp) {
existingProp.nameType = getUnionType([existingProp.nameType!, t]);
existingProp.mapper = appendTypeMapping(type.mapper, typeParameter, existingProp.nameType);
}
else {
const modifiersProp = getPropertyOfType(modifiersType, propName);
const isOptional = !!(templateModifiers & MappedTypeModifiers.IncludeOptional ||
!(templateModifiers & MappedTypeModifiers.ExcludeOptional) && modifiersProp && modifiersProp.flags & SymbolFlags.Optional);
const isReadonly = !!(templateModifiers & MappedTypeModifiers.IncludeReadonly ||
!(templateModifiers & MappedTypeModifiers.ExcludeReadonly) && modifiersProp && isReadonlySymbol(modifiersProp));
const stripOptional = strictNullChecks && !isOptional && modifiersProp && modifiersProp.flags & SymbolFlags.Optional;
const prop = <MappedSymbol>createSymbol(SymbolFlags.Property | (isOptional ? SymbolFlags.Optional : 0), propName,
CheckFlags.Mapped | (isReadonly ? CheckFlags.Readonly : 0) | (stripOptional ? CheckFlags.StripOptional : 0));
prop.mappedType = type;
if (modifiersProp) {
prop.syntheticOrigin = modifiersProp;
prop.declarations = modifiersProp.declarations;
}
prop.nameType = t;
prop.mapper = templateMapper;
members.set(propName, prop);
}
prop.nameType = t;
members.set(propName, prop);
}
else if (t.flags & (TypeFlags.Any | TypeFlags.String | TypeFlags.Number | TypeFlags.Enum)) {
const propType = instantiateType(templateType, templateMapper);
@@ -10821,7 +10831,7 @@ namespace ts {
function createUnionOrIntersectionProperty(containingType: UnionOrIntersectionType, name: __String): Symbol | undefined {
let singleProp: Symbol | undefined;
let propSet: Map<SymbolId, Symbol> | undefined;
let propSet: ESMap<SymbolId, Symbol> | undefined;
let indexTypes: Type[] | undefined;
const isUnion = containingType.flags & TypeFlags.Union;
// Flags we want to propagate to the result if they exist in all source symbols
@@ -12882,7 +12892,7 @@ namespace ts {
return links.resolvedType;
}
function addTypeToIntersection(typeSet: Map<string, Type>, includes: TypeFlags, type: Type) {
function addTypeToIntersection(typeSet: ESMap<string, Type>, includes: TypeFlags, type: Type) {
const flags = type.flags;
if (flags & TypeFlags.Intersection) {
return addTypesToIntersection(typeSet, includes, (<IntersectionType>type).types);
@@ -12912,7 +12922,7 @@ namespace ts {
// Add the given types to the given type set. Order is preserved, freshness is removed from literal
// types, duplicates are removed, and nested types of the given kind are flattened into the set.
function addTypesToIntersection(typeSet: Map<string, Type>, includes: TypeFlags, types: readonly Type[]) {
function addTypesToIntersection(typeSet: ESMap<string, Type>, includes: TypeFlags, types: readonly Type[]) {
for (const type of types) {
includes = addTypeToIntersection(typeSet, includes, getRegularTypeOfLiteralType(type));
}
@@ -13029,7 +13039,7 @@ namespace ts {
// Also, unlike union types, the order of the constituent types is preserved in order that overload resolution
// for intersections of types with signatures can be deterministic.
function getIntersectionType(types: readonly Type[], aliasSymbol?: Symbol, aliasTypeArguments?: readonly Type[]): Type {
const typeMembershipMap: Map<string, Type> = new Map();
const typeMembershipMap: ESMap<string, Type> = new Map();
const includes = addTypesToIntersection(typeMembershipMap, 0, types);
const typeSet: Type[] = arrayFrom(typeMembershipMap.values());
// An intersection type is considered empty if it contains
@@ -13276,13 +13286,19 @@ namespace ts {
undefined;
}
function getPropertyTypeForIndexType(originalObjectType: Type, objectType: Type, indexType: Type, fullIndexType: Type, suppressNoImplicitAnyError: boolean, accessNode: ElementAccessExpression | IndexedAccessTypeNode | PropertyName | BindingName | SyntheticExpression | undefined, accessFlags: AccessFlags) {
function isUncalledFunctionReference(node: Node, symbol: Symbol) {
return !(symbol.flags & (SymbolFlags.Function | SymbolFlags.Method))
|| !isCallLikeExpression(findAncestor(node, n => !isAccessExpression(n)) || node.parent)
&& every(symbol.declarations, d => !isFunctionLike(d) || !!(d.flags & NodeFlags.Deprecated));
}
function getPropertyTypeForIndexType(originalObjectType: Type, objectType: Type, indexType: Type, fullIndexType: Type, suppressNoImplicitAnyError: boolean, accessNode: ElementAccessExpression | IndexedAccessTypeNode | PropertyName | BindingName | SyntheticExpression | undefined, accessFlags: AccessFlags, reportDeprecated?: boolean) {
const accessExpression = accessNode && accessNode.kind === SyntaxKind.ElementAccessExpression ? accessNode : undefined;
const propName = accessNode && isPrivateIdentifier(accessNode) ? undefined : getPropertyNameFromIndex(indexType, accessNode);
if (propName !== undefined) {
const prop = getPropertyOfType(objectType, propName);
if (prop) {
if (accessNode && prop.flags & SymbolFlags.Deprecated) {
if (reportDeprecated && accessNode && prop.valueDeclaration?.flags & NodeFlags.Deprecated && isUncalledFunctionReference(accessNode, prop)) {
const deprecatedNode = accessExpression?.argumentExpression ?? (isIndexedAccessTypeNode(accessNode) ? accessNode.indexType : accessNode);
errorOrSuggestion(/* isError */ false, deprecatedNode, Diagnostics._0_is_deprecated, propName as string);
}
@@ -13652,7 +13668,7 @@ namespace ts {
}
return accessFlags & AccessFlags.Writing ? getIntersectionType(propTypes, aliasSymbol, aliasTypeArguments) : getUnionType(propTypes, UnionReduction.Literal, aliasSymbol, aliasTypeArguments);
}
return getPropertyTypeForIndexType(objectType, apparentObjectType, indexType, indexType, /* supressNoImplicitAnyError */ false, accessNode, accessFlags | AccessFlags.CacheSymbol);
return getPropertyTypeForIndexType(objectType, apparentObjectType, indexType, indexType, /* supressNoImplicitAnyError */ false, accessNode, accessFlags | AccessFlags.CacheSymbol, /* reportDeprecated */ true);
}
function getTypeFromIndexedAccessTypeNode(node: IndexedAccessTypeNode) {
@@ -15069,7 +15085,7 @@ namespace ts {
function checkTypeRelatedToAndOptionallyElaborate(
source: Type,
target: Type,
relation: Map<string, RelationComparisonResult>,
relation: ESMap<string, RelationComparisonResult>,
errorNode: Node | undefined,
expr: Expression | undefined,
headMessage: DiagnosticMessage | undefined,
@@ -15091,7 +15107,7 @@ namespace ts {
node: Expression | undefined,
source: Type,
target: Type,
relation: Map<string, RelationComparisonResult>,
relation: ESMap<string, RelationComparisonResult>,
headMessage: DiagnosticMessage | undefined,
containingMessageChain: (() => DiagnosticMessageChain | undefined) | undefined,
errorOutputContainer: { errors?: Diagnostic[], skipLogging?: boolean } | undefined
@@ -15128,7 +15144,7 @@ namespace ts {
node: Expression,
source: Type,
target: Type,
relation: Map<string, RelationComparisonResult>,
relation: ESMap<string, RelationComparisonResult>,
headMessage: DiagnosticMessage | undefined,
containingMessageChain: (() => DiagnosticMessageChain | undefined) | undefined,
errorOutputContainer: { errors?: Diagnostic[], skipLogging?: boolean } | undefined
@@ -15157,7 +15173,7 @@ namespace ts {
node: ArrowFunction,
source: Type,
target: Type,
relation: Map<string, RelationComparisonResult>,
relation: ESMap<string, RelationComparisonResult>,
containingMessageChain: (() => DiagnosticMessageChain | undefined) | undefined,
errorOutputContainer: { errors?: Diagnostic[], skipLogging?: boolean } | undefined
): boolean {
@@ -15244,7 +15260,7 @@ namespace ts {
iterator: ElaborationIterator,
source: Type,
target: Type,
relation: Map<string, RelationComparisonResult>,
relation: ESMap<string, RelationComparisonResult>,
containingMessageChain: (() => DiagnosticMessageChain | undefined) | undefined,
errorOutputContainer: { errors?: Diagnostic[], skipLogging?: boolean } | undefined
) {
@@ -15358,7 +15374,7 @@ namespace ts {
node: JsxAttributes,
source: Type,
target: Type,
relation: Map<string, RelationComparisonResult>,
relation: ESMap<string, RelationComparisonResult>,
containingMessageChain: (() => DiagnosticMessageChain | undefined) | undefined,
errorOutputContainer: { errors?: Diagnostic[], skipLogging?: boolean } | undefined
) {
@@ -15459,7 +15475,7 @@ namespace ts {
node: ArrayLiteralExpression,
source: Type,
target: Type,
relation: Map<string, RelationComparisonResult>,
relation: ESMap<string, RelationComparisonResult>,
containingMessageChain: (() => DiagnosticMessageChain | undefined) | undefined,
errorOutputContainer: { errors?: Diagnostic[], skipLogging?: boolean } | undefined
) {
@@ -15512,7 +15528,7 @@ namespace ts {
node: ObjectLiteralExpression,
source: Type,
target: Type,
relation: Map<string, RelationComparisonResult>,
relation: ESMap<string, RelationComparisonResult>,
containingMessageChain: (() => DiagnosticMessageChain | undefined) | undefined,
errorOutputContainer: { errors?: Diagnostic[], skipLogging?: boolean } | undefined
) {
@@ -15803,7 +15819,7 @@ namespace ts {
return true;
}
function isSimpleTypeRelatedTo(source: Type, target: Type, relation: Map<string, RelationComparisonResult>, errorReporter?: ErrorReporter) {
function isSimpleTypeRelatedTo(source: Type, target: Type, relation: ESMap<string, RelationComparisonResult>, errorReporter?: ErrorReporter) {
const s = source.flags;
const t = target.flags;
if (t & TypeFlags.AnyOrUnknown || s & TypeFlags.Never || source === wildcardType) return true;
@@ -15840,7 +15856,7 @@ namespace ts {
return false;
}
function isTypeRelatedTo(source: Type, target: Type, relation: Map<string, RelationComparisonResult>) {
function isTypeRelatedTo(source: Type, target: Type, relation: ESMap<string, RelationComparisonResult>) {
if (isFreshLiteralType(source)) {
source = (<FreshableType>source).regularType;
}
@@ -15903,7 +15919,7 @@ namespace ts {
function checkTypeRelatedTo(
source: Type,
target: Type,
relation: Map<string, RelationComparisonResult>,
relation: ESMap<string, RelationComparisonResult>,
errorNode: Node | undefined,
headMessage?: DiagnosticMessage,
containingMessageChain?: () => DiagnosticMessageChain | undefined,
@@ -16122,6 +16138,7 @@ namespace ts {
if (isLiteralType(source) && !typeCouldHaveTopLevelSingletonTypes(target)) {
generalizedSource = getBaseTypeOfLiteralType(source);
Debug.assert(!isTypeAssignableTo(generalizedSource, target), "generalized source shouldn't be assignable");
generalizedSourceType = getTypeNameForErrorDisplay(generalizedSource);
}
@@ -17264,7 +17281,11 @@ namespace ts {
result &= signaturesRelatedTo(source, type, SignatureKind.Construct, /*reportStructuralErrors*/ false);
if (result) {
result &= indexTypesRelatedTo(source, type, IndexKind.String, /*sourceIsPrimitive*/ false, /*reportStructuralErrors*/ false, IntersectionState.None);
if (result) {
// Comparing numeric index types when both `source` and `type` are tuples is unnecessary as the
// element types should be sufficiently covered by `propertiesRelatedTo`. It also causes problems
// with index type assignability as the types for the excluded discriminants are still included
// in the index type.
if (result && !(isTupleType(source) && isTupleType(type))) {
result &= indexTypesRelatedTo(source, type, IndexKind.Number, /*sourceIsPrimitive*/ false, /*reportStructuralErrors*/ false, IntersectionState.None);
}
}
@@ -17489,6 +17510,7 @@ namespace ts {
for (let i = 0; i < maxArity; i++) {
const targetFlags = i < targetArity ? target.target.elementFlags[i] : targetRestFlag;
const sourceFlags = isTupleType(source) && i < sourceArity ? source.target.elementFlags[i] : sourceRestFlag;
let canExcludeDiscriminants = !!excludedProperties;
if (sourceFlags && targetFlags) {
if (targetFlags & ElementFlags.Variadic && !(sourceFlags & ElementFlags.Variadic) ||
(sourceFlags & ElementFlags.Variadic && !(targetFlags & ElementFlags.Variable))) {
@@ -17505,6 +17527,15 @@ namespace ts {
return Ternary.False;
}
}
// We can only exclude discriminant properties if we have not yet encountered a variable-length element.
if (canExcludeDiscriminants) {
if (sourceFlags & ElementFlags.Variable || targetFlags & ElementFlags.Variable) {
canExcludeDiscriminants = false;
}
if (canExcludeDiscriminants && excludedProperties?.has(("" + i) as __String)) {
continue;
}
}
const sourceType = getTypeArguments(source)[Math.min(i, sourceArity - 1)];
const targetType = getTypeArguments(target)[Math.min(i, targetArity - 1)];
const targetCheckType = sourceFlags & ElementFlags.Variadic && targetFlags & ElementFlags.Rest ? createArrayType(targetType) : targetType;
@@ -17825,6 +17856,13 @@ namespace ts {
}
function typeCouldHaveTopLevelSingletonTypes(type: Type): boolean {
// Okay, yes, 'boolean' is a union of 'true | false', but that's not useful
// in error reporting scenarios. If you need to use this function but that detail matters,
// feel free to add a flag.
if (type.flags & TypeFlags.Boolean) {
return false;
}
if (type.flags & TypeFlags.UnionOrIntersection) {
return !!forEach((type as IntersectionType).types, typeCouldHaveTopLevelSingletonTypes);
}
@@ -18025,7 +18063,7 @@ namespace ts {
* To improve caching, the relation key for two generic types uses the target's id plus ids of the type parameters.
* For other cases, the types ids are used.
*/
function getRelationKey(source: Type, target: Type, intersectionState: IntersectionState, relation: Map<string, RelationComparisonResult>) {
function getRelationKey(source: Type, target: Type, intersectionState: IntersectionState, relation: ESMap<string, RelationComparisonResult>) {
if (relation === identityRelation && source.id > target.id) {
const temp = source;
source = target;
@@ -18454,7 +18492,7 @@ namespace ts {
}
function getEndLengthOfType(type: Type) {
return isTupleType(type) ? getTypeReferenceArity(type) - findLastIndex(type.target.elementFlags, f => !!(f & ElementFlags.Variable)) - 1 : 0;
return isTupleType(type) ? getTypeReferenceArity(type) - findLastIndex(type.target.elementFlags, f => !(f & ElementFlags.Required)) - 1 : 0;
}
function getElementTypeOfSliceOfTupleType(type: TupleTypeReference, index: number, endSkipCount = 0, writing = false) {
@@ -19209,7 +19247,7 @@ namespace ts {
function inferTypes(inferences: InferenceInfo[], originalSource: Type, originalTarget: Type, priority: InferencePriority = 0, contravariant = false) {
let symbolOrTypeStack: (Symbol | Type)[];
let visited: Map<string, number>;
let visited: ESMap<string, number>;
let bivariant = false;
let propagationType: Type;
let inferencePriority = InferencePriority.MaxValue;
@@ -20572,7 +20610,7 @@ namespace ts {
}
function createFlowType(type: Type, incomplete: boolean): FlowType {
return incomplete ? { flags: 0, type } : type;
return incomplete ? { flags: 0, type: type.flags & TypeFlags.Never ? silentNeverType : type } : type;
}
// An evolving array type tracks the element types that have so far been seen in an
@@ -21160,9 +21198,7 @@ namespace ts {
if (narrowedType === nonEvolvingType) {
return flowType;
}
const incomplete = isIncomplete(flowType);
const resultType = incomplete && narrowedType.flags & TypeFlags.Never ? silentNeverType : narrowedType;
return createFlowType(resultType, incomplete);
return createFlowType(narrowedType, isIncomplete(flowType));
}
function getTypeAtSwitchClause(flow: FlowSwitchClause): FlowType {
@@ -21500,15 +21536,11 @@ namespace ts {
assumeTrue ? TypeFacts.EQUndefined : TypeFacts.NEUndefined;
return getTypeWithFacts(type, facts);
}
if (type.flags & TypeFlags.NotUnionOrUnit) {
return type;
}
if (assumeTrue) {
const filterFn: (t: Type) => boolean = operator === SyntaxKind.EqualsEqualsToken ?
(t => areTypesComparable(t, valueType) || isCoercibleUnderDoubleEquals(t, valueType)) :
t => areTypesComparable(t, valueType);
const narrowedType = filterType(type, filterFn);
return narrowedType.flags & TypeFlags.Never ? type : replacePrimitivesWithLiterals(narrowedType, valueType);
return replacePrimitivesWithLiterals(filterType(type, filterFn), valueType);
}
if (isUnitType(valueType)) {
const regularType = getRegularTypeOfLiteralType(valueType);
@@ -21784,6 +21816,12 @@ namespace ts {
emptyObjectType;
}
// We can't narrow a union based off instanceof without negated types see #31576 for more info
if (!assumeTrue && rightType.flags & TypeFlags.Union) {
const nonConstructorTypeInUnion = find((<UnionType>rightType).types, (t) => !isConstructorType(t));
if (!nonConstructorTypeInUnion) return type;
}
return getNarrowedType(type, targetType, assumeTrue, isTypeDerivedFrom);
}
@@ -22045,9 +22083,8 @@ namespace ts {
const localOrExportSymbol = getExportSymbolOfValueSymbolIfExported(symbol);
let declaration: Declaration | undefined = localOrExportSymbol.valueDeclaration;
const target = (symbol.flags & SymbolFlags.Alias ? resolveAlias(symbol) : symbol);
if (target.flags & SymbolFlags.Deprecated) {
errorOrSuggestion(/* isError */ false, node, Diagnostics._0_is_deprecated, node.escapedText as string);
if (declaration?.flags & NodeFlags.Deprecated && isUncalledFunctionReference(node.parent, localOrExportSymbol)) {
errorOrSuggestion(/* isError */ false, node, Diagnostics._0_is_deprecated, node.escapedText as string);;
}
if (localOrExportSymbol.flags & SymbolFlags.Class) {
// Due to the emit for class decorators, any reference to the class from inside of the class body
@@ -23410,7 +23447,7 @@ namespace ts {
return getContextualTypeForArgument(<CallExpression | NewExpression>parent, node);
case SyntaxKind.TypeAssertionExpression:
case SyntaxKind.AsExpression:
return isConstTypeReference((<AssertionExpression>parent).type) ? undefined : getTypeFromTypeNode((<AssertionExpression>parent).type);
return isConstTypeReference((<AssertionExpression>parent).type) ? tryFindWhenConstTypeReference(<AssertionExpression>parent) : getTypeFromTypeNode((<AssertionExpression>parent).type);
case SyntaxKind.BinaryExpression:
return getContextualTypeForBinaryOperand(node, contextFlags);
case SyntaxKind.PropertyAssignment:
@@ -23443,6 +23480,13 @@ namespace ts {
return getContextualJsxElementAttributesType(<JsxOpeningLikeElement>parent, contextFlags);
}
return undefined;
function tryFindWhenConstTypeReference(node: Expression) {
if(isCallLikeExpression(node.parent)){
return getContextualTypeForArgument(node.parent, node);
}
return undefined;
}
}
function getInferenceContext(node: Node) {
@@ -23826,10 +23870,15 @@ namespace ts {
return links.resolvedType;
}
function isSymbolWithNumericName(symbol: Symbol) {
const firstDecl = symbol.declarations?.[0];
return isNumericLiteralName(symbol.escapedName) || (firstDecl && isNamedDeclaration(firstDecl) && isNumericName(firstDecl.name));
}
function getObjectLiteralIndexInfo(node: ObjectLiteralExpression, offset: number, properties: Symbol[], kind: IndexKind): IndexInfo {
const propTypes: Type[] = [];
for (let i = offset; i < properties.length; i++) {
if (kind === IndexKind.String || isNumericName(node.properties[i].name!)) {
if (kind === IndexKind.String || isSymbolWithNumericName(properties[i])) {
propTypes.push(getTypeOfSymbol(properties[i]));
}
}
@@ -23882,8 +23931,7 @@ namespace ts {
}
let offset = 0;
for (let i = 0; i < node.properties.length; i++) {
const memberDecl = node.properties[i];
for (const memberDecl of node.properties) {
let member = getSymbolOfNode(memberDecl);
const computedNameType = memberDecl.name && memberDecl.name.kind === SyntaxKind.ComputedPropertyName && !isWellKnownSymbolSyntactically(memberDecl.name.expression) ?
checkComputedPropertyName(memberDecl.name) : undefined;
@@ -23891,7 +23939,10 @@ namespace ts {
memberDecl.kind === SyntaxKind.ShorthandPropertyAssignment ||
isObjectLiteralMethod(memberDecl)) {
let type = memberDecl.kind === SyntaxKind.PropertyAssignment ? checkPropertyAssignment(memberDecl, checkMode) :
memberDecl.kind === SyntaxKind.ShorthandPropertyAssignment ? checkExpressionForMutableLocation(memberDecl.name, checkMode) :
// avoid resolving the left side of the ShorthandPropertyAssignment outside of the destructuring
// for error recovery purposes. For example, if a user wrote `{ a = 100 }` instead of `{ a: 100 }`.
// we don't want to say "could not find 'a'".
memberDecl.kind === SyntaxKind.ShorthandPropertyAssignment ? checkExpressionForMutableLocation(!inDestructuringPattern && memberDecl.objectAssignmentInitializer ? memberDecl.objectAssignmentInitializer : memberDecl.name, checkMode) :
checkObjectLiteralMethod(memberDecl, checkMode);
if (isInJavascript) {
const jsDocType = getTypeForDeclarationFromJSDocComment(memberDecl);
@@ -23967,7 +24018,7 @@ namespace ts {
checkSpreadPropOverrides(type, allPropertiesTable, memberDecl);
}
spread = getSpreadType(spread, type, node.symbol, objectFlags, inConstContext);
offset = i + 1;
offset = propertiesArray.length;
continue;
}
else {
@@ -24587,6 +24638,7 @@ namespace ts {
if (isNodeOpeningLikeElement) {
const jsxOpeningLikeNode = node as JsxOpeningLikeElement;
const sig = getResolvedSignature(jsxOpeningLikeNode);
checkDeprecatedSignature(sig, node);
checkJsxReturnAssignableToAppropriateBound(getJsxReferenceKind(jsxOpeningLikeNode), getReturnTypeOfSignature(sig), jsxOpeningLikeNode);
}
}
@@ -25015,7 +25067,7 @@ namespace ts {
propType = indexInfo.type;
}
else {
if (prop.flags & SymbolFlags.Deprecated) {
if (prop.valueDeclaration?.flags & NodeFlags.Deprecated && isUncalledFunctionReference(node, prop)) {
errorOrSuggestion(/* isError */ false, right, Diagnostics._0_is_deprecated, right.escapedText as string);
}
@@ -25771,13 +25823,6 @@ namespace ts {
}
}
const thisType = getThisTypeOfSignature(signature);
if (thisType) {
const thisArgumentNode = getThisArgumentOfCall(node);
const thisArgumentType = thisArgumentNode ? checkExpression(thisArgumentNode) : voidType;
inferTypes(context.inferences, thisArgumentType, thisType);
}
const restType = getNonArrayRestType(signature);
const argCount = restType ? Math.min(getParameterCount(signature) - 1, args.length) : args.length;
if (restType && restType.flags & TypeFlags.TypeParameter) {
@@ -25786,6 +25831,14 @@ namespace ts {
info.impliedArity = findIndex(args, isSpreadArgument, argCount) < 0 ? args.length - argCount : undefined;
}
}
const thisType = getThisTypeOfSignature(signature);
if (thisType) {
const thisArgumentNode = getThisArgumentOfCall(node);
const thisArgumentType = thisArgumentNode ? checkExpression(thisArgumentNode) : voidType;
inferTypes(context.inferences, thisArgumentType, thisType);
}
for (let i = 0; i < argCount; i++) {
const arg = args[i];
if (arg.kind !== SyntaxKind.OmittedExpression) {
@@ -25901,7 +25954,7 @@ namespace ts {
function checkApplicableSignatureForJsxOpeningLikeElement(
node: JsxOpeningLikeElement,
signature: Signature,
relation: Map<string, RelationComparisonResult>,
relation: ESMap<string, RelationComparisonResult>,
checkMode: CheckMode,
reportErrors: boolean,
containingMessageChain: (() => DiagnosticMessageChain | undefined) | undefined,
@@ -26001,7 +26054,7 @@ namespace ts {
node: CallLikeExpression,
args: readonly Expression[],
signature: Signature,
relation: Map<string, RelationComparisonResult>,
relation: ESMap<string, RelationComparisonResult>,
checkMode: CheckMode,
reportErrors: boolean,
containingMessageChain: (() => DiagnosticMessageChain | undefined) | undefined,
@@ -26525,7 +26578,7 @@ namespace ts {
return getCandidateForOverloadFailure(node, candidates, args, !!candidatesOutArray);
function chooseOverload(candidates: Signature[], relation: Map<string, RelationComparisonResult>, signatureHelpTrailingComma = false) {
function chooseOverload(candidates: Signature[], relation: ESMap<string, RelationComparisonResult>, signatureHelpTrailingComma = false) {
candidatesForArgumentError = undefined;
candidateForArgumentArityError = undefined;
candidateForTypeArgumentError = undefined;
@@ -27406,6 +27459,8 @@ namespace ts {
return nonInferrableType;
}
checkDeprecatedSignature(signature, node);
if (node.expression.kind === SyntaxKind.SuperKeyword) {
return voidType;
}
@@ -27465,6 +27520,12 @@ namespace ts {
return returnType;
}
function checkDeprecatedSignature(signature: Signature, node: Node) {
if (signature.declaration && signature.declaration.flags & NodeFlags.Deprecated) {
errorOrSuggestion(/*isError*/ false, node, Diagnostics._0_is_deprecated, signatureToString(signature));
}
}
function isSymbolOrSymbolForCall(node: Node) {
if (!isCallExpression(node)) return false;
let left = node.expression;
@@ -27573,7 +27634,9 @@ namespace ts {
if (languageVersion < ScriptTarget.ES2015) {
checkExternalEmitHelpers(node, ExternalEmitHelpers.MakeTemplateObject);
}
return getReturnTypeOfSignature(getResolvedSignature(node));
const signature = getResolvedSignature(node);
checkDeprecatedSignature(signature, node);
return getReturnTypeOfSignature(signature);
}
function checkAssertion(node: AssertionExpression) {
@@ -27700,13 +27763,13 @@ namespace ts {
return d.name.escapedText;
}
function getParameterNameAtPosition(signature: Signature, pos: number) {
function getParameterNameAtPosition(signature: Signature, pos: number, overrideRestType?: Type) {
const paramCount = signature.parameters.length - (signatureHasRestParameter(signature) ? 1 : 0);
if (pos < paramCount) {
return signature.parameters[pos].escapedName;
}
const restParameter = signature.parameters[paramCount] || unknownSymbol;
const restType = getTypeOfSymbol(restParameter);
const restType = overrideRestType || getTypeOfSymbol(restParameter);
if (isTupleType(restType)) {
const associatedNames = (<TupleType>(<TypeReference>restType).target).labeledElementDeclarations;
const index = pos - paramCount;
@@ -30849,7 +30912,7 @@ namespace ts {
}
const symbol = getNodeLinks(node).resolvedSymbol;
if (symbol) {
if (symbol.flags & SymbolFlags.Deprecated) {
if (every(symbol.declarations, d => !isTypeDeclaration(d) || !!(d.flags & NodeFlags.Deprecated))) {
const diagLocation = isTypeReferenceNode(node) && isQualifiedName(node.typeName) ? node.typeName.right : node;
errorOrSuggestion(/* isError */ false, diagLocation, Diagnostics._0_is_deprecated, symbol.escapedName as string);
}
@@ -31701,6 +31764,7 @@ namespace ts {
/** Check a decorator */
function checkDecorator(node: Decorator): void {
const signature = getResolvedSignature(node);
checkDeprecatedSignature(signature, node);
const returnType = getReturnTypeOfSignature(signature);
if (returnType.flags & TypeFlags.Any) {
return;
@@ -32265,7 +32329,7 @@ namespace ts {
return !(getMergedSymbol(typeParameter.symbol).isReferenced! & SymbolFlags.TypeParameter) && !isIdentifierThatStartsWithUnderscore(typeParameter.name);
}
function addToGroup<K, V>(map: Map<string, [K, V[]]>, key: K, value: V, getKey: (key: K) => number | string): void {
function addToGroup<K, V>(map: ESMap<string, [K, V[]]>, key: K, value: V, getKey: (key: K) => number | string): void {
const keyString = String(getKey(key));
const group = map.get(keyString);
if (group) {
@@ -35194,7 +35258,9 @@ namespace ts {
}
}
if (isImportSpecifier(node) && target.flags & SymbolFlags.Deprecated) {
if (isImportSpecifier(node) &&
(target.valueDeclaration && target.valueDeclaration.flags & NodeFlags.Deprecated
|| every(target.declarations, d => !!(d.flags & NodeFlags.Deprecated)))) {
errorOrSuggestion(/* isError */ false, node.name, Diagnostics._0_is_deprecated, symbol.escapedName as string);
}
}
@@ -36057,16 +36123,19 @@ namespace ts {
function isTypeDeclarationName(name: Node): boolean {
return name.kind === SyntaxKind.Identifier &&
isTypeDeclaration(name.parent) &&
name.parent.name === name;
getNameOfDeclaration(name.parent) === name;
}
function isTypeDeclaration(node: Node): node is TypeParameterDeclaration | ClassDeclaration | InterfaceDeclaration | TypeAliasDeclaration | EnumDeclaration | ImportClause | ImportSpecifier | ExportSpecifier {
function isTypeDeclaration(node: Node): node is TypeParameterDeclaration | ClassDeclaration | InterfaceDeclaration | TypeAliasDeclaration | JSDocTypedefTag | JSDocCallbackTag | JSDocEnumTag | EnumDeclaration | ImportClause | ImportSpecifier | ExportSpecifier {
switch (node.kind) {
case SyntaxKind.TypeParameter:
case SyntaxKind.ClassDeclaration:
case SyntaxKind.InterfaceDeclaration:
case SyntaxKind.TypeAliasDeclaration:
case SyntaxKind.EnumDeclaration:
case SyntaxKind.JSDocTypedefTag:
case SyntaxKind.JSDocCallbackTag:
case SyntaxKind.JSDocEnumTag:
return true;
case SyntaxKind.ImportClause:
return (node as ImportClause).isTypeOnly;
@@ -36971,29 +37040,31 @@ namespace ts {
}
// Resolve the symbol as a value to ensure the type can be reached at runtime during emit.
const valueSymbol = resolveEntityName(typeName, SymbolFlags.Value, /*ignoreErrors*/ true, /*dontResolveAlias*/ false, location);
const valueSymbol = resolveEntityName(typeName, SymbolFlags.Value, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, location);
const isTypeOnly = valueSymbol?.declarations?.every(isTypeOnlyImportOrExportDeclaration) || false;
const resolvedSymbol = valueSymbol && valueSymbol.flags & SymbolFlags.Alias ? resolveAlias(valueSymbol) : valueSymbol;
// Resolve the symbol as a type so that we can provide a more useful hint for the type serializer.
const typeSymbol = resolveEntityName(typeName, SymbolFlags.Type, /*ignoreErrors*/ true, /*dontResolveAlias*/ false, location);
if (valueSymbol && valueSymbol === typeSymbol) {
if (resolvedSymbol && resolvedSymbol === typeSymbol) {
const globalPromiseSymbol = getGlobalPromiseConstructorSymbol(/*reportErrors*/ false);
if (globalPromiseSymbol && valueSymbol === globalPromiseSymbol) {
if (globalPromiseSymbol && resolvedSymbol === globalPromiseSymbol) {
return TypeReferenceSerializationKind.Promise;
}
const constructorType = getTypeOfSymbol(valueSymbol);
const constructorType = getTypeOfSymbol(resolvedSymbol);
if (constructorType && isConstructorType(constructorType)) {
return TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue;
return isTypeOnly ? TypeReferenceSerializationKind.TypeWithCallSignature : TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue;
}
}
// We might not be able to resolve type symbol so use unknown type in that case (eg error case)
if (!typeSymbol) {
return TypeReferenceSerializationKind.Unknown;
return isTypeOnly ? TypeReferenceSerializationKind.ObjectType : TypeReferenceSerializationKind.Unknown;
}
const type = getDeclaredTypeOfSymbol(typeSymbol);
if (type === errorType) {
return TypeReferenceSerializationKind.Unknown;
return isTypeOnly ? TypeReferenceSerializationKind.ObjectType : TypeReferenceSerializationKind.Unknown;
}
else if (type.flags & TypeFlags.AnyOrUnknown) {
return TypeReferenceSerializationKind.ObjectType;
@@ -37156,7 +37227,7 @@ namespace ts {
// this variable and functions that use it are deliberately moved here from the outer scope
// to avoid scope pollution
const resolvedTypeReferenceDirectives = host.getResolvedTypeReferenceDirectives();
let fileToDirective: Map<string, string>;
let fileToDirective: ESMap<string, string>;
if (resolvedTypeReferenceDirectives) {
// populate reverse mapping: file path -> type reference directive that was resolved to this file
fileToDirective = new Map<string, string>();
@@ -38220,7 +38291,7 @@ namespace ts {
if (prop.kind === SyntaxKind.ShorthandPropertyAssignment && !inDestructuring && prop.objectAssignmentInitializer) {
// having objectAssignmentInitializer is only valid in ObjectAssignmentPattern
// outside of destructuring it is a syntax error
return grammarErrorOnNode(prop.equalsToken!, Diagnostics.can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment);
return grammarErrorOnNode(prop.equalsToken!, Diagnostics.Did_you_mean_to_use_a_Colon_An_can_only_follow_a_property_name_when_the_containing_object_literal_is_part_of_a_destructuring_pattern);
}
if (name.kind === SyntaxKind.PrivateIdentifier) {
+23 -23
View File
@@ -1090,8 +1090,8 @@ namespace ts {
/* @internal */
export interface OptionsNameMap {
optionsNameMap: Map<string, CommandLineOption>;
shortOptionNames: Map<string, string>;
optionsNameMap: ESMap<string, CommandLineOption>;
shortOptionNames: ESMap<string, string>;
}
/*@internal*/
@@ -1469,7 +1469,7 @@ namespace ts {
configFileName: string,
optionsToExtend: CompilerOptions,
host: ParseConfigFileHost,
extendedConfigCache?: Map<string, ExtendedConfigCacheEntry>,
extendedConfigCache?: Map<ExtendedConfigCacheEntry>,
watchOptionsToExtend?: WatchOptions,
extraFileExtensions?: readonly FileExtensionInfo[],
): ParsedCommandLine | undefined {
@@ -1562,15 +1562,15 @@ namespace ts {
optionTypeMismatchDiagnostic: Diagnostics.Watch_option_0_requires_a_value_of_type_1
};
let commandLineCompilerOptionsMapCache: Map<string, CommandLineOption>;
let commandLineCompilerOptionsMapCache: ESMap<string, CommandLineOption>;
function getCommandLineCompilerOptionsMap() {
return commandLineCompilerOptionsMapCache || (commandLineCompilerOptionsMapCache = commandLineOptionsToMap(optionDeclarations));
}
let commandLineWatchOptionsMapCache: Map<string, CommandLineOption>;
let commandLineWatchOptionsMapCache: ESMap<string, CommandLineOption>;
function getCommandLineWatchOptionsMap() {
return commandLineWatchOptionsMapCache || (commandLineWatchOptionsMapCache = commandLineOptionsToMap(optionsForWatch));
}
let commandLineTypeAcquisitionMapCache: Map<string, CommandLineOption>;
let commandLineTypeAcquisitionMapCache: ESMap<string, CommandLineOption>;
function getCommandLineTypeAcquisitionMap() {
return commandLineTypeAcquisitionMapCache || (commandLineTypeAcquisitionMapCache = commandLineOptionsToMap(typeAcquisitionDeclarations));
}
@@ -1703,13 +1703,13 @@ namespace ts {
return convertPropertyValueToJson(sourceFile.statements[0].expression, knownRootOptions);
function isRootOptionMap(knownOptions: Map<string, CommandLineOption> | undefined) {
function isRootOptionMap(knownOptions: ESMap<string, CommandLineOption> | undefined) {
return knownRootOptions && (knownRootOptions as TsConfigOnlyOption).elementOptions === knownOptions;
}
function convertObjectLiteralExpressionToJson(
node: ObjectLiteralExpression,
knownOptions: Map<string, CommandLineOption> | undefined,
knownOptions: ESMap<string, CommandLineOption> | undefined,
extraKeyDiagnostics: DidYouMeanOptionsDiagnostics | undefined,
parentOption: string | undefined
): any {
@@ -1964,7 +1964,7 @@ namespace ts {
return config;
}
function optionMapToObject(optionMap: Map<string, CompilerOptionsValue>): object {
function optionMapToObject(optionMap: ESMap<string, CompilerOptionsValue>): object {
return {
...arrayFrom(optionMap.entries()).reduce((prev, cur) => ({ ...prev, [cur[0]]: cur[1] }), {}),
};
@@ -1994,7 +1994,7 @@ namespace ts {
return _ => true;
}
function getCustomTypeMapOfCommandLineOption(optionDefinition: CommandLineOption): Map<string, string | number> | undefined {
function getCustomTypeMapOfCommandLineOption(optionDefinition: CommandLineOption): ESMap<string, string | number> | undefined {
if (optionDefinition.type === "string" || optionDefinition.type === "number" || optionDefinition.type === "boolean" || optionDefinition.type === "object") {
// this is of a type CommandLineOptionOfPrimitiveType
return undefined;
@@ -2007,7 +2007,7 @@ namespace ts {
}
}
function getNameOfCompilerOptionValue(value: CompilerOptionsValue, customTypeMap: Map<string, string | number>): string | undefined {
function getNameOfCompilerOptionValue(value: CompilerOptionsValue, customTypeMap: ESMap<string, string | number>): string | undefined {
// There is a typeMap associated with this command-line option so use it to map value back to its name
return forEachEntry(customTypeMap, (mapValue, key) => {
if (mapValue === value) {
@@ -2019,7 +2019,7 @@ namespace ts {
function serializeCompilerOptions(
options: CompilerOptions,
pathOptions?: { configFilePath: string, useCaseSensitiveFileNames: boolean }
): Map<string, CompilerOptionsValue> {
): ESMap<string, CompilerOptionsValue> {
return serializeOptionBaseObject(options, getOptionsNameMap(), pathOptions);
}
@@ -2031,7 +2031,7 @@ namespace ts {
options: OptionsBase,
{ optionsNameMap }: OptionsNameMap,
pathOptions?: { configFilePath: string, useCaseSensitiveFileNames: boolean }
): Map<string, CompilerOptionsValue> {
): ESMap<string, CompilerOptionsValue> {
const result = new Map<string, CompilerOptionsValue>();
const getCanonicalFileName = pathOptions && createGetCanonicalFileName(pathOptions.useCaseSensitiveFileNames);
@@ -2220,7 +2220,7 @@ namespace ts {
* @param basePath A root directory to resolve relative path entries in the config
* file to. e.g. outDir
*/
export function parseJsonConfigFileContent(json: any, host: ParseConfigHost, basePath: string, existingOptions?: CompilerOptions, configFileName?: string, resolutionStack?: Path[], extraFileExtensions?: readonly FileExtensionInfo[], extendedConfigCache?: Map<string, ExtendedConfigCacheEntry>, existingWatchOptions?: WatchOptions): ParsedCommandLine {
export function parseJsonConfigFileContent(json: any, host: ParseConfigHost, basePath: string, existingOptions?: CompilerOptions, configFileName?: string, resolutionStack?: Path[], extraFileExtensions?: readonly FileExtensionInfo[], extendedConfigCache?: Map<ExtendedConfigCacheEntry>, existingWatchOptions?: WatchOptions): ParsedCommandLine {
return parseJsonConfigFileContentWorker(json, /*sourceFile*/ undefined, host, basePath, existingOptions, existingWatchOptions, configFileName, resolutionStack, extraFileExtensions, extendedConfigCache);
}
@@ -2231,7 +2231,7 @@ namespace ts {
* @param basePath A root directory to resolve relative path entries in the config
* file to. e.g. outDir
*/
export function parseJsonSourceFileConfigFileContent(sourceFile: TsConfigSourceFile, host: ParseConfigHost, basePath: string, existingOptions?: CompilerOptions, configFileName?: string, resolutionStack?: Path[], extraFileExtensions?: readonly FileExtensionInfo[], extendedConfigCache?: Map<string, ExtendedConfigCacheEntry>, existingWatchOptions?: WatchOptions): ParsedCommandLine {
export function parseJsonSourceFileConfigFileContent(sourceFile: TsConfigSourceFile, host: ParseConfigHost, basePath: string, existingOptions?: CompilerOptions, configFileName?: string, resolutionStack?: Path[], extraFileExtensions?: readonly FileExtensionInfo[], extendedConfigCache?: Map<ExtendedConfigCacheEntry>, existingWatchOptions?: WatchOptions): ParsedCommandLine {
return parseJsonConfigFileContentWorker(/*json*/ undefined, sourceFile, host, basePath, existingOptions, existingWatchOptions, configFileName, resolutionStack, extraFileExtensions, extendedConfigCache);
}
@@ -2271,7 +2271,7 @@ namespace ts {
configFileName?: string,
resolutionStack: Path[] = [],
extraFileExtensions: readonly FileExtensionInfo[] = [],
extendedConfigCache?: Map<string, ExtendedConfigCacheEntry>
extendedConfigCache?: ESMap<string, ExtendedConfigCacheEntry>
): ParsedCommandLine {
Debug.assert((json === undefined && sourceFile !== undefined) || (json !== undefined && sourceFile === undefined));
const errors: Diagnostic[] = [];
@@ -2456,7 +2456,7 @@ namespace ts {
configFileName: string | undefined,
resolutionStack: string[],
errors: Push<Diagnostic>,
extendedConfigCache?: Map<string, ExtendedConfigCacheEntry>
extendedConfigCache?: ESMap<string, ExtendedConfigCacheEntry>
): ParsedTsconfig {
basePath = normalizeSlashes(basePath);
const resolvedPath = getNormalizedAbsolutePath(configFileName || "", basePath);
@@ -2645,7 +2645,7 @@ namespace ts {
basePath: string,
resolutionStack: string[],
errors: Push<Diagnostic>,
extendedConfigCache?: Map<string, ExtendedConfigCacheEntry>
extendedConfigCache?: ESMap<string, ExtendedConfigCacheEntry>
): ParsedTsconfig | undefined {
const path = host.useCaseSensitiveFileNames ? extendedConfigPath : toFileNameLowerCase(extendedConfigPath);
let value: ExtendedConfigCacheEntry | undefined;
@@ -2750,11 +2750,11 @@ namespace ts {
return convertOptionsFromJson(getCommandLineWatchOptionsMap(), jsonOptions, basePath, /*defaultOptions*/ undefined, watchOptionsDidYouMeanDiagnostics, errors);
}
function convertOptionsFromJson(optionsNameMap: Map<string, CommandLineOption>, jsonOptions: any, basePath: string,
function convertOptionsFromJson(optionsNameMap: ESMap<string, CommandLineOption>, jsonOptions: any, basePath: string,
defaultOptions: undefined, diagnostics: DidYouMeanOptionsDiagnostics, errors: Push<Diagnostic>): WatchOptions | undefined;
function convertOptionsFromJson(optionsNameMap: Map<string, CommandLineOption>, jsonOptions: any, basePath: string,
function convertOptionsFromJson(optionsNameMap: ESMap<string, CommandLineOption>, jsonOptions: any, basePath: string,
defaultOptions: CompilerOptions | TypeAcquisition, diagnostics: DidYouMeanOptionsDiagnostics, errors: Push<Diagnostic>): CompilerOptions | TypeAcquisition;
function convertOptionsFromJson(optionsNameMap: Map<string, CommandLineOption>, jsonOptions: any, basePath: string,
function convertOptionsFromJson(optionsNameMap: ESMap<string, CommandLineOption>, jsonOptions: any, basePath: string,
defaultOptions: CompilerOptions | TypeAcquisition | WatchOptions | undefined, diagnostics: DidYouMeanOptionsDiagnostics, errors: Push<Diagnostic>) {
if (!jsonOptions) {
@@ -3174,7 +3174,7 @@ namespace ts {
* @param extensionPriority The priority of the extension.
* @param context The expansion context.
*/
function hasFileWithHigherPriorityExtension(file: string, literalFiles: Map<string, string>, wildcardFiles: Map<string, string>, extensions: readonly string[], keyMapper: (value: string) => string) {
function hasFileWithHigherPriorityExtension(file: string, literalFiles: ESMap<string, string>, wildcardFiles: ESMap<string, string>, extensions: readonly string[], keyMapper: (value: string) => string) {
const extensionPriority = getExtensionPriority(file, extensions);
const adjustedExtensionPriority = adjustExtensionPriority(extensionPriority, extensions);
for (let i = ExtensionPriority.Highest; i < adjustedExtensionPriority; i++) {
@@ -3196,7 +3196,7 @@ namespace ts {
* @param extensionPriority The priority of the extension.
* @param context The expansion context.
*/
function removeWildcardFilesWithLowerPriorityExtension(file: string, wildcardFiles: Map<string, string>, extensions: readonly string[], keyMapper: (value: string) => string) {
function removeWildcardFilesWithLowerPriorityExtension(file: string, wildcardFiles: ESMap<string, string>, extensions: readonly string[], keyMapper: (value: string) => string) {
const extensionPriority = getExtensionPriority(file, extensions);
const nextExtensionPriority = getNextLowestExtensionPriority(extensionPriority, extensions);
for (let i = nextExtensionPriority; i < extensions.length; i++) {
+27 -25
View File
@@ -1,7 +1,7 @@
/* @internal */
namespace ts {
type GetIteratorCallback = <I extends readonly any[] | ReadonlySet<any> | ReadonlyMap<any, any> | undefined>(iterable: I) => Iterator<
I extends ReadonlyMap<infer K, infer V> ? [K, V] :
type GetIteratorCallback = <I extends readonly any[] | ReadonlySet<any> | ReadonlyESMap<any, any> | undefined>(iterable: I) => Iterator<
I extends ReadonlyESMap<infer K, infer V> ? [K, V] :
I extends ReadonlySet<infer T> ? T :
I extends readonly (infer T)[] ? T :
I extends undefined ? undefined :
@@ -20,17 +20,17 @@ namespace ts {
export const Map = getCollectionImplementation("Map", "tryGetNativeMap", "createMapShim");
export const Set = getCollectionImplementation("Set", "tryGetNativeSet", "createSetShim");
export function getIterator<I extends readonly any[] | ReadonlySet<any> | ReadonlyMap<any, any> | undefined>(iterable: I): Iterator<
I extends ReadonlyMap<infer K, infer V> ? [K, V] :
export function getIterator<I extends readonly any[] | ReadonlySet<any> | ReadonlyESMap<any, any> | undefined>(iterable: I): Iterator<
I extends ReadonlyESMap<infer K, infer V> ? [K, V] :
I extends ReadonlySet<infer T> ? T :
I extends readonly (infer T)[] ? T :
I extends undefined ? undefined :
never>;
export function getIterator<K, V>(iterable: ReadonlyMap<K, V>): Iterator<[K, V]>;
export function getIterator<K, V>(iterable: ReadonlyMap<K, V> | undefined): Iterator<[K, V]> | undefined;
export function getIterator<K, V>(iterable: ReadonlyESMap<K, V>): Iterator<[K, V]>;
export function getIterator<K, V>(iterable: ReadonlyESMap<K, V> | undefined): Iterator<[K, V]> | undefined;
export function getIterator<T>(iterable: readonly T[] | ReadonlySet<T>): Iterator<T>;
export function getIterator<T>(iterable: readonly T[] | ReadonlySet<T> | undefined): Iterator<T> | undefined;
export function getIterator(iterable: readonly any[] | ReadonlySet<any> | ReadonlyMap<any, any> | undefined): Iterator<any> | undefined {
export function getIterator(iterable: readonly any[] | ReadonlySet<any> | ReadonlyESMap<any, any> | undefined): Iterator<any> | undefined {
if (iterable) {
if (isArray(iterable)) return arrayIterator(iterable);
if (iterable instanceof Map) return iterable.entries();
@@ -40,14 +40,16 @@ namespace ts {
}
export const emptyArray: never[] = [] as never[];
export const emptyMap: ReadonlyMap<never, never> = new Map<never, never>();
export const emptyMap: ReadonlyESMap<never, never> = new Map<never, never>();
export const emptySet: ReadonlySet<never> = new Set<never>();
/**
* Create a new map.
* @deprecated Use `new Map()` instead.
*/
export function createMap<K, V>(): Map<K, V> {
export function createMap<K, V>(): ESMap<K, V>;
export function createMap<T>(): ESMap<string, T>;
export function createMap<K, V>(): ESMap<K, V> {
return new Map<K, V>();
}
@@ -55,8 +57,8 @@ namespace ts {
* Create a new map from a template object is provided, the map will copy entries from it.
* @deprecated Use `new Map(getEntries(template))` instead.
*/
export function createMapFromTemplate<T>(template: MapLike<T>): Map<string, T> {
const map = new Map<string, T>();
export function createMapFromTemplate<T>(template: MapLike<T>): ESMap<string, T> {
const map: ESMap<string, T> = new Map<string, T>();
// Copies keys/values from template. Note that for..in will not throw if
// template is undefined, and instead will just exit the loop.
@@ -166,7 +168,7 @@ namespace ts {
};
}
export function zipToMap<K, V>(keys: readonly K[], values: readonly V[]): Map<K, V> {
export function zipToMap<K, V>(keys: readonly K[], values: readonly V[]): ESMap<K, V> {
Debug.assert(keys.length === values.length);
const map = new Map<K, V>();
for (let i = 0; i < keys.length; ++i) {
@@ -560,9 +562,9 @@ namespace ts {
};
}
export function mapDefinedEntries<K1, V1, K2, V2>(map: ReadonlyMap<K1, V1>, f: (key: K1, value: V1) => readonly [K2, V2] | undefined): Map<K2, V2>;
export function mapDefinedEntries<K1, V1, K2, V2>(map: ReadonlyMap<K1, V1> | undefined, f: (key: K1, value: V1) => readonly [K2 | undefined, V2 | undefined] | undefined): Map<K2, V2> | undefined;
export function mapDefinedEntries<K1, V1, K2, V2>(map: ReadonlyMap<K1, V1> | undefined, f: (key: K1, value: V1) => readonly [K2 | undefined, V2 | undefined] | undefined): Map<K2, V2> | undefined {
export function mapDefinedEntries<K1, V1, K2, V2>(map: ReadonlyESMap<K1, V1>, f: (key: K1, value: V1) => readonly [K2, V2] | undefined): ESMap<K2, V2>;
export function mapDefinedEntries<K1, V1, K2, V2>(map: ReadonlyESMap<K1, V1> | undefined, f: (key: K1, value: V1) => readonly [K2 | undefined, V2 | undefined] | undefined): ESMap<K2, V2> | undefined;
export function mapDefinedEntries<K1, V1, K2, V2>(map: ReadonlyESMap<K1, V1> | undefined, f: (key: K1, value: V1) => readonly [K2 | undefined, V2 | undefined] | undefined): ESMap<K2, V2> | undefined {
if (!map) {
return undefined;
}
@@ -596,7 +598,7 @@ namespace ts {
}
}
export function getOrUpdate<K, V>(map: Map<K, V>, key: K, callback: () => V) {
export function getOrUpdate<K, V>(map: ESMap<K, V>, key: K, callback: () => V) {
if (map.has(key)) {
return map.get(key)!;
}
@@ -675,9 +677,9 @@ namespace ts {
return result;
}
export function mapEntries<K1, V1, K2, V2>(map: ReadonlyMap<K1, V1>, f: (key: K1, value: V1) => readonly [K2, V2]): Map<K2, V2>;
export function mapEntries<K1, V1, K2, V2>(map: ReadonlyMap<K1, V1> | undefined, f: (key: K1, value: V1) => readonly [K2, V2]): Map<K2, V2> | undefined;
export function mapEntries<K1, V1, K2, V2>(map: ReadonlyMap<K1, V1> | undefined, f: (key: K1, value: V1) => readonly [K2, V2]): Map<K2, V2> | undefined {
export function mapEntries<K1, V1, K2, V2>(map: ReadonlyESMap<K1, V1>, f: (key: K1, value: V1) => readonly [K2, V2]): ESMap<K2, V2>;
export function mapEntries<K1, V1, K2, V2>(map: ReadonlyESMap<K1, V1> | undefined, f: (key: K1, value: V1) => readonly [K2, V2]): ESMap<K2, V2> | undefined;
export function mapEntries<K1, V1, K2, V2>(map: ReadonlyESMap<K1, V1> | undefined, f: (key: K1, value: V1) => readonly [K2, V2]): ESMap<K2, V2> | undefined {
if (!map) {
return undefined;
}
@@ -1370,11 +1372,11 @@ namespace ts {
* the same key with the given 'makeKey' function, then the element with the higher
* index in the array will be the one associated with the produced key.
*/
export function arrayToMap<K, V>(array: readonly V[], makeKey: (value: V) => K | undefined): Map<K, V>;
export function arrayToMap<K, V1, V2>(array: readonly V1[], makeKey: (value: V1) => K | undefined, makeValue: (value: V1) => V2): Map<K, V2>;
export function arrayToMap<T>(array: readonly T[], makeKey: (value: T) => string | undefined): Map<string, T>;
export function arrayToMap<T, U>(array: readonly T[], makeKey: (value: T) => string | undefined, makeValue: (value: T) => U): Map<string, U>;
export function arrayToMap<K, V1, V2>(array: readonly V1[], makeKey: (value: V1) => K | undefined, makeValue: (value: V1) => V1 | V2 = identity): Map<K, V1 | V2> {
export function arrayToMap<K, V>(array: readonly V[], makeKey: (value: V) => K | undefined): ESMap<K, V>;
export function arrayToMap<K, V1, V2>(array: readonly V1[], makeKey: (value: V1) => K | undefined, makeValue: (value: V1) => V2): ESMap<K, V2>;
export function arrayToMap<T>(array: readonly T[], makeKey: (value: T) => string | undefined): ESMap<string, T>;
export function arrayToMap<T, U>(array: readonly T[], makeKey: (value: T) => string | undefined, makeValue: (value: T) => U): ESMap<string, U>;
export function arrayToMap<K, V1, V2>(array: readonly V1[], makeKey: (value: V1) => K | undefined, makeValue: (value: V1) => V1 | V2 = identity): ESMap<K, V1 | V2> {
const result = new Map<K, V1 | V2>();
for (const value of array) {
const key = makeKey(value);
@@ -1455,7 +1457,7 @@ namespace ts {
return fn ? fn.bind(obj) : undefined;
}
export interface MultiMap<K, V> extends Map<K, V[]> {
export interface MultiMap<K, V> extends ESMap<K, V[]> {
/**
* Adds the value to an array of values associated with the key, and returns the array.
* Creates the array if it does not already exist.
+17 -3
View File
@@ -36,22 +36,36 @@ namespace ts {
}
/** ES6 Map interface, only read methods included. */
export interface ReadonlyMap<K, V> extends ReadonlyCollection<K> {
export interface ReadonlyESMap<K, V> extends ReadonlyCollection<K> {
get(key: K): V | undefined;
values(): Iterator<V>;
entries(): Iterator<[K, V]>;
forEach(action: (value: V, key: K) => void): void;
}
/**
* ES6 Map interface, only read methods included.
* @deprecated Use `ts.ReadonlyESMap<K, V>` instead.
*/
export interface ReadonlyMap<T> extends ReadonlyESMap<string, T> {
}
/** ES6 Map interface. */
export interface Map<K, V> extends ReadonlyMap<K, V>, Collection<K> {
export interface ESMap<K, V> extends ReadonlyESMap<K, V>, Collection<K> {
set(key: K, value: V): this;
}
/**
* ES6 Map interface.
* @deprecated Use `ts.ESMap<K, V>` instead.
*/
export interface Map<T> extends ESMap<string, T> {
}
/* @internal */
export interface MapConstructor {
// eslint-disable-next-line @typescript-eslint/prefer-function-type
new <K, V>(iterable?: readonly (readonly [K, V])[] | ReadonlyMap<K, V>): Map<K, V>;
new <K, V>(iterable?: readonly (readonly [K, V])[] | ReadonlyESMap<K, V>): ESMap<K, V>;
}
/** ES6 Set interface, only read methods included. */
+13 -5
View File
@@ -880,7 +880,7 @@
"category": "Error",
"code": 1308
},
"'=' can only be used in an object literal property inside a destructuring assignment.": {
"Did you mean to use a ':'? An '=' can only follow a property name when the containing object literal is part of a destructuring pattern.": {
"category": "Error",
"code": 1312
},
@@ -5155,10 +5155,6 @@
"category": "Message",
"code": 90008
},
"Remove destructuring": {
"category": "Message",
"code": 90009
},
"Remove variable statement": {
"category": "Message",
"code": 90010
@@ -5275,6 +5271,14 @@
"category": "Message",
"code": 90038
},
"Remove unused destructuring declaration": {
"category": "Message",
"code": 90039
},
"Remove unused declarations for: '{0}'": {
"category": "Message",
"code": 90041
},
"Declare a private field named '{0}'.": {
"category": "Message",
"code": 90053
@@ -5819,6 +5823,10 @@
"category": "Message",
"code": 95137
},
"Switch each misused '{0}' to '{1}'": {
"category": "Message",
"code": 95138
},
"No value exists in scope for the shorthand property '{0}'. Either declare one or provide an initializer.": {
"category": "Error",
+16 -7
View File
@@ -2667,7 +2667,7 @@ namespace ts {
emitTokenWithComment(SyntaxKind.CloseParenToken, node.expression.end, writePunctuation, node);
emitEmbeddedStatement(node, node.thenStatement);
if (node.elseStatement) {
writeLineOrSpace(node);
writeLineOrSpace(node, node.thenStatement, node.elseStatement);
emitTokenWithComment(SyntaxKind.ElseKeyword, node.thenStatement.end, writeKeyword, node);
if (node.elseStatement.kind === SyntaxKind.IfStatement) {
writeSpace();
@@ -2690,11 +2690,11 @@ namespace ts {
function emitDoStatement(node: DoStatement) {
emitTokenWithComment(SyntaxKind.DoKeyword, node.pos, writeKeyword, node);
emitEmbeddedStatement(node, node.statement);
if (isBlock(node.statement)) {
if (isBlock(node.statement) && !preserveSourceNewlines) {
writeSpace();
}
else {
writeLineOrSpace(node);
writeLineOrSpace(node, node.statement, node.expression);
}
emitWhileClause(node, node.statement.end);
@@ -2836,11 +2836,11 @@ namespace ts {
writeSpace();
emit(node.tryBlock);
if (node.catchClause) {
writeLineOrSpace(node);
writeLineOrSpace(node, node.tryBlock, node.catchClause);
emit(node.catchClause);
}
if (node.finallyBlock) {
writeLineOrSpace(node);
writeLineOrSpace(node, node.catchClause || node.tryBlock, node.finallyBlock);
emitTokenWithComment(SyntaxKind.FinallyKeyword, (node.catchClause || node.tryBlock).end, writeKeyword, node);
writeSpace();
emit(node.finallyBlock);
@@ -4249,10 +4249,19 @@ namespace ts {
return pos! < 0 ? pos! : pos! + tokenString.length;
}
function writeLineOrSpace(node: Node) {
if (getEmitFlags(node) & EmitFlags.SingleLine) {
function writeLineOrSpace(parentNode: Node, prevChildNode: Node, nextChildNode: Node) {
if (getEmitFlags(parentNode) & EmitFlags.SingleLine) {
writeSpace();
}
else if (preserveSourceNewlines) {
const lines = getLinesBetweenNodes(parentNode, prevChildNode, nextChildNode);
if (lines) {
writeLine(lines);
}
else {
writeSpace();
}
}
else {
writeLine();
}
+1 -1
View File
@@ -841,7 +841,7 @@ namespace ts {
};`
};
let allUnscopedEmitHelpers: ReadonlyMap<string, UnscopedEmitHelper> | undefined;
let allUnscopedEmitHelpers: ReadonlyESMap<string, UnscopedEmitHelper> | undefined;
export function getAllUnscopedEmitHelpers() {
return allUnscopedEmitHelpers || (allUnscopedEmitHelpers = arrayToMap([
+11 -11
View File
@@ -442,8 +442,8 @@ namespace ts {
* This assumes that any module id will have the same resolution for sibling files located in the same folder.
*/
export interface ModuleResolutionCache extends NonRelativeModuleNameResolutionCache {
getOrCreateCacheForDirectory(directoryName: string, redirectedReference?: ResolvedProjectReference): Map<string, ResolvedModuleWithFailedLookupLocations>;
/*@internal*/ directoryToModuleNameMap: CacheWithRedirects<Map<string, ResolvedModuleWithFailedLookupLocations>>;
getOrCreateCacheForDirectory(directoryName: string, redirectedReference?: ResolvedProjectReference): Map<ResolvedModuleWithFailedLookupLocations>;
/*@internal*/ directoryToModuleNameMap: CacheWithRedirects<ESMap<string, ResolvedModuleWithFailedLookupLocations>>;
}
/**
@@ -472,18 +472,18 @@ namespace ts {
/*@internal*/
export interface CacheWithRedirects<T> {
ownMap: Map<string, T>;
redirectsMap: Map<Path, Map<string, T>>;
getOrCreateMapOfCacheRedirects(redirectedReference: ResolvedProjectReference | undefined): Map<string, T>;
ownMap: ESMap<string, T>;
redirectsMap: ESMap<Path, ESMap<string, T>>;
getOrCreateMapOfCacheRedirects(redirectedReference: ResolvedProjectReference | undefined): ESMap<string, T>;
clear(): void;
setOwnOptions(newOptions: CompilerOptions): void;
setOwnMap(newOwnMap: Map<string, T>): void;
setOwnMap(newOwnMap: ESMap<string, T>): void;
}
/*@internal*/
export function createCacheWithRedirects<T>(options?: CompilerOptions): CacheWithRedirects<T> {
let ownMap: Map<string, T> = new Map();
const redirectsMap = new Map<Path, Map<string, T>>();
let ownMap: ESMap<string, T> = new Map();
const redirectsMap = new Map<Path, ESMap<string, T>>();
return {
ownMap,
redirectsMap,
@@ -497,7 +497,7 @@ namespace ts {
options = newOptions;
}
function setOwnMap(newOwnMap: Map<string, T>) {
function setOwnMap(newOwnMap: ESMap<string, T>) {
ownMap = newOwnMap;
}
@@ -523,7 +523,7 @@ namespace ts {
/*@internal*/
export function createModuleResolutionCacheWithMaps(
directoryToModuleNameMap: CacheWithRedirects<Map<string, ResolvedModuleWithFailedLookupLocations>>,
directoryToModuleNameMap: CacheWithRedirects<ESMap<string, ResolvedModuleWithFailedLookupLocations>>,
moduleNameToDirectoryMap: CacheWithRedirects<PerModuleNameCache>,
currentDirectory: string,
getCanonicalFileName: GetCanonicalFileName): ModuleResolutionCache {
@@ -532,7 +532,7 @@ namespace ts {
function getOrCreateCacheForDirectory(directoryName: string, redirectedReference?: ResolvedProjectReference) {
const path = toPath(directoryName, currentDirectory, getCanonicalFileName);
return getOrCreateCache<Map<string, ResolvedModuleWithFailedLookupLocations>>(directoryToModuleNameMap, redirectedReference, path, () => new Map());
return getOrCreateCache<ESMap<string, ResolvedModuleWithFailedLookupLocations>>(directoryToModuleNameMap, redirectedReference, path, () => new Map());
}
function getOrCreateCacheForModuleName(nonRelativeModuleName: string, redirectedReference?: ResolvedProjectReference): PerModuleNameCache {
+13 -22
View File
@@ -722,8 +722,8 @@ namespace ts {
let currentToken: SyntaxKind;
let nodeCount: number;
let identifiers: Map<string, string>;
let privateIdentifiers: Map<string, string>;
let identifiers: ESMap<string, string>;
let privateIdentifiers: ESMap<string, string>;
let identifierCount: number;
let parsingContext: ParsingContext;
@@ -2701,19 +2701,10 @@ namespace ts {
return finishNode(factory.createThisTypeNode(), pos);
}
function parseJSDocAllType(postFixEquals: boolean): JSDocAllType | JSDocOptionalType {
function parseJSDocAllType(): JSDocAllType | JSDocOptionalType {
const pos = getNodePos();
nextToken();
const node = factory.createJSDocAllType();
if (postFixEquals) {
// Trim the trailing `=` from the `*=` token
const end = Math.max(getNodePos() - 1, pos);
return finishNode(factory.createJSDocOptionalType(finishNode(node, pos, end)), pos);
}
else {
return finishNode(node, pos);
}
return finishNode(factory.createJSDocAllType(), pos);
}
function parseJSDocNonNullableType(): TypeNode {
@@ -3396,12 +3387,14 @@ namespace ts {
case SyntaxKind.ObjectKeyword:
// If these are followed by a dot, then parse these out as a dotted type reference instead.
return tryParse(parseKeywordAndNoDot) || parseTypeReference();
case SyntaxKind.AsteriskToken:
return parseJSDocAllType(/*postfixEquals*/ false);
case SyntaxKind.AsteriskEqualsToken:
return parseJSDocAllType(/*postfixEquals*/ true);
// If there is '*=', treat it as * followed by postfix =
scanner.reScanAsteriskEqualsToken();
// falls through
case SyntaxKind.AsteriskToken:
return parseJSDocAllType();
case SyntaxKind.QuestionQuestionToken:
// If there is '??', consider that is prefix '?' in JSDoc type.
// If there is '??', treat it as prefix-'?' in JSDoc type.
scanner.reScanQuestionToken();
// falls through
case SyntaxKind.QuestionToken:
@@ -7440,11 +7433,9 @@ namespace ts {
loop: while (true) {
switch (tok) {
case SyntaxKind.NewLineTrivia:
if (state >= JSDocState.SawAsterisk) {
state = JSDocState.BeginningOfLine;
// don't use pushComment here because we want to keep the margin unchanged
comments.push(scanner.getTokenText());
}
state = JSDocState.BeginningOfLine;
// don't use pushComment here because we want to keep the margin unchanged
comments.push(scanner.getTokenText());
indent = 0;
break;
case SyntaxKind.AtToken:
+3 -3
View File
@@ -8,9 +8,9 @@ namespace ts.performance {
let enabled = false;
let profilerStart = 0;
let counts: Map<string, number>;
let marks: Map<string, number>;
let measures: Map<string, number>;
let counts: ESMap<string, number>;
let marks: ESMap<string, number>;
let measures: ESMap<string, number>;
export interface Timer {
enter(): void;
+9 -9
View File
@@ -126,7 +126,7 @@ namespace ts {
}
}
let outputFingerprints: Map<string, OutputFingerprint>;
let outputFingerprints: ESMap<string, OutputFingerprint>;
function writeFileWorker(fileName: string, data: string, writeByteOrderMark: boolean) {
if (!isWatchSet(options) || !system.createHash || !system.getModifiedTime) {
system.writeFile(fileName, data, writeByteOrderMark);
@@ -533,7 +533,7 @@ namespace ts {
export const inferredTypesContainingFile = "__inferred type names__.ts";
interface DiagnosticCache<T extends Diagnostic> {
perFile?: Map<Path, readonly T[]>;
perFile?: ESMap<Path, readonly T[]>;
allDiagnostics?: readonly T[];
}
@@ -702,7 +702,7 @@ namespace ts {
let processingDefaultLibFiles: SourceFile[] | undefined;
let processingOtherFiles: SourceFile[] | undefined;
let files: SourceFile[];
let symlinks: ReadonlyMap<string, string> | undefined;
let symlinks: ReadonlyESMap<string, string> | undefined;
let commonSourceDirectory: string;
let diagnosticsProducingTypeChecker: TypeChecker;
let noDiagnosticsTypeChecker: TypeChecker;
@@ -803,9 +803,9 @@ namespace ts {
// A parallel array to projectReferences storing the results of reading in the referenced tsconfig files
let resolvedProjectReferences: readonly (ResolvedProjectReference | undefined)[] | undefined;
let projectReferenceRedirects: Map<Path, ResolvedProjectReference | false> | undefined;
let mapFromFileToProjectReferenceRedirects: Map<Path, Path> | undefined;
let mapFromToProjectReferenceRedirectSource: Map<Path, SourceOfProjectReferenceRedirect> | undefined;
let projectReferenceRedirects: ESMap<Path, ResolvedProjectReference | false> | undefined;
let mapFromFileToProjectReferenceRedirects: ESMap<Path, Path> | undefined;
let mapFromToProjectReferenceRedirectSource: ESMap<Path, SourceOfProjectReferenceRedirect> | undefined;
const useSourceOfProjectReferenceRedirect = !!host.useSourceOfProjectReferenceRedirect?.() &&
!options.disableSourceOfProjectReferenceRedirect;
@@ -3452,7 +3452,7 @@ namespace ts {
return comparePaths(file1, file2, currentDirectory, !host.useCaseSensitiveFileNames()) === Comparison.EqualTo;
}
function getProbableSymlinks(): ReadonlyMap<string, string> {
function getProbableSymlinks(): ReadonlyESMap<string, string> {
if (host.getSymlinks) {
return host.getSymlinks();
}
@@ -3479,8 +3479,8 @@ namespace ts {
function updateHostForUseSourceOfProjectReferenceRedirect(host: HostForUseSourceOfProjectReferenceRedirect) {
let setOfDeclarationDirectories: Set<Path> | undefined;
let symlinkedDirectories: Map<Path, SymlinkedDirectory | false> | undefined;
let symlinkedFiles: Map<Path, string> | undefined;
let symlinkedDirectories: ESMap<Path, SymlinkedDirectory | false> | undefined;
let symlinkedFiles: ESMap<Path, string> | undefined;
const originalFileExists = host.compilerHost.fileExists;
const originalDirectoryExists = host.compilerHost.directoryExists;
+10 -10
View File
@@ -13,7 +13,7 @@ namespace ts {
invalidateResolutionOfFile(filePath: Path): void;
removeResolutionsOfFile(filePath: Path): void;
removeResolutionsFromProjectReferenceRedirects(filePath: Path): void;
setFilesWithInvalidatedNonRelativeUnresolvedImports(filesWithUnresolvedImports: Map<Path, readonly string[]>): void;
setFilesWithInvalidatedNonRelativeUnresolvedImports(filesWithUnresolvedImports: ESMap<Path, readonly string[]>): void;
createHasInvalidatedResolution(forceAllFilesAsInvalidated?: boolean): HasInvalidatedResolution;
hasChangedAutomaticTypeDirectiveNames(): boolean;
@@ -144,7 +144,7 @@ namespace ts {
export function createResolutionCache(resolutionHost: ResolutionCacheHost, rootDirForResolution: string | undefined, logChangesWhenResolvingModule: boolean): ResolutionCache {
let filesWithChangedSetOfUnresolvedImports: Path[] | undefined;
let filesWithInvalidatedResolutions: Set<Path> | undefined;
let filesWithInvalidatedNonRelativeUnresolvedImports: ReadonlyMap<Path, readonly string[]> | undefined;
let filesWithInvalidatedNonRelativeUnresolvedImports: ReadonlyESMap<Path, readonly string[]> | undefined;
const nonRelativeExternalModuleResolutions = createMultiMap<ResolutionWithFailedLookupLocations>();
const resolutionsWithFailedLookups: ResolutionWithFailedLookupLocations[] = [];
@@ -161,8 +161,8 @@ namespace ts {
// The resolvedModuleNames and resolvedTypeReferenceDirectives are the cache of resolutions per file.
// The key in the map is source file's path.
// The values are Map of resolutions with key being name lookedup.
const resolvedModuleNames = new Map<Path, Map<string, CachedResolvedModuleWithFailedLookupLocations>>();
const perDirectoryResolvedModuleNames: CacheWithRedirects<Map<string, CachedResolvedModuleWithFailedLookupLocations>> = createCacheWithRedirects();
const resolvedModuleNames = new Map<Path, ESMap<string, CachedResolvedModuleWithFailedLookupLocations>>();
const perDirectoryResolvedModuleNames: CacheWithRedirects<ESMap<string, CachedResolvedModuleWithFailedLookupLocations>> = createCacheWithRedirects();
const nonRelativeModuleNameCache: CacheWithRedirects<PerModuleNameCache> = createCacheWithRedirects();
const moduleResolutionCache = createModuleResolutionCacheWithMaps(
perDirectoryResolvedModuleNames,
@@ -171,8 +171,8 @@ namespace ts {
resolutionHost.getCanonicalFileName
);
const resolvedTypeReferenceDirectives = new Map<Path, Map<string, CachedResolvedTypeReferenceDirectiveWithFailedLookupLocations>>();
const perDirectoryResolvedTypeReferenceDirectives: CacheWithRedirects<Map<string, CachedResolvedTypeReferenceDirectiveWithFailedLookupLocations>> = createCacheWithRedirects();
const resolvedTypeReferenceDirectives = new Map<Path, ESMap<string, CachedResolvedTypeReferenceDirectiveWithFailedLookupLocations>>();
const perDirectoryResolvedTypeReferenceDirectives: CacheWithRedirects<ESMap<string, CachedResolvedTypeReferenceDirectiveWithFailedLookupLocations>> = createCacheWithRedirects();
/**
* These are the extensions that failed lookup files will have by default,
@@ -334,8 +334,8 @@ namespace ts {
names: readonly string[];
containingFile: string;
redirectedReference: ResolvedProjectReference | undefined;
cache: Map<Path, Map<string, T>>;
perDirectoryCacheWithRedirects: CacheWithRedirects<Map<string, T>>;
cache: ESMap<Path, ESMap<string, T>>;
perDirectoryCacheWithRedirects: CacheWithRedirects<ESMap<string, T>>;
loader: (name: string, containingFile: string, options: CompilerOptions, host: ModuleResolutionHost, redirectedReference?: ResolvedProjectReference) => T;
getResolutionWithResolvedFileName: GetResolutionWithResolvedFileName<T, R>;
shouldRetryResolution: (t: T) => boolean;
@@ -684,7 +684,7 @@ namespace ts {
}
function removeResolutionsOfFileFromCache<T extends ResolutionWithFailedLookupLocations, R extends ResolutionWithResolvedFileName>(
cache: Map<string, Map<string, T>>,
cache: ESMap<string, ESMap<string, T>>,
filePath: Path,
getResolutionWithResolvedFileName: GetResolutionWithResolvedFileName<T, R>,
) {
@@ -741,7 +741,7 @@ namespace ts {
}
}
function setFilesWithInvalidatedNonRelativeUnresolvedImports(filesMap: ReadonlyMap<Path, readonly string[]>) {
function setFilesWithInvalidatedNonRelativeUnresolvedImports(filesMap: ReadonlyESMap<Path, readonly string[]>) {
Debug.assert(filesWithInvalidatedNonRelativeUnresolvedImports === filesMap || filesWithInvalidatedNonRelativeUnresolvedImports === undefined);
filesWithInvalidatedNonRelativeUnresolvedImports = filesMap;
}
+14 -2
View File
@@ -34,6 +34,7 @@ namespace ts {
getTokenFlags(): TokenFlags;
reScanGreaterToken(): SyntaxKind;
reScanSlashToken(): SyntaxKind;
reScanAsteriskEqualsToken(): SyntaxKind;
reScanTemplateToken(isTaggedTemplate: boolean): SyntaxKind;
reScanTemplateHeadOrNoSubstitutionTemplate(): SyntaxKind;
scanJsxIdentifier(): SyntaxKind;
@@ -330,7 +331,7 @@ namespace ts {
lookupInUnicodeMap(code, unicodeES3IdentifierPart);
}
function makeReverseMap(source: Map<string, number>): string[] {
function makeReverseMap(source: ESMap<string, number>): string[] {
const result: string[] = [];
source.forEach((value, name) => {
result[value] = name;
@@ -954,6 +955,7 @@ namespace ts {
getNumericLiteralFlags: () => tokenFlags & TokenFlags.NumericLiteralFlags,
getTokenFlags: () => tokenFlags,
reScanGreaterToken,
reScanAsteriskEqualsToken,
reScanSlashToken,
reScanTemplateToken,
reScanTemplateHeadOrNoSubstitutionTemplate,
@@ -2086,6 +2088,12 @@ namespace ts {
return token;
}
function reScanAsteriskEqualsToken(): SyntaxKind {
Debug.assert(token === SyntaxKind.AsteriskEqualsToken, "'reScanAsteriskEqualsToken' should only be called on a '*='");
pos = tokenPos + 1;
return token = SyntaxKind.EqualsToken;
}
function reScanSlashToken(): SyntaxKind {
if (token === SyntaxKind.SlashToken || token === SyntaxKind.SlashEqualsToken) {
let p = tokenPos + 1;
@@ -2352,8 +2360,12 @@ namespace ts {
return token = SyntaxKind.WhitespaceTrivia;
case CharacterCodes.at:
return token = SyntaxKind.AtToken;
case CharacterCodes.lineFeed:
case CharacterCodes.carriageReturn:
if (text.charCodeAt(pos) === CharacterCodes.lineFeed) {
pos++;
}
// falls through
case CharacterCodes.lineFeed:
tokenFlags |= TokenFlags.PrecedingLineBreak;
return token = SyntaxKind.NewLineTrivia;
case CharacterCodes.asterisk:
+1 -1
View File
@@ -16,7 +16,7 @@ namespace ts {
let sourcesContent: (string | null)[] | undefined;
const names: string[] = [];
let nameToNameIndexMap: Map<string, number> | undefined;
let nameToNameIndexMap: ESMap<string, number> | undefined;
let mappings = "";
// Last recorded and encoded mappings
+1 -1
View File
@@ -538,7 +538,7 @@ namespace ts {
};
}
type InvokeMap = Map<Path, string[] | true>;
type InvokeMap = ESMap<Path, string[] | true>;
function invokeCallbacks(dirPath: Path, fileName: string): void;
function invokeCallbacks(dirPath: Path, invokeMap: InvokeMap, fileNames: string[] | undefined): void;
function invokeCallbacks(dirPath: Path, fileNameOrInvokeMap: string | InvokeMap, fileNames?: string[]) {
+5 -5
View File
@@ -60,7 +60,7 @@ namespace ts {
let enclosingDeclaration: Node;
let necessaryTypeReferences: Set<string> | undefined;
let lateMarkedStatements: LateVisibilityPaintedStatement[] | undefined;
let lateStatementReplacementMap: Map<NodeId, VisitResult<LateVisibilityPaintedStatement | ExportAssignment>>;
let lateStatementReplacementMap: ESMap<NodeId, VisitResult<LateVisibilityPaintedStatement | ExportAssignment>>;
let suppressNewDiagnosticContexts: boolean;
let exportedModulesFromDeclarationEmit: Symbol[] | undefined;
@@ -81,8 +81,8 @@ namespace ts {
let errorNameNode: DeclarationName | undefined;
let currentSourceFile: SourceFile;
let refs: Map<NodeId, SourceFile>;
let libs: Map<string, boolean>;
let refs: ESMap<NodeId, SourceFile>;
let libs: ESMap<string, boolean>;
let emittedImports: readonly AnyImportSyntax[] | undefined; // must be declared in container so it can be `undefined` while transformer's first pass
const resolver = context.getEmitResolver();
const options = context.getCompilerOptions();
@@ -402,7 +402,7 @@ namespace ts {
}
}
function collectReferences(sourceFile: SourceFile | UnparsedSource, ret: Map<NodeId, SourceFile>) {
function collectReferences(sourceFile: SourceFile | UnparsedSource, ret: ESMap<NodeId, SourceFile>) {
if (noResolve || (!isUnparsedSource(sourceFile) && isSourceFileJS(sourceFile))) return ret;
forEach(sourceFile.referencedFiles, f => {
const elem = host.getSourceFileFromReference(sourceFile, f);
@@ -413,7 +413,7 @@ namespace ts {
return ret;
}
function collectLibs(sourceFile: SourceFile | UnparsedSource, ret: Map<string, boolean>) {
function collectLibs(sourceFile: SourceFile | UnparsedSource, ret: ESMap<string, boolean>) {
forEach(sourceFile.libReferenceDirectives, ref => {
const lib = host.getLibFileFromReference(ref);
if (lib) {
+4 -4
View File
@@ -72,15 +72,15 @@ namespace ts {
* set of labels that occurred inside the converted loop
* used to determine if labeled jump can be emitted as is or it should be dispatched to calling code
*/
labels?: Map<string, boolean>;
labels?: ESMap<string, boolean>;
/*
* collection of labeled jumps that transfer control outside the converted loop.
* maps store association 'label -> labelMarker' where
* - label - value of label as it appear in code
* - label marker - return value that should be interpreted by calling code as 'jump to <label>'
*/
labeledNonLocalBreaks?: Map<string, string>;
labeledNonLocalContinues?: Map<string, string>;
labeledNonLocalBreaks?: ESMap<string, string>;
labeledNonLocalContinues?: ESMap<string, string>;
/*
* set of non-labeled jumps that transfer control outside the converted loop
@@ -3291,7 +3291,7 @@ namespace ts {
}
}
function processLabeledJumps(table: Map<string, string>, isBreak: boolean, loopResultName: Identifier, outerLoop: ConvertedLoopState | undefined, caseClauses: CaseClause[]): void {
function processLabeledJumps(table: ESMap<string, string>, isBreak: boolean, loopResultName: Identifier, outerLoop: ConvertedLoopState | undefined, caseClauses: CaseClause[]): void {
if (!table) {
return;
}
+1 -1
View File
@@ -244,7 +244,7 @@ namespace ts {
const previousOnSubstituteNode = context.onSubstituteNode;
context.onSubstituteNode = onSubstituteNode;
let renamedCatchVariables: Map<string, boolean>;
let renamedCatchVariables: ESMap<string, boolean>;
let renamedCatchVariableDeclarations: Identifier[];
let inGeneratorFunctionBody: boolean;
@@ -13,7 +13,7 @@ namespace ts {
context.enableEmitNotification(SyntaxKind.SourceFile);
context.enableSubstitution(SyntaxKind.Identifier);
let helperNameSubstitutions: Map<string, Identifier> | undefined;
let helperNameSubstitutions: ESMap<string, Identifier> | undefined;
return chainBundle(context, transformSourceFile);
function transformSourceFile(node: SourceFile) {
+2 -2
View File
@@ -8,7 +8,7 @@ namespace ts {
export interface ExternalModuleInfo {
externalImports: (ImportDeclaration | ImportEqualsDeclaration | ExportDeclaration)[]; // imports of other external modules
externalHelpersImportDeclaration: ImportDeclaration | undefined; // import of external helpers
exportSpecifiers: Map<string, ExportSpecifier[]>; // file-local export specifiers by name (no reexports)
exportSpecifiers: ESMap<string, ExportSpecifier[]>; // file-local export specifiers by name (no reexports)
exportedBindings: Identifier[][]; // exported names of local declarations
exportedNames: Identifier[] | undefined; // all exported names in the module, both local and reexported
exportEquals: ExportAssignment | undefined; // an export= declaration if one was present
@@ -219,7 +219,7 @@ namespace ts {
}
}
function collectExportedVariableInfo(decl: VariableDeclaration | BindingElement, uniqueExports: Map<string, boolean>, exportedNames: Identifier[] | undefined) {
function collectExportedVariableInfo(decl: VariableDeclaration | BindingElement, uniqueExports: ESMap<string, boolean>, exportedNames: Identifier[] | undefined) {
if (isBindingPattern(decl.name)) {
for (const element of decl.name.elements) {
if (!isOmittedExpression(element)) {
+17 -17
View File
@@ -52,7 +52,7 @@ namespace ts {
/*@internal*/
export type ResolvedConfigFilePath = ResolvedConfigFileName & Path;
function getOrCreateValueFromConfigFileMap<T>(configFileMap: Map<ResolvedConfigFilePath, T>, resolved: ResolvedConfigFilePath, createT: () => T): T {
function getOrCreateValueFromConfigFileMap<T>(configFileMap: ESMap<ResolvedConfigFilePath, T>, resolved: ResolvedConfigFilePath, createT: () => T): T {
const existingValue = configFileMap.get(resolved);
let newValue: T | undefined;
if (!existingValue) {
@@ -62,8 +62,8 @@ namespace ts {
return existingValue || newValue!;
}
function getOrCreateValueMapFromConfigFileMap<T>(configFileMap: Map<ResolvedConfigFilePath, Map<string, T>>, resolved: ResolvedConfigFilePath): Map<string, T> {
return getOrCreateValueFromConfigFileMap<Map<string, T>>(configFileMap, resolved, () => new Map());
function getOrCreateValueMapFromConfigFileMap<T>(configFileMap: ESMap<ResolvedConfigFilePath, ESMap<string, T>>, resolved: ResolvedConfigFilePath): ESMap<string, T> {
return getOrCreateValueFromConfigFileMap<ESMap<string, T>>(configFileMap, resolved, () => new Map());
}
function newer(date1: Date, date2: Date): Date {
@@ -222,17 +222,17 @@ namespace ts {
readonly rootNames: readonly string[];
readonly baseWatchOptions: WatchOptions | undefined;
readonly resolvedConfigFilePaths: Map<string, ResolvedConfigFilePath>;
readonly configFileCache: Map<ResolvedConfigFilePath, ConfigFileCacheEntry>;
readonly resolvedConfigFilePaths: ESMap<string, ResolvedConfigFilePath>;
readonly configFileCache: ESMap<ResolvedConfigFilePath, ConfigFileCacheEntry>;
/** Map from config file name to up-to-date status */
readonly projectStatus: Map<ResolvedConfigFilePath, UpToDateStatus>;
readonly buildInfoChecked: Map<ResolvedConfigFilePath, true>;
readonly extendedConfigCache: Map<string, ExtendedConfigCacheEntry>;
readonly projectStatus: ESMap<ResolvedConfigFilePath, UpToDateStatus>;
readonly buildInfoChecked: ESMap<ResolvedConfigFilePath, true>;
readonly extendedConfigCache: ESMap<string, ExtendedConfigCacheEntry>;
readonly builderPrograms: Map<ResolvedConfigFilePath, T>;
readonly diagnostics: Map<ResolvedConfigFilePath, readonly Diagnostic[]>;
readonly projectPendingBuild: Map<ResolvedConfigFilePath, ConfigFileProgramReloadLevel>;
readonly projectErrorsReported: Map<ResolvedConfigFilePath, true>;
readonly builderPrograms: ESMap<ResolvedConfigFilePath, T>;
readonly diagnostics: ESMap<ResolvedConfigFilePath, readonly Diagnostic[]>;
readonly projectPendingBuild: ESMap<ResolvedConfigFilePath, ConfigFileProgramReloadLevel>;
readonly projectErrorsReported: ESMap<ResolvedConfigFilePath, true>;
readonly compilerHost: CompilerHost;
readonly moduleResolutionCache: ModuleResolutionCache | undefined;
@@ -249,9 +249,9 @@ namespace ts {
// Watch state
readonly watch: boolean;
readonly allWatchedWildcardDirectories: Map<ResolvedConfigFilePath, Map<string, WildcardDirectoryWatcher>>;
readonly allWatchedInputFiles: Map<ResolvedConfigFilePath, Map<Path, FileWatcher>>;
readonly allWatchedConfigFiles: Map<ResolvedConfigFilePath, FileWatcher>;
readonly allWatchedWildcardDirectories: ESMap<ResolvedConfigFilePath, ESMap<string, WildcardDirectoryWatcher>>;
readonly allWatchedInputFiles: ESMap<ResolvedConfigFilePath, ESMap<Path, FileWatcher>>;
readonly allWatchedConfigFiles: ESMap<ResolvedConfigFilePath, FileWatcher>;
timerToBuildInvalidatedProject: any;
reportFileChangeDetected: boolean;
@@ -978,7 +978,7 @@ namespace ts {
function finishEmit(
emitterDiagnostics: DiagnosticCollection,
emittedOutputs: Map<Path, string>,
emittedOutputs: ESMap<Path, string>,
priorNewestUpdateTime: Date,
newestDeclarationFileContentChangedTimeIsMaximumDate: boolean,
oldestOutputFileName: string,
@@ -1546,7 +1546,7 @@ namespace ts {
return actual;
}
function updateOutputTimestampsWorker(state: SolutionBuilderState, proj: ParsedCommandLine, priorNewestUpdateTime: Date, verboseMessage: DiagnosticMessage, skipOutputs?: Map<Path, string>) {
function updateOutputTimestampsWorker(state: SolutionBuilderState, proj: ParsedCommandLine, priorNewestUpdateTime: Date, verboseMessage: DiagnosticMessage, skipOutputs?: ESMap<Path, string>) {
const { host } = state;
const outputs = getAllProjectOutputs(proj, !host.useCaseSensitiveFileNames());
if (!skipOutputs || outputs.length !== skipOutputs.size) {
+32 -32
View File
@@ -3400,7 +3400,7 @@ namespace ts {
// this map is used by transpiler to supply alternative names for dependencies (i.e. in case of bundling)
/* @internal */
renamedDependencies?: ReadonlyMap<string, string>;
renamedDependencies?: ReadonlyESMap<string, string>;
/**
* lib.d.ts should have a reference comment like
@@ -3426,7 +3426,7 @@ namespace ts {
// JS identifier-declarations that are intended to merge with globals
/* @internal */ jsGlobalAugmentations?: SymbolTable;
/* @internal */ identifiers: Map<string, string>; // Map from a string to an interned string
/* @internal */ identifiers: ESMap<string, string>; // Map from a string to an interned string
/* @internal */ nodeCount: number;
/* @internal */ identifierCount: number;
/* @internal */ symbolCount: number;
@@ -3454,8 +3454,8 @@ namespace ts {
// Stores a mapping 'external module reference text' -> 'resolved file name' | undefined
// It is used to resolve module names in the checker.
// Content of this field should never be used directly - use getResolvedModuleFileName/setResolvedModuleFileName functions instead
/* @internal */ resolvedModules?: Map<string, ResolvedModuleFull | undefined>;
/* @internal */ resolvedTypeReferenceDirectiveNames: Map<string, ResolvedTypeReferenceDirective | undefined>;
/* @internal */ resolvedModules?: ESMap<string, ResolvedModuleFull | undefined>;
/* @internal */ resolvedTypeReferenceDirectiveNames: ESMap<string, ResolvedTypeReferenceDirective | undefined>;
/* @internal */ imports: readonly StringLiteralLike[];
// Identifier only if `declare global`
/* @internal */ moduleAugmentations: readonly (StringLiteral | Identifier)[];
@@ -3687,7 +3687,7 @@ namespace ts {
/* @internal */
getRefFileMap(): MultiMap<Path, RefFile> | undefined;
/* @internal */
getFilesByNameMap(): Map<string, SourceFile | false | undefined>;
getFilesByNameMap(): ESMap<string, SourceFile | false | undefined>;
/**
* Emits the JavaScript and declaration files. If targetSourceFile is not specified, then
@@ -3737,7 +3737,7 @@ namespace ts {
getRelationCacheSizes(): { assignable: number, identity: number, subtype: number, strictSubtype: number };
/* @internal */ getFileProcessingDiagnostics(): DiagnosticCollection;
/* @internal */ getResolvedTypeReferenceDirectives(): Map<string, ResolvedTypeReferenceDirective | undefined>;
/* @internal */ getResolvedTypeReferenceDirectives(): ESMap<string, ResolvedTypeReferenceDirective | undefined>;
isSourceFileFromExternalLibrary(file: SourceFile): boolean;
isSourceFileDefaultLibrary(file: SourceFile): boolean;
@@ -3748,7 +3748,7 @@ namespace ts {
/* @internal */ getLibFileFromReference(ref: FileReference): SourceFile | undefined;
/** Given a source file, get the name of the package it was imported from. */
/* @internal */ sourceFileToPackageName: Map<string, string>;
/* @internal */ sourceFileToPackageName: ESMap<string, string>;
/** Set of all source files that some other source file redirects to. */
/* @internal */ redirectTargetsMap: MultiMap<string, string>;
/** Is the file emitted file */
@@ -3765,7 +3765,7 @@ namespace ts {
/*@internal*/ isSourceOfProjectReferenceRedirect(fileName: string): boolean;
/*@internal*/ getProgramBuildInfo?(): ProgramBuildInfo | undefined;
/*@internal*/ emitBuildInfo(writeFile?: WriteFileCallback, cancellationToken?: CancellationToken): EmitResult;
/*@internal*/ getProbableSymlinks(): ReadonlyMap<string, string>;
/*@internal*/ getProbableSymlinks(): ReadonlyESMap<string, string>;
/**
* This implementation handles file exists to be true if file is source of project reference redirect when program is created using useSourceOfProjectReferenceRedirect
*/
@@ -3777,7 +3777,7 @@ namespace ts {
}
/* @internal */
export type RedirectTargetsMap = ReadonlyMap<string, readonly string[]>;
export type RedirectTargetsMap = ReadonlyESMap<string, readonly string[]>;
export interface ResolvedProjectReference {
commandLine: ParsedCommandLine;
@@ -3873,7 +3873,7 @@ namespace ts {
getSourceFiles(): readonly SourceFile[];
getSourceFile(fileName: string): SourceFile | undefined;
getResolvedTypeReferenceDirectives(): ReadonlyMap<string, ResolvedTypeReferenceDirective | undefined>;
getResolvedTypeReferenceDirectives(): ReadonlyESMap<string, ResolvedTypeReferenceDirective | undefined>;
getProjectReferenceRedirect(fileName: string): string | undefined;
isSourceOfProjectReferenceRedirect(fileName: string): boolean;
@@ -4515,10 +4515,9 @@ namespace ts {
Transient = 1 << 25, // Transient symbol (created during type check)
Assignment = 1 << 26, // Assignment treated as declaration (eg `this.prop = 1`)
ModuleExports = 1 << 27, // Symbol for CommonJS `module` of `module.exports`
Deprecated = 1 << 28, // Symbol has Deprecated declaration tag (eg `@deprecated`)
/* @internal */
All = FunctionScopedVariable | BlockScopedVariable | Property | EnumMember | Function | Class | Interface | ConstEnum | RegularEnum | ValueModule | NamespaceModule | TypeLiteral
| ObjectLiteral | Method | Constructor | GetAccessor | SetAccessor | Signature | TypeParameter | TypeAlias | ExportValue | Alias | Prototype | ExportStar | Optional | Transient | Deprecated,
| ObjectLiteral | Method | Constructor | GetAccessor | SetAccessor | Signature | TypeParameter | TypeAlias | ExportValue | Alias | Prototype | ExportStar | Optional | Transient,
Enum = RegularEnum | ConstEnum,
Variable = FunctionScopedVariable | BlockScopedVariable,
@@ -4597,7 +4596,7 @@ namespace ts {
/* @internal */ isReferenced?: SymbolFlags; // True if the symbol is referenced elsewhere. Keeps track of the meaning of a reference in case a symbol is both a type parameter and parameter.
/* @internal */ isReplaceableByMethod?: boolean; // Can this Javascript class property be replaced by a method symbol?
/* @internal */ isAssigned?: boolean; // True if the symbol is a parameter with assignments
/* @internal */ assignmentDeclarationMembers?: Map<number, Declaration>; // detected late-bound assignment declarations associated with the symbol
/* @internal */ assignmentDeclarationMembers?: ESMap<number, Declaration>; // detected late-bound assignment declarations associated with the symbol
}
/* @internal */
@@ -4610,8 +4609,8 @@ namespace ts {
declaredType?: Type; // Type of class, interface, enum, type alias, or type parameter
typeParameters?: TypeParameter[]; // Type parameters of type alias (undefined if non-generic)
outerTypeParameters?: TypeParameter[]; // Outer type parameters of anonymous object type
instantiations?: Map<string, Type>; // Instantiations of generic type alias (undefined if non-generic)
inferredClassSymbol?: Map<SymbolId, TransientSymbol>; // Symbol of an inferred ES5 constructor function
instantiations?: ESMap<string, Type>; // Instantiations of generic type alias (undefined if non-generic)
inferredClassSymbol?: ESMap<SymbolId, TransientSymbol>; // Symbol of an inferred ES5 constructor function
mapper?: TypeMapper; // Type mapper for instantiation alias
referenced?: boolean; // True if alias symbol has been referenced as a value that can be emitted
constEnumReferenced?: boolean; // True if alias symbol resolves to a const enum and is referenced as a value ('referenced' will be false)
@@ -4630,9 +4629,9 @@ namespace ts {
enumKind?: EnumKind; // Enum declaration classification
originatingImport?: ImportDeclaration | ImportCall; // Import declaration which produced the symbol, present if the symbol is marked as uncallable but had call signatures in `resolveESModuleSymbol`
lateSymbol?: Symbol; // Late-bound symbol for a computed property
specifierCache?: Map<string, string>; // For symbols corresponding to external modules, a cache of incoming path -> module specifier name mappings
specifierCache?: ESMap<string, string>; // For symbols corresponding to external modules, a cache of incoming path -> module specifier name mappings
extendedContainers?: Symbol[]; // Containers (other than the parent) which this symbol is aliased in
extendedContainersByFile?: Map<NodeId, Symbol[]>; // Containers (other than the parent) which this symbol is aliased in
extendedContainersByFile?: ESMap<NodeId, Symbol[]>; // Containers (other than the parent) which this symbol is aliased in
variances?: VarianceFlags[]; // Alias symbol type argument variance cache
deferralConstituents?: Type[]; // Calculated list of constituents for a deferred type
deferralParent?: Type; // Source union/intersection of a deferred type
@@ -4724,10 +4723,12 @@ namespace ts {
export type __String = (string & { __escapedIdentifier: void }) | (void & { __escapedIdentifier: void }) | InternalSymbolName; // eslint-disable-line @typescript-eslint/naming-convention
/** ReadonlyMap where keys are `__String`s. */
export type ReadonlyUnderscoreEscapedMap<T> = ReadonlyMap<__String, T>;
export interface ReadonlyUnderscoreEscapedMap<T> extends ReadonlyESMap<__String, T> {
}
/** Map where keys are `__String`s. */
export type UnderscoreEscapedMap<T> = Map<__String, T>;
export interface UnderscoreEscapedMap<T> extends ESMap<__String, T>, ReadonlyUnderscoreEscapedMap<T> {
}
/** SymbolTable based on ES6 Map interface. */
export type SymbolTable = UnderscoreEscapedMap<Symbol>;
@@ -4786,10 +4787,10 @@ namespace ts {
switchTypes?: Type[]; // Cached array of switch case expression types
jsxNamespace?: Symbol | false; // Resolved jsx namespace symbol for this node
contextFreeType?: Type; // Cached context-free type used by the first pass of inference; used when a function's return is partially contextually sensitive
deferredNodes?: Map<NodeId, Node>; // Set of nodes whose checking has been deferred
deferredNodes?: ESMap<NodeId, Node>; // Set of nodes whose checking has been deferred
capturedBlockScopeBindings?: Symbol[]; // Block-scoped bindings captured beneath this part of an IterationStatement
outerTypeParameters?: TypeParameter[]; // Outer type parameters of anonymous object type
instantiations?: Map<string, Type>; // Instantiations of generic type alias (undefined if non-generic)
instantiations?: ESMap<string, Type>; // Instantiations of generic type alias (undefined if non-generic)
isExhaustive?: boolean; // Is node an exhaustive switch statement
skipDirectInference?: true; // Flag set by the API `getContextualType` call on a node when `Completions` is passed to force the checker to skip making inferences to a node's type
declarationRequiresScopeChange?: boolean; // Set by `useOuterVariableScopeInParameter` in checker when downlevel emit would change the name resolution scope inside of a parameter.
@@ -4865,7 +4866,6 @@ namespace ts {
// 'Narrowable' types are types where narrowing actually narrows.
// This *should* be every type other than null, undefined, void, and never
Narrowable = Any | Unknown | StructuredOrInstantiable | StringLike | NumberLike | BigIntLike | BooleanLike | ESSymbol | UniqueESSymbol | NonPrimitive,
NotUnionOrUnit = Any | Unknown | ESSymbol | Object | NonPrimitive,
/* @internal */
NotPrimitiveUnion = Any | Unknown | Enum | Void | Never | StructuredOrInstantiable,
// The following flags are aggregated during union and intersection type construction
@@ -5092,7 +5092,7 @@ namespace ts {
// Generic class and interface types
export interface GenericType extends InterfaceType, TypeReference {
/* @internal */
instantiations: Map<string, TypeReference>; // Generic instantiation cache
instantiations: ESMap<string, TypeReference>; // Generic instantiation cache
/* @internal */
variances?: VarianceFlags[]; // Variance of each type parameter
}
@@ -5280,7 +5280,7 @@ namespace ts {
isDistributive: boolean;
inferTypeParameters?: TypeParameter[];
outerTypeParameters?: TypeParameter[];
instantiations?: Map<string, Type>;
instantiations?: Map<Type>;
aliasSymbol?: Symbol;
aliasTypeArguments?: Type[];
}
@@ -5375,7 +5375,7 @@ namespace ts {
/* @internal */
isolatedSignatureType?: ObjectType; // A manufactured type that just contains the signature for purposes of signature comparison
/* @internal */
instantiations?: Map<string, Signature>; // Generic signature instantiation cache
instantiations?: ESMap<string, Signature>; // Generic signature instantiation cache
}
export const enum IndexKind {
@@ -5896,7 +5896,7 @@ namespace ts {
/* @internal */
export interface CommandLineOptionBase {
name: string;
type: "string" | "number" | "boolean" | "object" | "list" | Map<string, number | string>; // a value of a primitive type, or an object literal mapping named values to actual values
type: "string" | "number" | "boolean" | "object" | "list" | ESMap<string, number | string>; // a value of a primitive type, or an object literal mapping named values to actual values
isFilePath?: boolean; // True if option value is a path or fileName
shortName?: string; // A short mnemonic for convenience - for instance, 'h' can be used in place of 'help'
description?: DiagnosticMessage; // The message describing what the command line switch does
@@ -5921,7 +5921,7 @@ namespace ts {
/* @internal */
export interface CommandLineOptionOfCustomType extends CommandLineOptionBase {
type: Map<string, number | string>; // an object literal mapping named values to actual values
type: ESMap<string, number | string>; // an object literal mapping named values to actual values
}
/* @internal */
@@ -5934,7 +5934,7 @@ namespace ts {
/* @internal */
export interface TsConfigOnlyOption extends CommandLineOptionBase {
type: "object";
elementOptions?: Map<string, CommandLineOption>;
elementOptions?: ESMap<string, CommandLineOption>;
extraKeyDiagnostics?: DidYouMeanOptionsDiagnostics;
}
@@ -6223,7 +6223,7 @@ namespace ts {
// TODO: later handle this in better way in builder host instead once the api for tsbuild finalizes and doesn't use compilerHost as base
/*@internal*/createDirectory?(directory: string): void;
/*@internal*/getSymlinks?(): ReadonlyMap<string, string>;
/*@internal*/getSymlinks?(): ReadonlyESMap<string, string>;
}
/** true if --out otherwise source file name */
@@ -7736,7 +7736,7 @@ namespace ts {
fileExists(path: string): boolean;
getCurrentDirectory(): string;
readFile?(path: string): string | undefined;
getProbableSymlinks?(files: readonly SourceFile[]): ReadonlyMap<string, string>;
getProbableSymlinks?(files: readonly SourceFile[]): ReadonlyESMap<string, string>;
getGlobalTypingsCacheLocation?(): string | undefined;
getSourceFiles(): readonly SourceFile[];
@@ -8000,7 +8000,7 @@ namespace ts {
export type PragmaPseudoMapEntry = {[K in keyof PragmaPseudoMap]: {name: K, args: PragmaPseudoMap[K]}}[keyof PragmaPseudoMap];
/* @internal */
export interface ReadonlyPragmaMap extends ReadonlyMap<string, PragmaPseudoMap[keyof PragmaPseudoMap] | PragmaPseudoMap[keyof PragmaPseudoMap][]> {
export interface ReadonlyPragmaMap extends ReadonlyESMap<string, PragmaPseudoMap[keyof PragmaPseudoMap] | PragmaPseudoMap[keyof PragmaPseudoMap][]> {
get<TKey extends keyof PragmaPseudoMap>(key: TKey): PragmaPseudoMap[TKey] | PragmaPseudoMap[TKey][];
forEach(action: <TKey extends keyof PragmaPseudoMap>(value: PragmaPseudoMap[TKey] | PragmaPseudoMap[TKey][], key: TKey) => void): void;
}
@@ -8011,7 +8011,7 @@ namespace ts {
* in multiple places
*/
/* @internal */
export interface PragmaMap extends Map<string, PragmaPseudoMap[keyof PragmaPseudoMap] | PragmaPseudoMap[keyof PragmaPseudoMap][]>, ReadonlyPragmaMap {
export interface PragmaMap extends ESMap<string, PragmaPseudoMap[keyof PragmaPseudoMap] | PragmaPseudoMap[keyof PragmaPseudoMap][]>, ReadonlyPragmaMap {
set<TKey extends keyof PragmaPseudoMap>(key: TKey, value: PragmaPseudoMap[TKey] | PragmaPseudoMap[TKey][]): this;
get<TKey extends keyof PragmaPseudoMap>(key: TKey): PragmaPseudoMap[TKey] | PragmaPseudoMap[TKey][];
forEach(action: <TKey extends keyof PragmaPseudoMap>(value: PragmaPseudoMap[TKey] | PragmaPseudoMap[TKey][], key: TKey) => void): void;
+18 -14
View File
@@ -136,7 +136,7 @@ namespace ts {
* Calls `callback` for each entry in the map, returning the first truthy result.
* Use `map.forEach` instead for normal iteration.
*/
export function forEachEntry<K, V, U>(map: ReadonlyMap<K, V>, callback: (value: V, key: K) => U | undefined): U | undefined {
export function forEachEntry<K, V, U>(map: ReadonlyESMap<K, V>, callback: (value: V, key: K) => U | undefined): U | undefined {
const iterator = map.entries();
for (let iterResult = iterator.next(); !iterResult.done; iterResult = iterator.next()) {
const [key, value] = iterResult.value;
@@ -161,7 +161,7 @@ namespace ts {
}
/** Copy entries from `source` to `target`. */
export function copyEntries<K, V>(source: ReadonlyMap<K, V>, target: Map<K, V>): void {
export function copyEntries<K, V>(source: ReadonlyESMap<K, V>, target: ESMap<K, V>): void {
source.forEach((value, key) => {
target.set(key, value);
});
@@ -233,7 +233,7 @@ namespace ts {
export function hasChangesInResolutions<T>(
names: readonly string[],
newResolutions: readonly T[],
oldResolutions: ReadonlyMap<string, T> | undefined,
oldResolutions: ReadonlyESMap<string, T> | undefined,
comparer: (oldResolution: T, newResolution: T) => boolean): boolean {
Debug.assert(names.length === newResolutions.length);
@@ -2203,7 +2203,7 @@ namespace ts {
}
return AssignmentDeclarationKind.ObjectDefinePropertyValue;
}
if (expr.operatorToken.kind !== SyntaxKind.EqualsToken || !isAccessExpression(expr.left)) {
if (expr.operatorToken.kind !== SyntaxKind.EqualsToken || !isAccessExpression(expr.left) || isVoidZero(getRightMostAssignedExpression(expr))) {
return AssignmentDeclarationKind.None;
}
if (isBindableStaticNameExpression(expr.left.expression, /*excludeThisKeyword*/ true) && getElementOrPropertyAccessName(expr.left) === "prototype" && isObjectLiteralExpression(getInitializerOfBinaryExpression(expr))) {
@@ -2213,6 +2213,10 @@ namespace ts {
return getAssignmentDeclarationPropertyAccessKind(expr.left);
}
function isVoidZero(node: Node) {
return isVoidExpression(node) && isNumericLiteral(node.expression) && node.expression.text === "0";
}
/**
* Does not handle signed numeric names like `a[+0]` - handling those would require handling prefix unary expressions
* throughout late binding handling as well, which is awkward (but ultimately probably doable if there is demand)
@@ -5244,7 +5248,7 @@ namespace ts {
/**
* clears already present map by calling onDeleteExistingValue callback before deleting that key/value
*/
export function clearMap<T>(map: { forEach: Map<string, T>["forEach"]; clear: Map<string, T>["clear"]; }, onDeleteValue: (valueInMap: T, key: string) => void) {
export function clearMap<T>(map: { forEach: ESMap<string, T>["forEach"]; clear: ESMap<string, T>["clear"]; }, onDeleteValue: (valueInMap: T, key: string) => void) {
// Remove all
map.forEach(onDeleteValue);
map.clear();
@@ -5266,8 +5270,8 @@ namespace ts {
* Mutates the map with newMap such that keys in map will be same as newMap.
*/
export function mutateMapSkippingNewValues<T, U>(
map: Map<string, T>,
newMap: ReadonlyMap<string, U>,
map: ESMap<string, T>,
newMap: ReadonlyESMap<string, U>,
options: MutateMapSkippingNewValuesOptions<T, U>
) {
const { onDeleteValue, onExistingValue } = options;
@@ -5293,7 +5297,7 @@ namespace ts {
/**
* Mutates the map with newMap such that keys in map will be same as newMap.
*/
export function mutateMap<T, U>(map: Map<string, T>, newMap: ReadonlyMap<string, U>, options: MutateMapOptions<T, U>) {
export function mutateMap<T, U>(map: ESMap<string, T>, newMap: ReadonlyESMap<string, U>, options: MutateMapOptions<T, U>) {
// Needs update
mutateMapSkippingNewValues(map, newMap, options);
@@ -5363,9 +5367,9 @@ namespace ts {
}
/** Add a value to a set, and return true if it wasn't already present. */
export function addToSeen(seen: Map<string, true>, key: string | number): boolean;
export function addToSeen<T>(seen: Map<string, T>, key: string | number, value: T): boolean;
export function addToSeen<T>(seen: Map<string, T>, key: string | number, value: T = true as any): boolean {
export function addToSeen(seen: ESMap<string, true>, key: string | number): boolean;
export function addToSeen<T>(seen: ESMap<string, T>, key: string | number, value: T): boolean;
export function addToSeen<T>(seen: ESMap<string, T>, key: string | number, value: T = true as any): boolean {
key = String(key);
if (seen.has(key)) {
return false;
@@ -5920,7 +5924,7 @@ namespace ts {
return true;
}
export function discoverProbableSymlinks(files: readonly SourceFile[], getCanonicalFileName: GetCanonicalFileName, cwd: string): ReadonlyMap<string, string> {
export function discoverProbableSymlinks(files: readonly SourceFile[], getCanonicalFileName: GetCanonicalFileName, cwd: string): ReadonlyESMap<string, string> {
const result = new Map<string, string>();
const symlinks = flatten<readonly [string, string]>(mapDefined(files, sf =>
sf.resolvedModules && compact(arrayFrom(mapIterator(sf.resolvedModules.values(), res =>
@@ -6550,10 +6554,10 @@ namespace ts {
export type NodeSet<TNode extends Node> = Set<TNode>;
/** @deprecated Use `ReadonlyMap<TNode, TValue>` instead. */
export type ReadonlyNodeMap<TNode extends Node, TValue> = ReadonlyMap<TNode, TValue>;
export type ReadonlyNodeMap<TNode extends Node, TValue> = ReadonlyESMap<TNode, TValue>;
/** @deprecated Use `Map<TNode, TValue>` instead. */
export type NodeMap<TNode extends Node, TValue> = Map<TNode, TValue>;
export type NodeMap<TNode extends Node, TValue> = ESMap<TNode, TValue>;
export function rangeOfNode(node: Node): TextRange {
return { pos: getTokenPosOfNode(node), end: node.end };
+2 -2
View File
@@ -246,8 +246,8 @@ namespace ts {
let builderProgram: T;
let reloadLevel: ConfigFileProgramReloadLevel; // level to indicate if the program needs to be reloaded from config file/just filenames etc
let missingFilesMap: Map<Path, FileWatcher>; // Map of file watchers for the missing files
let watchedWildcardDirectories: Map<string, WildcardDirectoryWatcher>; // map of watchers for the wild card directories in the config file
let missingFilesMap: ESMap<Path, FileWatcher>; // Map of file watchers for the missing files
let watchedWildcardDirectories: ESMap<string, WildcardDirectoryWatcher>; // map of watchers for the wild card directories in the config file
let timerToUpdateProgram: any; // timer callback to recompile the program
let timerToInvalidateFailedLookupResolutions: any; // timer callback to invalidate resolutions for changes in failed lookup locations
+3 -3
View File
@@ -262,7 +262,7 @@ namespace ts {
*/
export function updateMissingFilePathsWatch(
program: Program,
missingFileWatches: Map<Path, FileWatcher>,
missingFileWatches: ESMap<Path, FileWatcher>,
createMissingFileWatch: (missingFilePath: Path) => FileWatcher,
) {
const missingFilePaths = program.getMissingFilePaths();
@@ -294,8 +294,8 @@ namespace ts {
* as wildcard directories wont change unless reloading config file
*/
export function updateWatchingWildcardDirectories(
existingWatchedForWildcards: Map<string, WildcardDirectoryWatcher>,
wildcardDirectories: Map<string, WatchDirectoryFlags>,
existingWatchedForWildcards: ESMap<string, WildcardDirectoryWatcher>,
wildcardDirectories: ESMap<string, WatchDirectoryFlags>,
watchDirectory: (directory: string, flags: WatchDirectoryFlags) => FileWatcher
) {
mutateMap(
+1 -1
View File
@@ -100,7 +100,7 @@ namespace ts {
if (option.name === "lib") {
description = getDiagnosticText(option.description);
const element = (<CommandLineOptionOfListType>option).element;
const typeMap = <Map<string, number | string>>element.type;
const typeMap = <ESMap<string, number | string>>element.type;
optionsDescriptionMap.set(description, arrayFrom(typeMap.keys()).map(key => `'${key}'`));
}
else {
+1 -1
View File
@@ -35,7 +35,7 @@ namespace ts.server {
export class SessionClient implements LanguageService {
private sequence = 0;
private lineMaps: Map<string, number[]> = new Map<string, number[]>();
private lineMaps = new Map<string, number[]>();
private messages: string[] = [];
private lastRenameEntry: RenameEntry | undefined;
+8 -7
View File
@@ -29,7 +29,7 @@ namespace FourSlash {
symlinks: vfs.FileSet | undefined;
// A mapping from marker names to name/position pairs
markerPositions: ts.Map<string, Marker>;
markerPositions: ts.ESMap<string, Marker>;
markers: Marker[];
@@ -1426,7 +1426,7 @@ namespace FourSlash {
this.raiseError("Could not get a help signature");
}
const selectedItem = help.items[help.selectedItemIndex];
const selectedItem = help.items[options.overrideSelectedItemIndex ?? help.selectedItemIndex];
// Argument index may exceed number of parameters
const currentParameter = selectedItem.parameters[help.argumentIndex] as ts.SignatureHelpParameter | undefined;
@@ -1478,6 +1478,7 @@ namespace FourSlash {
"isVariadic",
"tags",
"argumentCount",
"overrideSelectedItemIndex"
];
for (const key in options) {
if (!ts.contains(allKeys, key)) {
@@ -2340,7 +2341,7 @@ namespace FourSlash {
return this.getRanges().filter(r => r.fileName === fileName);
}
public rangesByText(): ts.Map<string, Range[]> {
public rangesByText(): ts.ESMap<string, Range[]> {
if (this.testData.rangesByText) return this.testData.rangesByText;
const result = ts.createMultiMap<Range>();
this.testData.rangesByText = result;
@@ -3420,7 +3421,7 @@ namespace FourSlash {
return text;
}
private formatCallHierarchyItem(file: FourSlashFile, callHierarchyItem: ts.CallHierarchyItem, direction: CallHierarchyItemDirection, seen: ts.Map<string, boolean>, prefix: string, trailingPrefix: string = prefix) {
private formatCallHierarchyItem(file: FourSlashFile, callHierarchyItem: ts.CallHierarchyItem, direction: CallHierarchyItemDirection, seen: ts.ESMap<string, boolean>, prefix: string, trailingPrefix: string = prefix) {
const key = `${callHierarchyItem.file}|${JSON.stringify(callHierarchyItem.span)}|${direction}`;
const alreadySeen = seen.has(key);
seen.set(key, true);
@@ -3944,7 +3945,7 @@ namespace FourSlash {
throw new Error(errorMessage);
}
function recordObjectMarker(fileName: string, location: LocationInformation, text: string, markerMap: ts.Map<string, Marker>, markers: Marker[]): Marker | undefined {
function recordObjectMarker(fileName: string, location: LocationInformation, text: string, markerMap: ts.ESMap<string, Marker>, markers: Marker[]): Marker | undefined {
let markerValue: any;
try {
// Attempt to parse the marker value as JSON
@@ -3975,7 +3976,7 @@ namespace FourSlash {
return marker;
}
function recordMarker(fileName: string, location: LocationInformation, name: string, markerMap: ts.Map<string, Marker>, markers: Marker[]): Marker | undefined {
function recordMarker(fileName: string, location: LocationInformation, name: string, markerMap: ts.ESMap<string, Marker>, markers: Marker[]): Marker | undefined {
const marker: Marker = {
fileName,
position: location.position
@@ -3994,7 +3995,7 @@ namespace FourSlash {
}
}
function parseFileContent(content: string, fileName: string, markerMap: ts.Map<string, Marker>, markers: Marker[], ranges: Range[]): FourSlashFile {
function parseFileContent(content: string, fileName: string, markerMap: ts.ESMap<string, Marker>, markers: Marker[], ranges: Range[]): FourSlashFile {
content = chompLeadingSpace(content);
// Any slash-star comment with a character not in this string is not a marker.
+2 -1
View File
@@ -27,7 +27,7 @@ namespace FourSlashInterface {
return this.ranges().map(r => ts.createTextSpan(r.pos, r.end - r.pos));
}
public rangesByText(): ts.Map<string, FourSlash.Range[]> {
public rangesByText(): ts.ESMap<string, FourSlash.Range[]> {
return this.state.rangesByText();
}
@@ -1533,6 +1533,7 @@ namespace FourSlashInterface {
/** @default ts.emptyArray */
readonly tags?: readonly ts.JSDocTagInfo[];
readonly triggerReason?: ts.SignatureHelpTriggerReason;
readonly overrideSelectedItemIndex?: number;
}
export interface VerifyNavigateToOptions {
+5 -5
View File
@@ -243,7 +243,7 @@ namespace Harness {
export const es2015DefaultLibFileName = "lib.es2015.d.ts";
// Cache of lib files from "built/local"
let libFileNameSourceFileMap: ts.Map<string, ts.SourceFile> | undefined;
let libFileNameSourceFileMap: ts.ESMap<string, ts.SourceFile> | undefined;
export function getDefaultLibrarySourceFile(fileName = defaultLibFileName): ts.SourceFile | undefined {
if (!isDefaultLibraryFile(fileName)) {
@@ -313,7 +313,7 @@ namespace Harness {
{ name: "fullEmitPaths", type: "boolean" }
];
let optionsIndex: ts.Map<string, ts.CommandLineOption>;
let optionsIndex: ts.ESMap<string, ts.CommandLineOption>;
function getCommandLineOption(name: string): ts.CommandLineOption | undefined {
if (!optionsIndex) {
optionsIndex = new ts.Map<string, ts.CommandLineOption>();
@@ -958,7 +958,7 @@ namespace Harness {
}
}
function checkDuplicatedFileName(resultName: string, dupeCase: ts.Map<string, number>): string {
function checkDuplicatedFileName(resultName: string, dupeCase: ts.ESMap<string, number>): string {
resultName = sanitizeTestFilePath(resultName);
if (dupeCase.has(resultName)) {
// A different baseline filename should be manufactured if the names differ only in case, for windows compat
@@ -1066,9 +1066,9 @@ namespace Harness {
}
}
let booleanVaryByStarSettingValues: ts.Map<string, string | number> | undefined;
let booleanVaryByStarSettingValues: ts.ESMap<string, string | number> | undefined;
function getVaryByStarSettingValues(varyBy: string): ts.ReadonlyMap<string, string | number> | undefined {
function getVaryByStarSettingValues(varyBy: string): ts.ReadonlyESMap<string, string | number> | undefined {
const option = ts.forEach(ts.optionDeclarations, decl => ts.equateStringsCaseInsensitive(decl.name, varyBy) ? decl : undefined);
if (option) {
if (typeof option.type === "object") {
+1 -1
View File
@@ -126,7 +126,7 @@ namespace Harness.LanguageService {
export abstract class LanguageServiceAdapterHost {
public readonly sys = new fakes.System(new vfs.FileSystem(/*ignoreCase*/ true, { cwd: virtualFileSystemRoot }));
public typesRegistry: ts.Map<string, void> | undefined;
public typesRegistry: ts.ESMap<string, void> | undefined;
private scriptInfos: collections.SortedMap<string, ScriptInfo>;
constructor(protected cancellationToken = DefaultHostCancellationToken.instance,
+1 -1
View File
@@ -83,7 +83,7 @@ namespace Playback {
let recordLog: IoLog | undefined;
let replayLog: IoLog | undefined;
let replayFilesRead: ts.Map<string, IoLogFile> | undefined;
let replayFilesRead: ts.ESMap<string, IoLogFile> | undefined;
let recordLogFileNameBase = "";
interface Memoized<T> {
+22 -22
View File
@@ -36,7 +36,7 @@ interface Array<T> { length: number; [n: number]: T; }`
currentDirectory?: string;
newLine?: string;
windowsStyleRoot?: string;
environmentVariables?: Map<string, string>;
environmentVariables?: ESMap<string, string>;
runWithoutRecursiveWatches?: boolean;
runWithFallbackPolling?: boolean;
}
@@ -127,7 +127,7 @@ interface Array<T> { length: number; [n: number]: T; }`
return { close: () => map.remove(path, callback) };
}
function getDiffInKeys<T>(map: Map<string, T>, expectedKeys: readonly string[]) {
function getDiffInKeys<T>(map: ESMap<string, T>, expectedKeys: readonly string[]) {
if (map.size === expectedKeys.length) {
return "";
}
@@ -154,19 +154,19 @@ interface Array<T> { length: number; [n: number]: T; }`
return `\n\nNotInActual: ${notInActual}\nDuplicates: ${duplicates}\nInActualButNotInExpected: ${inActualNotExpected}`;
}
export function verifyMapSize(caption: string, map: Map<string, any>, expectedKeys: readonly string[]) {
export function verifyMapSize(caption: string, map: ESMap<string, any>, expectedKeys: readonly string[]) {
assert.equal(map.size, expectedKeys.length, `${caption}: incorrect size of map: Actual keys: ${arrayFrom(map.keys())} Expected: ${expectedKeys}${getDiffInKeys(map, expectedKeys)}`);
}
export type MapValueTester<T, U> = [Map<string, U[]> | undefined, (value: T) => U];
export type MapValueTester<T, U> = [ESMap<string, U[]> | undefined, (value: T) => U];
export function checkMap<T, U = undefined>(caption: string, actual: MultiMap<string, T>, expectedKeys: ReadonlyMap<string, number>, valueTester?: MapValueTester<T,U>): void;
export function checkMap<T, U = undefined>(caption: string, actual: MultiMap<string, T>, expectedKeys: ReadonlyESMap<string, number>, valueTester?: MapValueTester<T,U>): void;
export function checkMap<T, U = undefined>(caption: string, actual: MultiMap<string, T>, expectedKeys: readonly string[], eachKeyCount: number, valueTester?: MapValueTester<T, U>): void;
export function checkMap<T>(caption: string, actual: Map<string, T> | MultiMap<string, T>, expectedKeys: readonly string[], eachKeyCount: undefined): void;
export function checkMap<T>(caption: string, actual: ESMap<string, T> | MultiMap<string, T>, expectedKeys: readonly string[], eachKeyCount: undefined): void;
export function checkMap<T, U = undefined>(
caption: string,
actual: Map<string, T> | MultiMap<string, T>,
expectedKeysMapOrArray: ReadonlyMap<string, number> | readonly string[],
actual: ESMap<string, T> | MultiMap<string, T>,
expectedKeysMapOrArray: ReadonlyESMap<string, number> | readonly string[],
eachKeyCountOrValueTester?: number | MapValueTester<T, U>,
valueTester?: MapValueTester<T, U>) {
const expectedKeys = isArray(expectedKeysMapOrArray) ? arrayToMap(expectedKeysMapOrArray, s => s, () => eachKeyCountOrValueTester as number) : expectedKeysMapOrArray;
@@ -203,9 +203,9 @@ interface Array<T> { length: number; [n: number]: T; }`
fileName: string;
pollingInterval: PollingInterval;
}
export function checkWatchedFilesDetailed(host: TestServerHost, expectedFiles: ReadonlyMap<string, number>, expectedDetails?: Map<string, WatchFileDetails[]>): void;
export function checkWatchedFilesDetailed(host: TestServerHost, expectedFiles: readonly string[], eachFileWatchCount: number, expectedDetails?: Map<string, WatchFileDetails[]>): void;
export function checkWatchedFilesDetailed(host: TestServerHost, expectedFiles: ReadonlyMap<string, number> | readonly string[], eachFileWatchCountOrExpectedDetails?: number | Map<string, WatchFileDetails[]>, expectedDetails?: Map<string, WatchFileDetails[]>) {
export function checkWatchedFilesDetailed(host: TestServerHost, expectedFiles: ReadonlyESMap<string, number>, expectedDetails?: ESMap<string, WatchFileDetails[]>): void;
export function checkWatchedFilesDetailed(host: TestServerHost, expectedFiles: readonly string[], eachFileWatchCount: number, expectedDetails?: ESMap<string, WatchFileDetails[]>): void;
export function checkWatchedFilesDetailed(host: TestServerHost, expectedFiles: ReadonlyESMap<string, number> | readonly string[], eachFileWatchCountOrExpectedDetails?: number | ESMap<string, WatchFileDetails[]>, expectedDetails?: ESMap<string, WatchFileDetails[]>) {
if (!isNumber(eachFileWatchCountOrExpectedDetails)) expectedDetails = eachFileWatchCountOrExpectedDetails;
if (isArray(expectedFiles)) {
checkMap(
@@ -235,9 +235,9 @@ interface Array<T> { length: number; [n: number]: T; }`
fallbackPollingInterval: PollingInterval;
fallbackOptions: WatchOptions | undefined;
}
export function checkWatchedDirectoriesDetailed(host: TestServerHost, expectedDirectories: ReadonlyMap<string, number>, recursive: boolean, expectedDetails?: Map<string, WatchDirectoryDetails[]>): void;
export function checkWatchedDirectoriesDetailed(host: TestServerHost, expectedDirectories: readonly string[], eachDirectoryWatchCount: number, recursive: boolean, expectedDetails?: Map<string, WatchDirectoryDetails[]>): void;
export function checkWatchedDirectoriesDetailed(host: TestServerHost, expectedDirectories: ReadonlyMap<string, number> | readonly string[], recursiveOrEachDirectoryWatchCount: boolean | number, recursiveOrExpectedDetails?: boolean | Map<string, WatchDirectoryDetails[]>, expectedDetails?: Map<string, WatchDirectoryDetails[]>) {
export function checkWatchedDirectoriesDetailed(host: TestServerHost, expectedDirectories: ReadonlyESMap<string, number>, recursive: boolean, expectedDetails?: ESMap<string, WatchDirectoryDetails[]>): void;
export function checkWatchedDirectoriesDetailed(host: TestServerHost, expectedDirectories: readonly string[], eachDirectoryWatchCount: number, recursive: boolean, expectedDetails?: ESMap<string, WatchDirectoryDetails[]>): void;
export function checkWatchedDirectoriesDetailed(host: TestServerHost, expectedDirectories: ReadonlyESMap<string, number> | readonly string[], recursiveOrEachDirectoryWatchCount: boolean | number, recursiveOrExpectedDetails?: boolean | ESMap<string, WatchDirectoryDetails[]>, expectedDetails?: ESMap<string, WatchDirectoryDetails[]>) {
if (typeof recursiveOrExpectedDetails !== "boolean") expectedDetails = recursiveOrExpectedDetails;
if (isArray(expectedDirectories)) {
checkMap(
@@ -368,7 +368,7 @@ interface Array<T> { length: number; [n: number]: T; }`
fileOrFolderorSymLinkList: readonly FileOrFolderOrSymLink[];
newLine?: string;
useWindowsStylePaths?: boolean;
environmentVariables?: Map<string, string>;
environmentVariables?: ESMap<string, string>;
}
export class TestServerHost implements server.ServerHost, FormatDiagnosticsHost, ModuleResolutionHost {
@@ -376,7 +376,7 @@ interface Array<T> { length: number; [n: number]: T; }`
private readonly output: string[] = [];
private fs: Map<Path, FSEntry> = new Map();
private fs: ESMap<Path, FSEntry> = new Map();
private time = timeIncrements;
getCanonicalFileName: (s: string) => string;
private toPath: (f: string) => Path;
@@ -391,7 +391,7 @@ interface Array<T> { length: number; [n: number]: T; }`
public readonly useCaseSensitiveFileNames: boolean;
public readonly newLine: string;
public readonly windowsStyleRoot?: string;
private readonly environmentVariables?: Map<string, string>;
private readonly environmentVariables?: ESMap<string, string>;
private readonly executingFilePath: string;
private readonly currentDirectory: string;
public require: ((initialPath: string, moduleName: string) => RequireResult) | undefined;
@@ -1042,7 +1042,7 @@ interface Array<T> { length: number; [n: number]: T; }`
this.clearOutput();
}
snap(): Map<Path, FSEntry> {
snap(): ESMap<Path, FSEntry> {
const result = new Map<Path, FSEntry>();
this.fs.forEach((value, key) => {
const cloneValue = clone(value);
@@ -1055,8 +1055,8 @@ interface Array<T> { length: number; [n: number]: T; }`
return result;
}
writtenFiles?: Map<Path, number>;
diff(baseline: string[], base: Map<string, FSEntry> = new Map()) {
writtenFiles?: ESMap<Path, number>;
diff(baseline: string[], base: ESMap<string, FSEntry> = new Map()) {
this.fs.forEach(newFsEntry => {
diffFsEntry(baseline, base.get(newFsEntry.path), newFsEntry, this.writtenFiles);
});
@@ -1115,7 +1115,7 @@ interface Array<T> { length: number; [n: number]: T; }`
function diffFsSymLink(baseline: string[], fsEntry: FsSymLink) {
baseline.push(`//// [${fsEntry.fullPath}] symlink(${fsEntry.symLink})`);
}
function diffFsEntry(baseline: string[], oldFsEntry: FSEntry | undefined, newFsEntry: FSEntry | undefined, writtenFiles: Map<string, any> | undefined): void {
function diffFsEntry(baseline: string[], oldFsEntry: FSEntry | undefined, newFsEntry: FSEntry | undefined, writtenFiles: ESMap<string, any> | undefined): void {
const file = newFsEntry && newFsEntry.fullPath;
if (isFsFile(oldFsEntry)) {
if (isFsFile(newFsEntry)) {
@@ -1208,7 +1208,7 @@ interface Array<T> { length: number; [n: number]: T; }`
}
}
export type TestServerHostTrackingWrittenFiles = TestServerHost & { writtenFiles: Map<Path, number>; };
export type TestServerHostTrackingWrittenFiles = TestServerHost & { writtenFiles: ESMap<Path, number>; };
export function changeToHostTrackingWrittenFiles(inputHost: TestServerHost) {
const host = inputHost as TestServerHostTrackingWrittenFiles;
+3 -3
View File
@@ -77,7 +77,7 @@ namespace ts.JsTyping {
/**
* A map of loose file names to library names that we are confident require typings
*/
export type SafeList = ReadonlyMap<string, string>;
export type SafeList = ReadonlyESMap<string, string>;
export function loadSafeList(host: TypingResolutionHost, safeListPath: Path): SafeList {
const result = readConfigFile(safeListPath, path => host.readFile(path));
@@ -107,10 +107,10 @@ namespace ts.JsTyping {
fileNames: string[],
projectRootPath: Path,
safeList: SafeList,
packageNameToTypingLocation: ReadonlyMap<string, CachedTyping>,
packageNameToTypingLocation: ReadonlyESMap<string, CachedTyping>,
typeAcquisition: TypeAcquisition,
unresolvedImports: readonly string[],
typesRegistry: ReadonlyMap<string, MapLike<string>>):
typesRegistry: ReadonlyESMap<string, MapLike<string>>):
{ cachedTypingPaths: string[], newTypingNames: string[], filesToWatch: string[] } {
if (!typeAcquisition || !typeAcquisition.enable) {
@@ -2581,7 +2581,7 @@
<Str Cat="Text">
<Val><![CDATA[Cannot find lib definition for '{0}'.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[找不到“{0}”的 LIB 定义。]]></Val>
<Val><![CDATA[找不到“{0}”的定义。]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
@@ -2590,7 +2590,7 @@
<Str Cat="Text">
<Val><![CDATA[Cannot find lib definition for '{0}'. Did you mean '{1}'?]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[找不到“{0}”的 LIB 定义。你是指“{1}”?]]></Val>
<Val><![CDATA[找不到“{0}”的定义。你是指“{1}”?]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
@@ -4068,6 +4068,15 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Did_you_mean_to_use_a_Colon_An_can_only_follow_a_property_name_when_the_containing_object_literal_is_1312" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Did you mean to use a ':'? An '=' can only follow a property name when the containing object literal is part of a destructuring pattern.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[你的意思是使用 ":" 吗? 当包含对象文字属于解构模式时,"=" 只能跟在属性名称的后面。]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Did_you_mean_to_use_new_with_this_expression_6213" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Did you mean to use 'new' with this expression?]]></Val>
@@ -4446,6 +4455,9 @@
<Item ItemId=";Element_at_index_0_is_variadic_in_one_type_but_not_in_the_other_2622" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Element at index {0} is variadic in one type but not in the other.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[索引 {0} 处的元素在其中一个类型中是可变元素,在另一个类型中却不是。]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
@@ -8871,15 +8883,6 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_destructuring_90009" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove destructuring]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[删除解构]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_import_from_0_90005" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove import from '{0}']]></Val>
@@ -8943,6 +8946,24 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_unused_declarations_for_Colon_0_90041" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove unused declarations for: '{0}']]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[为“{0}”删除未使用的声明]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_unused_destructuring_declaration_90039" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove unused destructuring declaration]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[删除未使用的解构声明]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_unused_label_95053" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove unused label]]></Val>
@@ -9615,12 +9636,18 @@
<Item ItemId=";Source_has_0_element_s_but_target_allows_only_1_2619" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Source has {0} element(s) but target allows only {1}.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[源具有 {0} 个元素,但目标仅允许 {1} 个。]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Source_has_0_element_s_but_target_requires_1_2618" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Source has {0} element(s) but target requires {1}.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[源具有 {0} 个元素,但目标需要 {1} 个。]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
@@ -9996,6 +10023,15 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Switch_each_misused_0_to_1_95138" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Switch each misused '{0}' to '{1}']]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[将每个误用的“{0}”切换到“{1}”]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Symbol_reference_does_not_refer_to_the_global_Symbol_constructor_object_2470" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA['Symbol' reference does not refer to the global Symbol constructor object.]]></Val>
@@ -10044,12 +10080,18 @@
<Item ItemId=";Target_allows_only_0_element_s_but_source_may_have_more_2621" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Target allows only {0} element(s) but source may have more.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[目标仅允许 {0} 个元素,但源中的元素可能更多。]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Target_requires_0_element_s_but_source_may_have_fewer_2620" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Target requires {0} element(s) but source may have fewer.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[目标仅允许 {0} 个元素,但源中的元素可能不够。]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
@@ -12876,15 +12918,6 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment_1312" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA['=' can only be used in an object literal property inside a destructuring assignment.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA["=" 只可在重构赋值内部的对象文字属性中使用。]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";case_or_default_expected_1130" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA['case' or 'default' expected.]]></Val>
@@ -2581,7 +2581,7 @@
<Str Cat="Text">
<Val><![CDATA[Cannot find lib definition for '{0}'.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[找不到 '{0}' 的 lib 定義。]]></Val>
<Val><![CDATA[找不到 '{0}' 的程式庫定義。]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
@@ -2590,7 +2590,7 @@
<Str Cat="Text">
<Val><![CDATA[Cannot find lib definition for '{0}'. Did you mean '{1}'?]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[找不到 '{0}' 的 lib 定義。您是指 '{1}' 嗎?]]></Val>
<Val><![CDATA[找不到 '{0}' 的程式庫定義。您是指 '{1}' 嗎?]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
@@ -4068,6 +4068,15 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Did_you_mean_to_use_a_Colon_When_following_property_names_in_an_object_literal_implies_a_destructuri_1312" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Did you mean to use a ':'? When following property names in an object literal, '=' implies a destructuring assignment.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[確定要使用 ':' 嗎? 當物件常值包含屬性名稱時,'=' 表示解構指派。]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Did_you_mean_to_use_new_with_this_expression_6213" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Did you mean to use 'new' with this expression?]]></Val>
@@ -4446,6 +4455,9 @@
<Item ItemId=";Element_at_index_0_is_variadic_in_one_type_but_not_in_the_other_2622" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Element at index {0} is variadic in one type but not in the other.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[位於索引 {0} 的元素在一個類型中是可變參數,但在另一個類型中不是。]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
@@ -8871,15 +8883,6 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_destructuring_90009" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove destructuring]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[移除解構]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_import_from_0_90005" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove import from '{0}']]></Val>
@@ -8943,6 +8946,24 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_unused_declarations_for_Colon_0_90041" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove unused declarations for: '{0}']]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[移除 '{0}' 未使用的宣告]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_unused_destructuring_declaration_90039" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove unused destructuring declaration]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[移除未使用的解構宣告]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_unused_label_95053" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove unused label]]></Val>
@@ -9615,12 +9636,18 @@
<Item ItemId=";Source_has_0_element_s_but_target_allows_only_1_2619" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Source has {0} element(s) but target allows only {1}.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[來源具有 {0} 個元素,但目標只允許 {1} 個。]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Source_has_0_element_s_but_target_requires_1_2618" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Source has {0} element(s) but target requires {1}.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[來源有 {0} 個元素,但目標需要 {1} 個。]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
@@ -9996,6 +10023,15 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Switch_each_misused_0_to_1_95138" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Switch each misused '{0}' to '{1}']]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[將每個誤用的 '{0}' 切換為 '{1}']]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Symbol_reference_does_not_refer_to_the_global_Symbol_constructor_object_2470" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA['Symbol' reference does not refer to the global Symbol constructor object.]]></Val>
@@ -10044,12 +10080,18 @@
<Item ItemId=";Target_allows_only_0_element_s_but_source_may_have_more_2621" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Target allows only {0} element(s) but source may have more.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[目標只允許 {0} 個元素,但來源的元素可能較多。]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Target_requires_0_element_s_but_source_may_have_fewer_2620" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Target requires {0} element(s) but source may have fewer.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[目標需要 {0} 個元素,但來源的元素可能較少。]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
@@ -12876,15 +12918,6 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment_1312" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA['=' can only be used in an object literal property inside a destructuring assignment.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA['=' 僅能在解構指派內的物件常值屬性中使用。]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";case_or_default_expected_1130" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA['case' or 'default' expected.]]></Val>
@@ -4077,6 +4077,15 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Did_you_mean_to_use_a_Colon_When_following_property_names_in_an_object_literal_implies_a_destructuri_1312" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Did you mean to use a ':'? When following property names in an object literal, '=' implies a destructuring assignment.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Nechtěli jste použít :? Když se budou dodržovat názvy vlastností v literálu objektu, = znamená destrukční přiřazení.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Did_you_mean_to_use_new_with_this_expression_6213" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Did you mean to use 'new' with this expression?]]></Val>
@@ -8883,15 +8892,6 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_destructuring_90009" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove destructuring]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Odebrat destrukci]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_import_from_0_90005" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove import from '{0}']]></Val>
@@ -8955,6 +8955,24 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_unused_declarations_for_Colon_0_90041" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove unused declarations for: '{0}']]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Odebrat nepoužívané deklarace pro {0}]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_unused_destructuring_declaration_90039" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove unused destructuring declaration]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Odebrat nepoužívané destrukční deklarace]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_unused_label_95053" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove unused label]]></Val>
@@ -10014,6 +10032,15 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Switch_each_misused_0_to_1_95138" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Switch each misused '{0}' to '{1}']]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Přepnout každé chybně použité {0} na {1}]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Symbol_reference_does_not_refer_to_the_global_Symbol_constructor_object_2470" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA['Symbol' reference does not refer to the global Symbol constructor object.]]></Val>
@@ -10045,7 +10072,7 @@
<Str Cat="Text">
<Val><![CDATA[Tag '{0}' expects at least '{1}' arguments, but the JSX factory '{2}' provides at most '{3}'.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Značka {0} očekává nejmíň {1} argumentů, ale objekt pro vytváření JSX {2} poskytuje maximálně {3}.]]></Val>
<Val><![CDATA[Značka {0} očekává určitý minimální počet argumentů ({1}), ale objekt pro vytváření JSX {2} jich poskytuje maximálně {3}.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
@@ -12900,15 +12927,6 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment_1312" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA['=' can only be used in an object literal property inside a destructuring assignment.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[= jde použít jenom ve vlastnosti literálu objektu uvnitř destrukturujícího přiřazení.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";case_or_default_expected_1130" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA['case' or 'default' expected.]]></Val>
@@ -4065,6 +4065,15 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Did_you_mean_to_use_a_Colon_When_following_property_names_in_an_object_literal_implies_a_destructuri_1312" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Did you mean to use a ':'? When following property names in an object literal, '=' implies a destructuring assignment.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Wollten Sie ":" verwenden? Bei Eigenschaftennamen in einem Objektliteral impliziert "=" eine Destrukturierungszuweisung.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Did_you_mean_to_use_new_with_this_expression_6213" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Did you mean to use 'new' with this expression?]]></Val>
@@ -8868,15 +8877,6 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_destructuring_90009" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove destructuring]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Destrukturierung entfernen]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_import_from_0_90005" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove import from '{0}']]></Val>
@@ -8940,6 +8940,24 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_unused_declarations_for_Colon_0_90041" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove unused declarations for: '{0}']]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Nicht verwendete Deklarationen für "{0}" entfernen]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_unused_destructuring_declaration_90039" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove unused destructuring declaration]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Nicht verwendete Destrukturierungsdeklaration entfernen]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_unused_label_95053" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove unused label]]></Val>
@@ -9999,6 +10017,15 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Switch_each_misused_0_to_1_95138" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Switch each misused '{0}' to '{1}']]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Jedes falsch verwendete {0}-Element in "{1}" ändern]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Symbol_reference_does_not_refer_to_the_global_Symbol_constructor_object_2470" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA['Symbol' reference does not refer to the global Symbol constructor object.]]></Val>
@@ -12885,15 +12912,6 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment_1312" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA['=' can only be used in an object literal property inside a destructuring assignment.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA["=" kann nur in einer Objektliteraleigenschaft innerhalb eines Destrukturierungszuweisung verwendet werden.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";case_or_default_expected_1130" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA['case' or 'default' expected.]]></Val>
@@ -4080,6 +4080,15 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Did_you_mean_to_use_a_Colon_When_following_property_names_in_an_object_literal_implies_a_destructuri_1312" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Did you mean to use a ':'? When following property names in an object literal, '=' implies a destructuring assignment.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[¿Pretendía usar el carácter ":"? Cuando aparece después de los nombres de propiedad en un literal de objeto, "=" implica una asignación de desestructuración.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Did_you_mean_to_use_new_with_this_expression_6213" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Did you mean to use 'new' with this expression?]]></Val>
@@ -4458,6 +4467,9 @@
<Item ItemId=";Element_at_index_0_is_variadic_in_one_type_but_not_in_the_other_2622" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Element at index {0} is variadic in one type but not in the other.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[El elemento en el índice {0} es variádico en un tipo, pero no en el otro.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
@@ -8883,15 +8895,6 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_destructuring_90009" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove destructuring]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Quitar la desestructuración]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_import_from_0_90005" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove import from '{0}']]></Val>
@@ -8955,6 +8958,24 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_unused_declarations_for_Colon_0_90041" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove unused declarations for: '{0}']]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Quitar las declaraciones sin usar para "{0}"]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_unused_destructuring_declaration_90039" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove unused destructuring declaration]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Quitar la declaración de desestructuración no utilizada]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_unused_label_95053" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove unused label]]></Val>
@@ -9627,12 +9648,18 @@
<Item ItemId=";Source_has_0_element_s_but_target_allows_only_1_2619" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Source has {0} element(s) but target allows only {1}.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[El origen tiene {0} elemento(s), pero el destino solo permite {1}.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Source_has_0_element_s_but_target_requires_1_2618" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Source has {0} element(s) but target requires {1}.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[El origen tiene {0} elemento(s), pero el destino requiere {1}.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
@@ -10008,6 +10035,15 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Switch_each_misused_0_to_1_95138" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Switch each misused '{0}' to '{1}']]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Cambiar cada elemento "{0}" usado incorrectamente a "{1}"]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Symbol_reference_does_not_refer_to_the_global_Symbol_constructor_object_2470" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA['Symbol' reference does not refer to the global Symbol constructor object.]]></Val>
@@ -10056,12 +10092,18 @@
<Item ItemId=";Target_allows_only_0_element_s_but_source_may_have_more_2621" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Target allows only {0} element(s) but source may have more.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[El destino solo permite {0} elemento(s), pero el origen puede tener más.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Target_requires_0_element_s_but_source_may_have_fewer_2620" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Target requires {0} element(s) but source may have fewer.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[El destino requiere {0} elemento(s), pero el origen puede tener menos.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
@@ -12888,15 +12930,6 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment_1312" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA['=' can only be used in an object literal property inside a destructuring assignment.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA["=" solo se puede usar en una propiedad de literal de objeto dentro de una asignación de desestructuración.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";case_or_default_expected_1130" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA['case' or 'default' expected.]]></Val>
@@ -2593,7 +2593,7 @@
<Str Cat="Text">
<Val><![CDATA[Cannot find lib definition for '{0}'.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Définition de lib introuvable pour '{0}'.]]></Val>
<Val><![CDATA[Définition de bibliothèque introuvable pour '{0}'.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
@@ -2602,7 +2602,7 @@
<Str Cat="Text">
<Val><![CDATA[Cannot find lib definition for '{0}'. Did you mean '{1}'?]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Définition de lib introuvable pour '{0}'. Est-ce qu'il ne s'agit pas plutôt de '{1}' ?]]></Val>
<Val><![CDATA[Définition de bibliothèque introuvable pour '{0}'. Est-ce qu'il ne s'agit pas plutôt de '{1}' ?]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
@@ -4080,6 +4080,15 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Did_you_mean_to_use_a_Colon_When_following_property_names_in_an_object_literal_implies_a_destructuri_1312" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Did you mean to use a ':'? When following property names in an object literal, '=' implies a destructuring assignment.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Voulez-vous vraiment utiliser le signe ':' ? Quand vous placez le signe '=' à la suite de noms de propriétés dans un littéral d'objet, cela implique une affectation de déstructuration.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Did_you_mean_to_use_new_with_this_expression_6213" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Did you mean to use 'new' with this expression?]]></Val>
@@ -4455,6 +4464,15 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Element_at_index_0_is_variadic_in_one_type_but_not_in_the_other_2622" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Element at index {0} is variadic in one type but not in the other.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[L'élément à l'index {0} est variadique dans un type mais pas dans l'autre.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Element_implicitly_has_an_any_type_because_expression_of_type_0_can_t_be_used_to_index_type_1_7053" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Element implicitly has an 'any' type because expression of type '{0}' can't be used to index type '{1}'.]]></Val>
@@ -8877,15 +8895,6 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_destructuring_90009" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove destructuring]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Supprimer la déstructuration]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_import_from_0_90005" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove import from '{0}']]></Val>
@@ -8949,6 +8958,24 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_unused_declarations_for_Colon_0_90041" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove unused declarations for: '{0}']]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Supprimer les déclarations inutilisées pour : '{0}']]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_unused_destructuring_declaration_90039" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove unused destructuring declaration]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Supprimer la déclaration de déstructuration inutilisée]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_unused_label_95053" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove unused label]]></Val>
@@ -9618,6 +9645,24 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Source_has_0_element_s_but_target_allows_only_1_2619" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Source has {0} element(s) but target allows only {1}.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[La source a {0} élément(s) mais la cible n'en autorise que {1}.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Source_has_0_element_s_but_target_requires_1_2618" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Source has {0} element(s) but target requires {1}.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[La source a {0} élément(s) mais la cible en nécessite {1}.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Specialized_overload_signature_is_not_assignable_to_any_non_specialized_signature_2382" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Specialized overload signature is not assignable to any non-specialized signature.]]></Val>
@@ -9990,6 +10035,15 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Switch_each_misused_0_to_1_95138" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Switch each misused '{0}' to '{1}']]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Remplacer chaque utilisation incorrecte de '{0}' par '{1}']]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Symbol_reference_does_not_refer_to_the_global_Symbol_constructor_object_2470" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA['Symbol' reference does not refer to the global Symbol constructor object.]]></Val>
@@ -10035,6 +10089,24 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Target_allows_only_0_element_s_but_source_may_have_more_2621" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Target allows only {0} element(s) but source may have more.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[La cible autorise uniquement {0} élément(s) mais la source peut en avoir plus.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Target_requires_0_element_s_but_source_may_have_fewer_2620" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Target requires {0} element(s) but source may have fewer.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[La cible nécessite {0} élément(s) mais la source peut en avoir moins.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";The_0_modifier_can_only_be_used_in_TypeScript_files_8009" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[The '{0}' modifier can only be used in TypeScript files.]]></Val>
@@ -12858,15 +12930,6 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment_1312" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA['=' can only be used in an object literal property inside a destructuring assignment.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA['=' ne peut être utilisé que dans une propriété de littéral d'objet au sein d'une affectation par déstructuration.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";case_or_default_expected_1130" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA['case' or 'default' expected.]]></Val>
@@ -4068,6 +4068,15 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Did_you_mean_to_use_a_Colon_When_following_property_names_in_an_object_literal_implies_a_destructuri_1312" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Did you mean to use a ':'? When following property names in an object literal, '=' implies a destructuring assignment.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Si intendeva usare i due punti (':')? Quando segue nomi di proprietà in un valore letterale di oggetto, il carattere '=' implica un'assegnazione di destrutturazione.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Did_you_mean_to_use_new_with_this_expression_6213" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Did you mean to use 'new' with this expression?]]></Val>
@@ -8874,15 +8883,6 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_destructuring_90009" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove destructuring]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Rimuovere la destrutturazione]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_import_from_0_90005" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove import from '{0}']]></Val>
@@ -8946,6 +8946,24 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_unused_declarations_for_Colon_0_90041" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove unused declarations for: '{0}']]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Rimuovere le dichiarazioni inutilizzate per: '{0}']]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_unused_destructuring_declaration_90039" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove unused destructuring declaration]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Rimuovere la dichiarazione di destrutturazione inutilizzata]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_unused_label_95053" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove unused label]]></Val>
@@ -10005,6 +10023,15 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Switch_each_misused_0_to_1_95138" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Switch each misused '{0}' to '{1}']]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Cambiare ogni '{0}' non usato correttamente in '{1}']]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Symbol_reference_does_not_refer_to_the_global_Symbol_constructor_object_2470" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA['Symbol' reference does not refer to the global Symbol constructor object.]]></Val>
@@ -12891,15 +12918,6 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment_1312" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA['=' can only be used in an object literal property inside a destructuring assignment.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[È possibile usare '=' solo in una proprietà di valore letterale di oggetto all'interno di un'assegnazione di destrutturazione.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";case_or_default_expected_1130" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA['case' or 'default' expected.]]></Val>
@@ -4068,6 +4068,15 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Did_you_mean_to_use_a_Colon_When_following_property_names_in_an_object_literal_implies_a_destructuri_1312" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Did you mean to use a ':'? When following property names in an object literal, '=' implies a destructuring assignment.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[':' を使用しますか? オブジェクト リテラルでプロパティ名を次のように指定する場合、'=' は非構造化代入を意味します。]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Did_you_mean_to_use_new_with_this_expression_6213" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Did you mean to use 'new' with this expression?]]></Val>
@@ -8874,15 +8883,6 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_destructuring_90009" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove destructuring]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[非構造化を削除します]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_import_from_0_90005" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove import from '{0}']]></Val>
@@ -8946,6 +8946,24 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_unused_declarations_for_Colon_0_90041" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove unused declarations for: '{0}']]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA['{0}' に対する使用されていない宣言を削除する]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_unused_destructuring_declaration_90039" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove unused destructuring declaration]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[未使用の非構造化宣言を削除する]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_unused_label_95053" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove unused label]]></Val>
@@ -10005,6 +10023,15 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Switch_each_misused_0_to_1_95138" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Switch each misused '{0}' to '{1}']]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[誤用されている各 '{0}' を '{1}' に切り替える]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Symbol_reference_does_not_refer_to_the_global_Symbol_constructor_object_2470" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA['Symbol' reference does not refer to the global Symbol constructor object.]]></Val>
@@ -12891,15 +12918,6 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment_1312" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA['=' can only be used in an object literal property inside a destructuring assignment.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA['=' は、非構造化代入内のオブジェクト リテラル プロパティでのみ使用できます。]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";case_or_default_expected_1130" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA['case' or 'default' expected.]]></Val>
@@ -2581,7 +2581,7 @@
<Str Cat="Text">
<Val><![CDATA[Cannot find lib definition for '{0}'.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA['{0}'에 대한 lib 정의를 찾을 수 없습니다.]]></Val>
<Val><![CDATA['{0}'에 대한 라이브러리 정의를 찾을 수 없습니다.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
@@ -2590,7 +2590,7 @@
<Str Cat="Text">
<Val><![CDATA[Cannot find lib definition for '{0}'. Did you mean '{1}'?]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA['{0}'에 대한 lib 정의를 찾을 수 없습니다. '{1}'이(가) 아닌지 확인하세요.]]></Val>
<Val><![CDATA['{0}'에 대한 라이브러리 정의를 찾을 수 없습니다. '{1}'이(가) 아닌지 확인하세요.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
@@ -4068,6 +4068,15 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Did_you_mean_to_use_a_Colon_When_following_property_names_in_an_object_literal_implies_a_destructuri_1312" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Did you mean to use a ':'? When following property names in an object literal, '=' implies a destructuring assignment.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[':'을 사용하려고 하셨습니까? 개체 리터럴에서 속성 이름 뒤에 있으면 '='은 구조 파괴 할당을 의미합니다.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Did_you_mean_to_use_new_with_this_expression_6213" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Did you mean to use 'new' with this expression?]]></Val>
@@ -8874,15 +8883,6 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_destructuring_90009" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove destructuring]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[구조 파괴 제거]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_import_from_0_90005" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove import from '{0}']]></Val>
@@ -8946,6 +8946,24 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_unused_declarations_for_Colon_0_90041" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove unused declarations for: '{0}']]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA['{0}'의 사용되지 않는 선언 제거]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_unused_destructuring_declaration_90039" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove unused destructuring declaration]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[사용되지 않는 구조 파괴 선언 제거]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_unused_label_95053" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove unused label]]></Val>
@@ -10005,6 +10023,15 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Switch_each_misused_0_to_1_95138" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Switch each misused '{0}' to '{1}']]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[잘못 사용된 각 '{0}'을(를) '{1}'(으)로 전환]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Symbol_reference_does_not_refer_to_the_global_Symbol_constructor_object_2470" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA['Symbol' reference does not refer to the global Symbol constructor object.]]></Val>
@@ -12891,15 +12918,6 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment_1312" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA['=' can only be used in an object literal property inside a destructuring assignment.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA['='는 구조 파괴 할당 내의 개체 리터럴 속성에서만 사용할 수 있습니다.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";case_or_default_expected_1130" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA['case' or 'default' expected.]]></Val>
@@ -4058,6 +4058,15 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Did_you_mean_to_use_a_Colon_When_following_property_names_in_an_object_literal_implies_a_destructuri_1312" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Did you mean to use a ':'? When following property names in an object literal, '=' implies a destructuring assignment.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Czy chodziło o użycie znaku „:”? Jeśli występuje po nazwie właściwości w literale obiektu, znak „=” oznacza przypisanie usuwające strukturę.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Did_you_mean_to_use_new_with_this_expression_6213" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Did you mean to use 'new' with this expression?]]></Val>
@@ -8861,15 +8870,6 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_destructuring_90009" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove destructuring]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Usuń usuwanie struktury]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_import_from_0_90005" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove import from '{0}']]></Val>
@@ -8933,6 +8933,24 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_unused_declarations_for_Colon_0_90041" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove unused declarations for: '{0}']]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Usuń nieużywane deklaracje dla: „{0}”]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_unused_destructuring_declaration_90039" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove unused destructuring declaration]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Usuń nieużywaną deklarację usuwania struktury]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_unused_label_95053" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove unused label]]></Val>
@@ -9992,6 +10010,15 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Switch_each_misused_0_to_1_95138" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Switch each misused '{0}' to '{1}']]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Zmień każdy niepoprawnie użyty element „{0}” na „{1}”]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Symbol_reference_does_not_refer_to_the_global_Symbol_constructor_object_2470" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA['Symbol' reference does not refer to the global Symbol constructor object.]]></Val>
@@ -12878,15 +12905,6 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment_1312" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA['=' can only be used in an object literal property inside a destructuring assignment.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Znaku „=” można użyć tylko we właściwości literału obiektu wewnątrz przypisania usuwającego strukturę.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";case_or_default_expected_1130" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA['case' or 'default' expected.]]></Val>
@@ -2574,7 +2574,7 @@
<Str Cat="Text">
<Val><![CDATA[Cannot find lib definition for '{0}'.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Não é possível encontrar a definição de lib para '{0}'.]]></Val>
<Val><![CDATA[Não é possível encontrar a definição de biblioteca para '{0}'.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
@@ -2583,7 +2583,7 @@
<Str Cat="Text">
<Val><![CDATA[Cannot find lib definition for '{0}'. Did you mean '{1}'?]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Não é possível encontrar a definição de lib para '{0}'. Você quis dizer '{1}'?]]></Val>
<Val><![CDATA[Não é possível encontrar a definição de biblioteca para '{0}'. Você quis dizer '{1}'?]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
@@ -4061,6 +4061,15 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Did_you_mean_to_use_a_Colon_When_following_property_names_in_an_object_literal_implies_a_destructuri_1312" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Did you mean to use a ':'? When following property names in an object literal, '=' implies a destructuring assignment.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Você quis usar um ':'? Após os nomes de propriedade em um literal de objeto, '=' implica uma atribuição de desestruturação.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Did_you_mean_to_use_new_with_this_expression_6213" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Did you mean to use 'new' with this expression?]]></Val>
@@ -8864,15 +8873,6 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_destructuring_90009" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove destructuring]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Remover desestruturação]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_import_from_0_90005" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove import from '{0}']]></Val>
@@ -8936,6 +8936,24 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_unused_declarations_for_Colon_0_90041" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove unused declarations for: '{0}']]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Remover a declaração não usada de: '{0}']]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_unused_destructuring_declaration_90039" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove unused destructuring declaration]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Remover a declaração de desestruturação não usada]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_unused_label_95053" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove unused label]]></Val>
@@ -9995,6 +10013,15 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Switch_each_misused_0_to_1_95138" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Switch each misused '{0}' to '{1}']]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Mudar cada '{0}' usado incorretamente para '{1}']]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Symbol_reference_does_not_refer_to_the_global_Symbol_constructor_object_2470" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA['Symbol' reference does not refer to the global Symbol constructor object.]]></Val>
@@ -12881,15 +12908,6 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment_1312" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA['=' can only be used in an object literal property inside a destructuring assignment.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA['=' só pode ser usado em uma propriedade literal de objeto dentro de uma atribuição de desestruturação.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";case_or_default_expected_1130" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA['case' or 'default' expected.]]></Val>
@@ -4067,6 +4067,15 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Did_you_mean_to_use_a_Colon_When_following_property_names_in_an_object_literal_implies_a_destructuri_1312" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Did you mean to use a ':'? When following property names in an object literal, '=' implies a destructuring assignment.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Возможно, вы хотели использовать ":"? Знак "=" после имен свойств в объектном литерале подразумевает назначение деструктурирования.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Did_you_mean_to_use_new_with_this_expression_6213" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Did you mean to use 'new' with this expression?]]></Val>
@@ -4445,6 +4454,9 @@
<Item ItemId=";Element_at_index_0_is_variadic_in_one_type_but_not_in_the_other_2622" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Element at index {0} is variadic in one type but not in the other.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Элемент с индексом {0} является вариадическим в одном типе, но не является в другом.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
@@ -8870,15 +8882,6 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_destructuring_90009" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove destructuring]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Удалить деструктурирование]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_import_from_0_90005" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove import from '{0}']]></Val>
@@ -8942,6 +8945,24 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_unused_declarations_for_Colon_0_90041" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove unused declarations for: '{0}']]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Удалите неиспользуемые объявления для: "{0}"]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_unused_destructuring_declaration_90039" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove unused destructuring declaration]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Удалите неиспользуемое объявление деструктурирования]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_unused_label_95053" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove unused label]]></Val>
@@ -9614,12 +9635,18 @@
<Item ItemId=";Source_has_0_element_s_but_target_allows_only_1_2619" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Source has {0} element(s) but target allows only {1}.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Число элементов в источнике — {0}, но целевой объект разрешает только {1}.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Source_has_0_element_s_but_target_requires_1_2618" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Source has {0} element(s) but target requires {1}.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Число элементов в источнике — {0}, но целевой объект требует {1}.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
@@ -9995,6 +10022,15 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Switch_each_misused_0_to_1_95138" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Switch each misused '{0}' to '{1}']]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Измените все неверно используемые "{0}" на "{1}"]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Symbol_reference_does_not_refer_to_the_global_Symbol_constructor_object_2470" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA['Symbol' reference does not refer to the global Symbol constructor object.]]></Val>
@@ -10043,12 +10079,18 @@
<Item ItemId=";Target_allows_only_0_element_s_but_source_may_have_more_2621" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Target allows only {0} element(s) but source may have more.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Целевой объект разрешает только следующее число элементов — {0}, но источник может иметь больше.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Target_requires_0_element_s_but_source_may_have_fewer_2620" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Target requires {0} element(s) but source may have fewer.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Целевой объект требует следующего числа элементов — {0}, но источник может иметь меньше.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
@@ -12875,15 +12917,6 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment_1312" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA['=' can only be used in an object literal property inside a destructuring assignment.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA["=" можно использовать только в свойстве объектного литерала в назначении деструктурирования.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";case_or_default_expected_1130" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA['case' or 'default' expected.]]></Val>
@@ -4061,6 +4061,15 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Did_you_mean_to_use_a_Colon_When_following_property_names_in_an_object_literal_implies_a_destructuri_1312" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Did you mean to use a ':'? When following property names in an object literal, '=' implies a destructuring assignment.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[':' işaretini mi kullanmak istediniz? Bir nesne sabit değerinde özellik adlarının ardından kullanılan '=' işareti, yapıyı bozan bir atamayı gösterir.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Did_you_mean_to_use_new_with_this_expression_6213" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Did you mean to use 'new' with this expression?]]></Val>
@@ -8867,15 +8876,6 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_destructuring_90009" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove destructuring]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Yıkmayı kaldır]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_import_from_0_90005" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove import from '{0}']]></Val>
@@ -8939,6 +8939,24 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_unused_declarations_for_Colon_0_90041" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove unused declarations for: '{0}']]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA['{0}' için kullanılmayan bildirimleri kaldırın]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_unused_destructuring_declaration_90039" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove unused destructuring declaration]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Yapıyı bozan kullanılmayan bildirimi kaldır]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Remove_unused_label_95053" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Remove unused label]]></Val>
@@ -9998,6 +10016,15 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Switch_each_misused_0_to_1_95138" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Switch each misused '{0}' to '{1}']]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[Yanlış kullanılan tüm '{0}' öğelerini '{1}' olarak değiştir]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Symbol_reference_does_not_refer_to_the_global_Symbol_constructor_object_2470" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA['Symbol' reference does not refer to the global Symbol constructor object.]]></Val>
@@ -12884,15 +12911,6 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment_1312" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA['=' can only be used in an object literal property inside a destructuring assignment.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA['=', yalnızca yok etme ataması içindeki bir nesne sabit değeri özelliğinde kullanılabilir.]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";case_or_default_expected_1130" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA['case' or 'default' expected.]]></Val>
+16 -16
View File
@@ -157,11 +157,11 @@ namespace ts.server {
[name: string]: { match: RegExp, exclude?: (string | number)[][], types?: string[] };
}
function prepareConvertersForEnumLikeCompilerOptions(commandLineOptions: CommandLineOption[]): Map<string, Map<string, number>> {
const map: Map<string, Map<string, number>> = new Map<string, Map<string, number>>();
function prepareConvertersForEnumLikeCompilerOptions(commandLineOptions: CommandLineOption[]): ESMap<string, ESMap<string, number>> {
const map = new Map<string, ESMap<string, number>>();
for (const option of commandLineOptions) {
if (typeof option.type === "object") {
const optionMap = <Map<string, number>>option.type;
const optionMap = <ESMap<string, number>>option.type;
// verify that map contains only numbers
optionMap.forEach(value => {
Debug.assert(typeof value === "number");
@@ -373,7 +373,7 @@ namespace ts.server {
* It is false when the open file that would still be impacted by existence of
* this config file but it is not the root of inferred project
*/
openFilesImpactedByConfigFile: Map<Path, boolean>;
openFilesImpactedByConfigFile: ESMap<Path, boolean>;
/**
* The file watcher watching the config file because there is open script info that is root of
* inferred project and will be impacted by change in the status of the config file
@@ -590,7 +590,7 @@ namespace ts.server {
/**
* maps external project file name to list of config files that were the part of this project
*/
private readonly externalProjectToConfiguredProjectMap: Map<string, NormalizedPath[]> = new Map<string, NormalizedPath[]>();
private readonly externalProjectToConfiguredProjectMap = new Map<string, NormalizedPath[]>();
/**
* external projects (configuration and list of root files is not controlled by tsserver)
@@ -603,11 +603,11 @@ namespace ts.server {
/**
* projects specified by a tsconfig.json file
*/
readonly configuredProjects = new Map<string, ConfiguredProject>();
readonly configuredProjects: Map<ConfiguredProject> = new Map<string, ConfiguredProject>();
/**
* Open files: with value being project root path, and key being Path of the file that is open
*/
readonly openFiles = new Map<Path, NormalizedPath | undefined>();
readonly openFiles: Map<NormalizedPath | undefined> = new Map<Path, NormalizedPath | undefined>();
/**
* Map of open files that are opened without complete path but have projectRoot as current directory
*/
@@ -620,7 +620,7 @@ namespace ts.server {
/**
* Project size for configured or external projects
*/
private readonly projectToSizeMap: Map<string, number> = new Map<string, number>();
private readonly projectToSizeMap = new Map<string, number>();
/**
* This is a map of config file paths existence that doesnt need query to disk
* - The entry can be present because there is inferred project that needs to watch addition of config file to directory
@@ -656,7 +656,7 @@ namespace ts.server {
public readonly globalPlugins: readonly string[];
public readonly pluginProbeLocations: readonly string[];
public readonly allowLocalPluginLoads: boolean;
private currentPluginConfigOverrides: Map<string, any> | undefined;
private currentPluginConfigOverrides: ESMap<string, any> | undefined;
public readonly typesMapLocation: string | undefined;
@@ -671,7 +671,7 @@ namespace ts.server {
/*@internal*/
readonly packageJsonCache: PackageJsonCache;
/*@internal*/
private packageJsonFilesMap: Map<Path, FileWatcher> | undefined;
private packageJsonFilesMap: ESMap<Path, FileWatcher> | undefined;
private performanceEventHandler?: PerformanceEventHandler;
@@ -875,7 +875,7 @@ namespace ts.server {
const event: ProjectsUpdatedInBackgroundEvent = {
eventName: ProjectsUpdatedInBackgroundEvent,
data: {
openFiles: arrayFrom(this.openFiles.keys(), path => this.getScriptInfoForPath(path)!.fileName)
openFiles: arrayFrom(this.openFiles.keys(), path => this.getScriptInfoForPath(path as Path)!.fileName)
}
};
this.eventHandler(event);
@@ -1375,7 +1375,7 @@ namespace ts.server {
private assignOrphanScriptInfosToInferredProject() {
// collect orphaned files and assign them to inferred project just like we treat open of a file
this.openFiles.forEach((projectRootPath, path) => {
const info = this.getScriptInfoForPath(path)!;
const info = this.getScriptInfoForPath(path as Path)!;
// collect all orphaned script infos from open files
if (info.isOrphan()) {
this.assignOrphanScriptInfoToInferredProject(info, projectRootPath);
@@ -1798,7 +1798,7 @@ namespace ts.server {
this.logger.info("Open files: ");
this.openFiles.forEach((projectRootPath, path) => {
const info = this.getScriptInfoForPath(path)!;
const info = this.getScriptInfoForPath(path as Path)!;
this.logger.info(`\tFileName: ${info.fileName} ProjectRootPath: ${projectRootPath}`);
this.logger.info(`\t\tProjects: ${info.containingProjects.map(p => p.getProjectName())}`);
});
@@ -2747,7 +2747,7 @@ namespace ts.server {
// as there is no need to load contents of the files from the disk
// Reload Projects
this.reloadConfiguredProjectForFiles(this.openFiles, /*delayReload*/ false, returnTrue, "User requested reload projects");
this.reloadConfiguredProjectForFiles(this.openFiles as ESMap<Path, NormalizedPath | undefined>, /*delayReload*/ false, returnTrue, "User requested reload projects");
this.ensureProjectForOpenFiles();
}
@@ -2771,7 +2771,7 @@ namespace ts.server {
* If the there is no existing project it just opens the configured project for the config file
* reloadForInfo provides a way to filter out files to reload configured project for
*/
private reloadConfiguredProjectForFiles<T>(openFiles: Map<Path, T>, delayReload: boolean, shouldReloadProjectFor: (openFileValue: T) => boolean, reason: string) {
private reloadConfiguredProjectForFiles<T>(openFiles: ESMap<Path, T>, delayReload: boolean, shouldReloadProjectFor: (openFileValue: T) => boolean, reason: string) {
const updatedProjects = new Map<string, true>();
// try to reload config file for all open files
openFiles.forEach((openFileValue, path) => {
@@ -2860,7 +2860,7 @@ namespace ts.server {
this.printProjects();
this.openFiles.forEach((projectRootPath, path) => {
const info = this.getScriptInfoForPath(path)!;
const info = this.getScriptInfoForPath(path as Path)!;
// collect all orphaned script infos from open files
if (info.isOrphan()) {
this.assignOrphanScriptInfoToInferredProject(info, projectRootPath);
+19 -19
View File
@@ -114,7 +114,7 @@ namespace ts.server {
generatedFilePath: Path;
watcher: FileWatcher;
}
type GeneratedFileWatcherMap = GeneratedFileWatcher | Map<Path, GeneratedFileWatcher>;
type GeneratedFileWatcherMap = GeneratedFileWatcher | ESMap<Path, GeneratedFileWatcher>;
function isGeneratedFileWatcher(watch: GeneratedFileWatcherMap): watch is GeneratedFileWatcher {
return (watch as GeneratedFileWatcher).generatedFilePath !== undefined;
}
@@ -130,7 +130,7 @@ namespace ts.server {
private rootFilesMap = new Map<string, ProjectRootFile>();
private program: Program | undefined;
private externalFiles: SortedReadonlyArray<string> | undefined;
private missingFilesMap: Map<Path, FileWatcher> | undefined;
private missingFilesMap: ESMap<Path, FileWatcher> | undefined;
private generatedFilesMap: GeneratedFileWatcherMap | undefined;
private plugins: PluginModuleWithName[] = [];
@@ -171,7 +171,7 @@ namespace ts.server {
/**
* Set of files that was returned from the last call to getChangesSinceVersion.
*/
private lastReportedFileNames: Map<string, boolean> | undefined;
private lastReportedFileNames: ESMap<string, boolean> | undefined;
/**
* Last version that was reported.
*/
@@ -246,7 +246,7 @@ namespace ts.server {
/*@internal*/
private dirtyFilesForSuggestions: Set<Path> | undefined;
/*@internal*/
private symlinks: ReadonlyMap<string, string> | undefined;
private symlinks: ReadonlyESMap<string, string> | undefined;
/*@internal*/
autoImportProviderHost: AutoImportProviderProject | false | undefined;
@@ -323,7 +323,7 @@ namespace ts.server {
}
/*@internal*/
getProbableSymlinks(files: readonly SourceFile[]): ReadonlyMap<string, string> {
getProbableSymlinks(files: readonly SourceFile[]): ReadonlyESMap<string, string> {
return this.symlinks || (this.symlinks = discoverProbableSymlinks(
files,
this.getCanonicalFileName,
@@ -1110,7 +1110,7 @@ namespace ts.server {
watcher
)) {
closeFileWatcherOf(watcher);
(this.generatedFilesMap as Map<string, GeneratedFileWatcher>).delete(source);
(this.generatedFilesMap as ESMap<string, GeneratedFileWatcher>).delete(source);
}
});
}
@@ -1386,11 +1386,11 @@ namespace ts.server {
getChangesSinceVersion(lastKnownVersion?: number, includeProjectReferenceRedirectInfo?: boolean): ProjectFilesWithTSDiagnostics {
const includeProjectReferenceRedirectInfoIfRequested =
includeProjectReferenceRedirectInfo
? (files: Map<string, boolean>) => arrayFrom(files.entries(), ([fileName, isSourceOfProjectReferenceRedirect]): protocol.FileWithProjectReferenceRedirectInfo => ({
? (files: ESMap<string, boolean>) => arrayFrom(files.entries(), ([fileName, isSourceOfProjectReferenceRedirect]): protocol.FileWithProjectReferenceRedirectInfo => ({
fileName,
isSourceOfProjectReferenceRedirect
}))
: (files: Map<string, boolean>) => arrayFrom(files.keys());
: (files: ESMap<string, boolean>) => arrayFrom(files.keys());
// Update the graph only if initial configured project load is not pending
if (!this.isInitialLoadPending()) {
@@ -1425,8 +1425,8 @@ namespace ts.server {
info => info.isSourceOfProjectReferenceRedirect
);
const added: Map<string, boolean> = new Map<string, boolean>();
const removed: Map<string, boolean> = new Map<string, boolean>();
const added: ESMap<string, boolean> = new Map<string, boolean>();
const removed: ESMap<string, boolean> = new Map<string, boolean>();
const updated: string[] = updatedFileNames ? arrayFrom(updatedFileNames.keys()) : [];
const updatedRedirects: protocol.FileWithProjectReferenceRedirectInfo[] = [];
@@ -1498,7 +1498,7 @@ namespace ts.server {
return !!this.program && this.program.isSourceOfProjectReferenceRedirect(fileName);
}
protected enableGlobalPlugins(options: CompilerOptions, pluginConfigOverrides: Map<string, any> | undefined) {
protected enableGlobalPlugins(options: CompilerOptions, pluginConfigOverrides: Map<any> | undefined) {
const host = this.projectService.host;
if (!host.require) {
@@ -1530,7 +1530,7 @@ namespace ts.server {
}
}
protected enablePlugin(pluginConfigEntry: PluginImport, searchPaths: string[], pluginConfigOverrides: Map<string, any> | undefined) {
protected enablePlugin(pluginConfigEntry: PluginImport, searchPaths: string[], pluginConfigOverrides: Map<any> | undefined) {
this.projectService.logger.info(`Enabling plugin ${pluginConfigEntry.name} from candidate paths: ${searchPaths.join(",")}`);
const log = (message: string) => this.projectService.logger.info(message);
@@ -1663,12 +1663,12 @@ namespace ts.server {
}
}
function getUnresolvedImports(program: Program, cachedUnresolvedImportsPerFile: Map<Path, readonly string[]>): SortedReadonlyArray<string> {
function getUnresolvedImports(program: Program, cachedUnresolvedImportsPerFile: ESMap<Path, readonly string[]>): SortedReadonlyArray<string> {
const ambientModules = program.getTypeChecker().getAmbientModules().map(mod => stripQuotes(mod.getName()));
return sortAndDeduplicate(flatMap(program.getSourceFiles(), sourceFile =>
extractUnresolvedImportsFromSourceFile(sourceFile, ambientModules, cachedUnresolvedImportsPerFile)));
}
function extractUnresolvedImportsFromSourceFile(file: SourceFile, ambientModules: readonly string[], cachedUnresolvedImportsPerFile: Map<Path, readonly string[]>): readonly string[] {
function extractUnresolvedImportsFromSourceFile(file: SourceFile, ambientModules: readonly string[], cachedUnresolvedImportsPerFile: ESMap<Path, readonly string[]>): readonly string[] {
return getOrUpdate(cachedUnresolvedImportsPerFile, file.path, () => {
if (!file.resolvedModules) return emptyArray;
let unresolvedImports: string[] | undefined;
@@ -1736,7 +1736,7 @@ namespace ts.server {
watchOptions: WatchOptions | undefined,
projectRootPath: NormalizedPath | undefined,
currentDirectory: string | undefined,
pluginConfigOverrides: Map<string, any> | undefined) {
pluginConfigOverrides: ESMap<string, any> | undefined) {
super(InferredProject.newName(),
ProjectKind.Inferred,
projectService,
@@ -1950,7 +1950,7 @@ namespace ts.server {
private typeAcquisition!: TypeAcquisition; // TODO: GH#18217
/* @internal */
configFileWatcher: FileWatcher | undefined;
private directoriesWatchedForWildcards: Map<string, WildcardDirectoryWatcher> | undefined;
private directoriesWatchedForWildcards: ESMap<string, WildcardDirectoryWatcher> | undefined;
readonly canonicalConfigFilePath: NormalizedPath;
/* @internal */
@@ -2112,7 +2112,7 @@ namespace ts.server {
}
/*@internal*/
enablePluginsWithOptions(options: CompilerOptions, pluginConfigOverrides: Map<string, any> | undefined) {
enablePluginsWithOptions(options: CompilerOptions, pluginConfigOverrides: ESMap<string, any> | undefined) {
const host = this.projectService.host;
if (!host.require) {
@@ -2167,7 +2167,7 @@ namespace ts.server {
}
/*@internal*/
watchWildcards(wildcardDirectories: Map<string, WatchDirectoryFlags>) {
watchWildcards(wildcardDirectories: ESMap<string, WatchDirectoryFlags>) {
updateWatchingWildcardDirectories(
this.directoriesWatchedForWildcards || (this.directoriesWatchedForWildcards = new Map()),
wildcardDirectories,
@@ -2290,7 +2290,7 @@ namespace ts.server {
lastFileExceededProgramSize: string | undefined,
public compileOnSaveEnabled: boolean,
projectFilePath?: string,
pluginConfigOverrides?: Map<string, any>,
pluginConfigOverrides?: ESMap<string, any>,
watchOptions?: WatchOptions) {
super(externalProjectName,
ProjectKind.External,
+2 -2
View File
@@ -41,7 +41,7 @@ namespace ts.server {
if ((arr1 || emptyArray).length === 0 && (arr2 || emptyArray).length === 0) {
return true;
}
const set: Map<string, boolean> = new Map<string, boolean>();
const set = new Map<string, boolean>();
let unique = 0;
for (const v of arr1!) {
@@ -83,7 +83,7 @@ namespace ts.server {
/*@internal*/
export class TypingsCache {
private readonly perProjectCache: Map<string, TypingsCacheEntry> = new Map<string, TypingsCacheEntry>();
private readonly perProjectCache = new Map<string, TypingsCacheEntry>();
constructor(private readonly installer: ITypingsInstaller) {
}
+1 -1
View File
@@ -1,7 +1,7 @@
/* @internal */
namespace ts.server {
export class ThrottledOperations {
private readonly pendingTimeouts: Map<string, any> = new Map<string, any>();
private readonly pendingTimeouts = new Map<string, any>();
private readonly logger?: Logger | undefined;
constructor(private readonly host: ServerHost, logger: Logger) {
this.logger = logger.hasLevel(LogLevel.verbose) ? logger : undefined;
@@ -14,48 +14,31 @@ namespace ts.codefix {
function doChange(changes: textChanges.ChangeTracker, sourceFile: SourceFile, position: number, checker: TypeChecker): void {
const ctorSymbol = checker.getSymbolAtLocation(getTokenAtPosition(sourceFile, position))!;
if (!ctorSymbol || !(ctorSymbol.flags & (SymbolFlags.Function | SymbolFlags.Variable))) {
// Bad input
return undefined;
}
const ctorDeclaration = ctorSymbol.valueDeclaration;
if (isFunctionDeclaration(ctorDeclaration)) {
changes.replaceNode(sourceFile, ctorDeclaration, createClassFromFunctionDeclaration(ctorDeclaration));
}
else if (isVariableDeclaration(ctorDeclaration)) {
const classDeclaration = createClassFromVariableDeclaration(ctorDeclaration);
if (!classDeclaration) {
return undefined;
}
let precedingNode: Node | undefined;
let newClassDeclaration: ClassDeclaration | undefined;
switch (ctorDeclaration.kind) {
case SyntaxKind.FunctionDeclaration:
precedingNode = ctorDeclaration;
const ancestor = ctorDeclaration.parent.parent;
if (isVariableDeclarationList(ctorDeclaration.parent) && ctorDeclaration.parent.declarations.length > 1) {
changes.delete(sourceFile, ctorDeclaration);
newClassDeclaration = createClassFromFunctionDeclaration(ctorDeclaration as FunctionDeclaration);
break;
case SyntaxKind.VariableDeclaration:
precedingNode = ctorDeclaration.parent.parent;
newClassDeclaration = createClassFromVariableDeclaration(ctorDeclaration as VariableDeclaration);
if ((<VariableDeclarationList>ctorDeclaration.parent).declarations.length === 1) {
copyLeadingComments(precedingNode, newClassDeclaration!, sourceFile); // TODO: GH#18217
changes.delete(sourceFile, precedingNode);
}
else {
changes.delete(sourceFile, ctorDeclaration);
}
break;
changes.insertNodeAfter(sourceFile, ancestor, classDeclaration);
}
else {
changes.replaceNode(sourceFile, ancestor, classDeclaration);
}
}
if (!newClassDeclaration) {
return undefined;
}
// Deleting a declaration only deletes JSDoc style comments, so only copy those to the new node.
if (hasJSDocNodes(ctorDeclaration)) {
copyLeadingComments(ctorDeclaration, newClassDeclaration, sourceFile);
}
// Because the preceding node could be touched, we need to insert nodes before delete nodes.
changes.insertNodeAfter(sourceFile, precedingNode!, newClassDeclaration);
function createClassElementsFromSymbol(symbol: Symbol) {
const memberElements: ClassElement[] = [];
// all instance members are stored in the "member" array of symbol
@@ -220,12 +203,8 @@ namespace ts.codefix {
}
function createClassFromVariableDeclaration(node: VariableDeclaration): ClassDeclaration | undefined {
const initializer = node.initializer as FunctionExpression;
if (!initializer || initializer.kind !== SyntaxKind.FunctionExpression) {
return undefined;
}
if (node.name.kind !== SyntaxKind.Identifier) {
const initializer = node.initializer;
if (!initializer || !isFunctionExpression(initializer) || !isIdentifier(node.name)) {
return undefined;
}
@@ -234,7 +213,7 @@ namespace ts.codefix {
memberElements.unshift(factory.createConstructorDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, initializer.parameters, initializer.body));
}
const modifiers = getModifierKindFromSource(precedingNode!, SyntaxKind.ExportKeyword);
const modifiers = getModifierKindFromSource(node.parent.parent, SyntaxKind.ExportKeyword);
const cls = factory.createClassDeclaration(/*decorators*/ undefined, modifiers, node.name,
/*typeParameters*/ undefined, /*heritageClauses*/ undefined, memberElements);
// Don't call copyComments here because we'll already leave them in place
@@ -38,7 +38,7 @@ namespace ts.codefix {
interface Transformer {
readonly checker: TypeChecker;
readonly synthNamesMap: Map<string, SynthIdentifier>; // keys are the symbol id of the identifier
readonly synthNamesMap: ESMap<string, SynthIdentifier>; // keys are the symbol id of the identifier
readonly setOfExpressionsToReturn: ReadonlySet<number>; // keys are the node ids of the expressions
readonly isInJSFile: boolean;
}
@@ -61,7 +61,7 @@ namespace ts.codefix {
return;
}
const synthNamesMap: Map<string, SynthIdentifier> = new Map();
const synthNamesMap = new Map<string, SynthIdentifier>();
const isInJavascript = isInJSFile(functionToConvert);
const setOfExpressionsToReturn = getAllPromiseExpressionsToReturn(functionToConvert, checker);
const functionToConvertRenamed = renameCollidingVarNames(functionToConvert, checker, synthNamesMap, context.sourceFile);
@@ -148,7 +148,7 @@ namespace ts.codefix {
This function collects all existing identifier names and names of identifiers that will be created in the refactor.
It then checks for any collisions and renames them through getSynthesizedDeepClone
*/
function renameCollidingVarNames(nodeToRename: FunctionLikeDeclaration, checker: TypeChecker, synthNamesMap: Map<string, SynthIdentifier>, sourceFile: SourceFile): FunctionLikeDeclaration {
function renameCollidingVarNames(nodeToRename: FunctionLikeDeclaration, checker: TypeChecker, synthNamesMap: ESMap<string, SynthIdentifier>, sourceFile: SourceFile): FunctionLikeDeclaration {
const identsToRenameMap = new Map<string, Identifier>(); // key is the symbol id
const collidingSymbolMap = createMultiMap<Symbol>();
forEachChild(nodeToRename, function visit(node: Node) {
@@ -202,7 +202,7 @@ namespace ts.codefix {
return getSynthesizedDeepCloneWithRenames(nodeToRename, /*includeTrivia*/ true, identsToRenameMap, checker);
}
function getNewNameIfConflict(name: Identifier, originalNames: ReadonlyMap<string, Symbol[]>): SynthIdentifier {
function getNewNameIfConflict(name: Identifier, originalNames: ReadonlyESMap<string, Symbol[]>): SynthIdentifier {
const numVarsSameName = (originalNames.get(name.text) || emptyArray).length;
const identifier = numVarsSameName === 0 ? name : factory.createIdentifier(name.text + "_" + numVarsSameName);
return createSynthIdentifier(identifier);
+2 -2
View File
@@ -60,7 +60,7 @@ namespace ts.codefix {
* export { _x as x };
* This conversion also must place if the exported name is not a valid identifier, e.g. `exports.class = 0;`.
*/
type ExportRenames = ReadonlyMap<string, string>;
type ExportRenames = ReadonlyESMap<string, string>;
function collectExportRenames(sourceFile: SourceFile, checker: TypeChecker, identifiers: Identifiers): ExportRenames {
const res = new Map<string, string>();
@@ -444,7 +444,7 @@ namespace ts.codefix {
readonly additional: Set<string>;
}
type FreeIdentifiers = ReadonlyMap<string, readonly Identifier[]>;
type FreeIdentifiers = ReadonlyESMap<string, readonly Identifier[]>;
function collectFreeIdentifiers(file: SourceFile): FreeIdentifiers {
const map = createMultiMap<Identifier>();
forEachFreeIdentifier(file, id => map.add(id.text, id));
@@ -42,7 +42,7 @@ namespace ts.codefix {
const abstractAndNonPrivateExtendsSymbols = checker.getPropertiesOfType(instantiatedExtendsType).filter(symbolPointsToNonPrivateAndAbstractMember);
const importAdder = createImportAdder(sourceFile, context.program, preferences, context.host);
createMissingMemberNodes(classDeclaration, abstractAndNonPrivateExtendsSymbols, context, preferences, importAdder, member => changeTracker.insertNodeAtClassStart(sourceFile, classDeclaration, member));
createMissingMemberNodes(classDeclaration, abstractAndNonPrivateExtendsSymbols, sourceFile, context, preferences, importAdder, member => changeTracker.insertNodeAtClassStart(sourceFile, classDeclaration, member));
importAdder.writeFixes(changeTracker);
}
@@ -64,7 +64,7 @@ namespace ts.codefix {
}
const importAdder = createImportAdder(sourceFile, context.program, preferences, context.host);
createMissingMemberNodes(classDeclaration, nonPrivateAndNotExistedInHeritageClauseMembers, context, preferences, importAdder, member => insertInterfaceMemberNode(sourceFile, classDeclaration, member));
createMissingMemberNodes(classDeclaration, nonPrivateAndNotExistedInHeritageClauseMembers, sourceFile, context, preferences, importAdder, member => insertInterfaceMemberNode(sourceFile, classDeclaration, member));
importAdder.writeFixes(changeTracker);
function createMissingIndexSignatureDeclaration(type: InterfaceType, kind: IndexKind): void {
@@ -0,0 +1,28 @@
/* @internal */
namespace ts.codefix {
const fixId = "fixPropertyAssignment";
const errorCodes = [
Diagnostics.Did_you_mean_to_use_a_Colon_An_can_only_follow_a_property_name_when_the_containing_object_literal_is_part_of_a_destructuring_pattern.code
];
registerCodeFix({
errorCodes,
fixIds: [fixId],
getCodeActions(context) {
const { sourceFile, span } = context;
const property = getProperty(sourceFile, span.start);
const changes = textChanges.ChangeTracker.with(context, t => doChange(t, context.sourceFile, property));
return [createCodeFixAction(fixId, changes, [Diagnostics.Change_0_to_1, "=", ":"], fixId, [Diagnostics.Switch_each_misused_0_to_1, "=", ":"])];
},
getAllCodeActions: context =>
codeFixAll(context, errorCodes, (changes, diag) => doChange(changes, diag.file, getProperty(diag.file, diag.start)))
});
function doChange(changes: textChanges.ChangeTracker, sourceFile: SourceFile, node: ShorthandPropertyAssignment): void {
changes.replaceNode(sourceFile, node, factory.createPropertyAssignment(node.name, node.objectAssignmentInitializer as Expression));
}
function getProperty(sourceFile: SourceFile, pos: number): ShorthandPropertyAssignment {
return cast(getTokenAtPosition(sourceFile, pos).parent, isShorthandPropertyAssignment);
}
}
+47 -29
View File
@@ -34,18 +34,33 @@ namespace ts.codefix {
const changes = textChanges.ChangeTracker.with(context, t => t.delete(sourceFile, importDecl));
return [createDeleteFix(changes, [Diagnostics.Remove_import_from_0, showModuleSpecifier(importDecl)])];
}
const delDestructure = textChanges.ChangeTracker.with(context, t =>
tryDeleteFullDestructure(token, t, sourceFile, checker, sourceFiles, /*isFixAll*/ false));
if (delDestructure.length) {
return [createDeleteFix(delDestructure, Diagnostics.Remove_destructuring)];
if (isObjectBindingPattern(token.parent)) {
if (isParameter(token.parent.parent)) {
const elements = token.parent.elements;
const diagnostic: [DiagnosticMessage, string] = [
elements.length > 1 ? Diagnostics.Remove_unused_declarations_for_Colon_0 : Diagnostics.Remove_unused_declaration_for_Colon_0,
map(elements, e => e.getText(sourceFile)).join(", ")
];
return [
createDeleteFix(textChanges.ChangeTracker.with(context, t =>
deleteDestructuringElements(t, sourceFile, <ObjectBindingPattern>token.parent)), diagnostic)
];
}
return [
createDeleteFix(textChanges.ChangeTracker.with(context, t =>
t.delete(sourceFile, token.parent.parent)), Diagnostics.Remove_unused_destructuring_declaration)
];
}
const delVar = textChanges.ChangeTracker.with(context, t => tryDeleteFullVariableStatement(sourceFile, token, t));
if (delVar.length) {
return [createDeleteFix(delVar, Diagnostics.Remove_variable_statement)];
if (canDeleteEntireVariableStatement(sourceFile, token)) {
return [
createDeleteFix(textChanges.ChangeTracker.with(context, t =>
deleteEntireVariableStatement(t, sourceFile, <VariableDeclarationList>token.parent)), Diagnostics.Remove_variable_statement)
];
}
const result: CodeFixAction[] = [];
if (token.kind === SyntaxKind.InferKeyword) {
const changes = textChanges.ChangeTracker.with(context, t => changeInferToUnknown(t, sourceFile, token));
const name = cast(token.parent, isInferTypeNode).typeParameter.name.text;
@@ -79,7 +94,9 @@ namespace ts.codefix {
tryPrefixDeclaration(changes, diag.code, sourceFile, token);
break;
case fixIdDelete: {
if (token.kind === SyntaxKind.InferKeyword) break; // Can't delete
if (token.kind === SyntaxKind.InferKeyword) {
break; // Can't delete
}
const importDecl = tryGetFullImport(token);
if (importDecl) {
changes.delete(sourceFile, importDecl);
@@ -90,8 +107,18 @@ namespace ts.codefix {
else if (token.kind === SyntaxKind.LessThanToken) {
deleteTypeParameters(changes, sourceFile, token);
}
else if (!tryDeleteFullDestructure(token, changes, sourceFile, checker, sourceFiles, /*isFixAll*/ true) &&
!tryDeleteFullVariableStatement(sourceFile, token, changes)) {
else if (isObjectBindingPattern(token.parent)) {
if (isParameter(token.parent.parent)) {
deleteDestructuringElements(changes, sourceFile, token.parent);
}
else {
changes.delete(sourceFile, token.parent.parent);
}
}
else if (canDeleteEntireVariableStatement(sourceFile, token)) {
deleteEntireVariableStatement(changes, sourceFile, <VariableDeclarationList>token.parent);
}
else {
tryDeleteDeclaration(sourceFile, token, changes, checker, sourceFiles, /*isFixAll*/ true);
}
break;
@@ -125,25 +152,16 @@ namespace ts.codefix {
return token.kind === SyntaxKind.ImportKeyword ? tryCast(token.parent, isImportDeclaration) : undefined;
}
function tryDeleteFullDestructure(token: Node, changes: textChanges.ChangeTracker, sourceFile: SourceFile, checker: TypeChecker, sourceFiles: readonly SourceFile[], isFixAll: boolean): boolean {
if (token.kind !== SyntaxKind.OpenBraceToken || !isObjectBindingPattern(token.parent)) return false;
const decl = token.parent.parent;
if (decl.kind === SyntaxKind.Parameter) {
tryDeleteParameter(changes, sourceFile, decl, checker, sourceFiles, isFixAll);
}
else {
changes.delete(sourceFile, decl);
}
return true;
function canDeleteEntireVariableStatement(sourceFile: SourceFile, token: Node): boolean {
return isVariableDeclarationList(token.parent) && first(token.parent.getChildren(sourceFile)) === token;
}
function tryDeleteFullVariableStatement(sourceFile: SourceFile, token: Node, changes: textChanges.ChangeTracker): boolean {
const declarationList = tryCast(token.parent, isVariableDeclarationList);
if (declarationList && declarationList.getChildren(sourceFile)[0] === token) {
changes.delete(sourceFile, declarationList.parent.kind === SyntaxKind.VariableStatement ? declarationList.parent : declarationList);
return true;
}
return false;
function deleteEntireVariableStatement(changes: textChanges.ChangeTracker, sourceFile: SourceFile, node: VariableDeclarationList) {
changes.delete(sourceFile, node.parent.kind === SyntaxKind.VariableStatement ? node.parent : node);
}
function deleteDestructuringElements(changes: textChanges.ChangeTracker, sourceFile: SourceFile, node: ObjectBindingPattern) {
forEach(node.elements, n => changes.delete(sourceFile, n));
}
function tryPrefixDeclaration(changes: textChanges.ChangeTracker, errorCode: number, sourceFile: SourceFile, token: Node): void {
@@ -205,7 +223,7 @@ namespace ts.codefix {
}
}
function tryDeleteParameter(changes: textChanges.ChangeTracker, sourceFile: SourceFile, p: ParameterDeclaration, checker: TypeChecker, sourceFiles: readonly SourceFile[], isFixAll: boolean): void {
function tryDeleteParameter(changes: textChanges.ChangeTracker, sourceFile: SourceFile, p: ParameterDeclaration, checker: TypeChecker, sourceFiles: readonly SourceFile[], isFixAll = false): void {
if (mayDeleteParameter(p, checker, isFixAll)) {
if (p.modifiers && p.modifiers.length > 0
&& (!isIdentifier(p.name) || FindAllReferences.Core.isSymbolReferencedInFile(p.name, checker, sourceFile))) {
+61 -65
View File
@@ -7,11 +7,11 @@ namespace ts.codefix {
* @param importAdder If provided, type annotations will use identifier type references instead of ImportTypeNodes, and the missing imports will be added to the importAdder.
* @returns Empty string iff there are no member insertions.
*/
export function createMissingMemberNodes(classDeclaration: ClassLikeDeclaration, possiblyMissingSymbols: readonly Symbol[], context: TypeConstructionContext, preferences: UserPreferences, importAdder: ImportAdder | undefined, addClassElement: (node: ClassElement) => void): void {
export function createMissingMemberNodes(classDeclaration: ClassLikeDeclaration, possiblyMissingSymbols: readonly Symbol[], sourceFile: SourceFile, context: TypeConstructionContext, preferences: UserPreferences, importAdder: ImportAdder | undefined, addClassElement: (node: ClassElement) => void): void {
const classMembers = classDeclaration.symbol.members!;
for (const symbol of possiblyMissingSymbols) {
if (!classMembers.has(symbol.escapedName)) {
addNewNodeForMemberSymbol(symbol, classDeclaration, context, preferences, importAdder, addClassElement);
addNewNodeForMemberSymbol(symbol, classDeclaration, sourceFile, context, preferences, importAdder, addClassElement);
}
}
}
@@ -31,7 +31,7 @@ namespace ts.codefix {
/**
* @returns Empty string iff there we can't figure out a representation for `symbol` in `enclosingDeclaration`.
*/
function addNewNodeForMemberSymbol(symbol: Symbol, enclosingDeclaration: ClassLikeDeclaration, context: TypeConstructionContext, preferences: UserPreferences, importAdder: ImportAdder | undefined, addClassElement: (node: Node) => void): void {
function addNewNodeForMemberSymbol(symbol: Symbol, enclosingDeclaration: ClassLikeDeclaration, sourceFile: SourceFile, context: TypeConstructionContext, preferences: UserPreferences, importAdder: ImportAdder | undefined, addClassElement: (node: Node) => void): void {
const declarations = symbol.getDeclarations();
if (!(declarations && declarations.length)) {
return undefined;
@@ -45,16 +45,17 @@ namespace ts.codefix {
const type = checker.getWidenedType(checker.getTypeOfSymbolAtLocation(symbol, enclosingDeclaration));
const optional = !!(symbol.flags & SymbolFlags.Optional);
const ambient = !!(enclosingDeclaration.flags & NodeFlags.Ambient);
const quotePreference = getQuotePreference(sourceFile, preferences);
switch (declaration.kind) {
case SyntaxKind.PropertySignature:
case SyntaxKind.PropertyDeclaration:
const flags = preferences.quotePreference === "single" ? NodeBuilderFlags.UseSingleQuotesForStringLiteralType : undefined;
const flags = quotePreference === QuotePreference.Single ? NodeBuilderFlags.UseSingleQuotesForStringLiteralType : undefined;
let typeNode = checker.typeToTypeNode(type, enclosingDeclaration, flags, getNoopSymbolTrackerWithResolver(context));
if (importAdder) {
const importableReference = tryGetAutoImportableReferenceFromImportTypeNode(typeNode, type, scriptTarget);
const importableReference = tryGetAutoImportableReferenceFromTypeNode(typeNode, scriptTarget);
if (importableReference) {
typeNode = importableReference.typeReference;
typeNode = importableReference.typeNode;
importSymbols(importAdder, importableReference.symbols);
}
}
@@ -74,9 +75,9 @@ namespace ts.codefix {
? [allAccessors.firstAccessor, allAccessors.secondAccessor]
: [allAccessors.firstAccessor];
if (importAdder) {
const importableReference = tryGetAutoImportableReferenceFromImportTypeNode(typeNode, type, scriptTarget);
const importableReference = tryGetAutoImportableReferenceFromTypeNode(typeNode, scriptTarget);
if (importableReference) {
typeNode = importableReference.typeReference;
typeNode = importableReference.typeNode;
importSymbols(importAdder, importableReference.symbols);
}
}
@@ -88,7 +89,7 @@ namespace ts.codefix {
name,
emptyArray,
typeNode,
ambient ? undefined : createStubbedMethodBody(preferences)));
ambient ? undefined : createStubbedMethodBody(quotePreference)));
}
else {
Debug.assertNode(accessor, isSetAccessorDeclaration, "The counterpart to a getter should be a setter");
@@ -99,7 +100,7 @@ namespace ts.codefix {
modifiers,
name,
createDummyParameters(1, [parameterName], [typeNode], 1, /*inJs*/ false),
ambient ? undefined : createStubbedMethodBody(preferences)));
ambient ? undefined : createStubbedMethodBody(quotePreference)));
}
}
break;
@@ -121,36 +122,37 @@ namespace ts.codefix {
if (declarations.length === 1) {
Debug.assert(signatures.length === 1, "One declaration implies one signature");
const signature = signatures[0];
outputMethod(signature, modifiers, name, ambient ? undefined : createStubbedMethodBody(preferences));
outputMethod(quotePreference, signature, modifiers, name, ambient ? undefined : createStubbedMethodBody(quotePreference));
break;
}
for (const signature of signatures) {
// Need to ensure nodes are fresh each time so they can have different positions.
outputMethod(signature, getSynthesizedDeepClones(modifiers, /*includeTrivia*/ false), getSynthesizedDeepClone(name, /*includeTrivia*/ false));
outputMethod(quotePreference, signature, getSynthesizedDeepClones(modifiers, /*includeTrivia*/ false), getSynthesizedDeepClone(name, /*includeTrivia*/ false));
}
if (!ambient) {
if (declarations.length > signatures.length) {
const signature = checker.getSignatureFromDeclaration(declarations[declarations.length - 1] as SignatureDeclaration)!;
outputMethod(signature, modifiers, name, createStubbedMethodBody(preferences));
outputMethod(quotePreference, signature, modifiers, name, createStubbedMethodBody(quotePreference));
}
else {
Debug.assert(declarations.length === signatures.length, "Declarations and signatures should match count");
addClassElement(createMethodImplementingSignatures(signatures, name, optional, modifiers, preferences));
addClassElement(createMethodImplementingSignatures(signatures, name, optional, modifiers, quotePreference));
}
}
break;
}
function outputMethod(signature: Signature, modifiers: NodeArray<Modifier> | undefined, name: PropertyName, body?: Block): void {
const method = signatureToMethodDeclaration(context, signature, enclosingDeclaration, modifiers, name, optional, body, importAdder);
function outputMethod(quotePreference: QuotePreference, signature: Signature, modifiers: NodeArray<Modifier> | undefined, name: PropertyName, body?: Block): void {
const method = signatureToMethodDeclaration(context, quotePreference, signature, enclosingDeclaration, modifiers, name, optional, body, importAdder);
if (method) addClassElement(method);
}
}
function signatureToMethodDeclaration(
context: TypeConstructionContext,
quotePreference: QuotePreference,
signature: Signature,
enclosingDeclaration: ClassLikeDeclaration,
modifiers: NodeArray<Modifier> | undefined,
@@ -162,7 +164,8 @@ namespace ts.codefix {
const program = context.program;
const checker = program.getTypeChecker();
const scriptTarget = getEmitScriptTarget(program.getCompilerOptions());
const signatureDeclaration = <MethodDeclaration>checker.signatureToSignatureDeclaration(signature, SyntaxKind.MethodDeclaration, enclosingDeclaration, NodeBuilderFlags.NoTruncation | NodeBuilderFlags.SuppressAnyReturnType, getNoopSymbolTrackerWithResolver(context));
const flags = NodeBuilderFlags.NoTruncation | NodeBuilderFlags.SuppressAnyReturnType | (quotePreference === QuotePreference.Single ? NodeBuilderFlags.UseSingleQuotesForStringLiteralType : 0);
const signatureDeclaration = <MethodDeclaration>checker.signatureToSignatureDeclaration(signature, SyntaxKind.MethodDeclaration, enclosingDeclaration, flags, getNoopSymbolTrackerWithResolver(context));
if (!signatureDeclaration) {
return undefined;
}
@@ -172,21 +175,20 @@ namespace ts.codefix {
let type = signatureDeclaration.type;
if (importAdder) {
if (typeParameters) {
const newTypeParameters = sameMap(typeParameters, (typeParameterDecl, i) => {
const typeParameter = signature.typeParameters![i];
const newTypeParameters = sameMap(typeParameters, typeParameterDecl => {
let constraint = typeParameterDecl.constraint;
let defaultType = typeParameterDecl.default;
if (constraint) {
const importableReference = tryGetAutoImportableReferenceFromImportTypeNode(constraint, typeParameter.constraint, scriptTarget);
const importableReference = tryGetAutoImportableReferenceFromTypeNode(constraint, scriptTarget);
if (importableReference) {
constraint = importableReference.typeReference;
constraint = importableReference.typeNode;
importSymbols(importAdder, importableReference.symbols);
}
}
if (defaultType) {
const importableReference = tryGetAutoImportableReferenceFromImportTypeNode(defaultType, typeParameter.default, scriptTarget);
const importableReference = tryGetAutoImportableReferenceFromTypeNode(defaultType, scriptTarget);
if (importableReference) {
defaultType = importableReference.typeReference;
defaultType = importableReference.typeNode;
importSymbols(importAdder, importableReference.symbols);
}
}
@@ -201,12 +203,11 @@ namespace ts.codefix {
typeParameters = setTextRange(factory.createNodeArray(newTypeParameters, typeParameters.hasTrailingComma), typeParameters);
}
}
const newParameters = sameMap(parameters, (parameterDecl, i) => {
const parameter = signature.parameters[i];
const importableReference = tryGetAutoImportableReferenceFromImportTypeNode(parameterDecl.type, checker.getTypeAtLocation(parameter.valueDeclaration), scriptTarget);
const newParameters = sameMap(parameters, parameterDecl => {
const importableReference = tryGetAutoImportableReferenceFromTypeNode(parameterDecl.type, scriptTarget);
let type = parameterDecl.type;
if (importableReference) {
type = importableReference.typeReference;
type = importableReference.typeNode;
importSymbols(importAdder, importableReference.symbols);
}
return factory.updateParameterDeclaration(
@@ -224,9 +225,9 @@ namespace ts.codefix {
parameters = setTextRange(factory.createNodeArray(newParameters, parameters.hasTrailingComma), parameters);
}
if (type) {
const importableReference = tryGetAutoImportableReferenceFromImportTypeNode(type, signature.resolvedReturnType, scriptTarget);
const importableReference = tryGetAutoImportableReferenceFromTypeNode(type, scriptTarget);
if (importableReference) {
type = importableReference.typeReference;
type = importableReference.typeNode;
importSymbols(importAdder, importableReference.symbols);
}
}
@@ -266,6 +267,7 @@ namespace ts.codefix {
isIdentifier(arg) ? arg.text : isPropertyAccessExpression(arg) && isIdentifier(arg.name) ? arg.name.text : undefined);
const contextualType = checker.getContextualType(call);
const returnType = (inJs || !contextualType) ? undefined : checker.typeToTypeNode(contextualType, contextNode, /*flags*/ undefined, tracker);
const quotePreference = getQuotePreference(context.sourceFile, context.preferences);
return factory.createMethodDeclaration(
/*decorators*/ undefined,
/*modifiers*/ modifierFlags ? factory.createNodeArray(factory.createModifiersFromModifierFlags(modifierFlags)) : undefined,
@@ -276,16 +278,16 @@ namespace ts.codefix {
factory.createTypeParameterDeclaration(CharacterCodes.T + typeArguments!.length - 1 <= CharacterCodes.Z ? String.fromCharCode(CharacterCodes.T + i) : `T${i}`)),
/*parameters*/ createDummyParameters(args.length, names, types, /*minArgumentCount*/ undefined, inJs),
/*type*/ returnType,
body ? createStubbedMethodBody(context.preferences) : undefined);
body ? createStubbedMethodBody(quotePreference) : undefined);
}
export function typeToAutoImportableTypeNode(checker: TypeChecker, importAdder: ImportAdder, type: Type, contextNode: Node, scriptTarget: ScriptTarget, flags?: NodeBuilderFlags, tracker?: SymbolTracker): TypeNode | undefined {
const typeNode = checker.typeToTypeNode(type, contextNode, flags, tracker);
if (typeNode && isImportTypeNode(typeNode)) {
const importableReference = tryGetAutoImportableReferenceFromImportTypeNode(typeNode, type, scriptTarget);
const importableReference = tryGetAutoImportableReferenceFromTypeNode(typeNode, scriptTarget);
if (importableReference) {
importSymbols(importAdder, importableReference.symbols);
return importableReference.typeReference;
return importableReference.typeNode;
}
}
return typeNode;
@@ -312,7 +314,7 @@ namespace ts.codefix {
name: PropertyName,
optional: boolean,
modifiers: readonly Modifier[] | undefined,
preferences: UserPreferences,
quotePreference: QuotePreference,
): MethodDeclaration {
/** This is *a* signature with the maximal number of arguments,
* such that if there is a "maximal" signature without rest arguments,
@@ -355,7 +357,7 @@ namespace ts.codefix {
/*typeParameters*/ undefined,
parameters,
/*returnType*/ undefined,
preferences);
quotePreference);
}
function createStubbedMethod(
@@ -365,7 +367,7 @@ namespace ts.codefix {
typeParameters: readonly TypeParameterDeclaration[] | undefined,
parameters: readonly ParameterDeclaration[],
returnType: TypeNode | undefined,
preferences: UserPreferences
quotePreference: QuotePreference
): MethodDeclaration {
return factory.createMethodDeclaration(
/*decorators*/ undefined,
@@ -376,17 +378,17 @@ namespace ts.codefix {
typeParameters,
parameters,
returnType,
createStubbedMethodBody(preferences));
createStubbedMethodBody(quotePreference));
}
function createStubbedMethodBody(preferences: UserPreferences): Block {
function createStubbedMethodBody(quotePreference: QuotePreference): Block {
return factory.createBlock(
[factory.createThrowStatement(
factory.createNewExpression(
factory.createIdentifier("Error"),
/*typeArguments*/ undefined,
// TODO Handle auto quote preference.
[factory.createStringLiteral("Method not implemented.", /*isSingleQuote*/ preferences.quotePreference === "single")]))],
[factory.createStringLiteral("Method not implemented.", /*isSingleQuote*/ quotePreference === QuotePreference.Single)]))],
/*multiline*/ true);
}
@@ -450,38 +452,32 @@ namespace ts.codefix {
}
/**
* Given an ImportTypeNode 'import("./a").SomeType<import("./b").OtherType<...>>',
* Given a type node containing 'import("./a").SomeType<import("./b").OtherType<...>>',
* returns an equivalent type reference node with any nested ImportTypeNodes also replaced
* with type references, and a list of symbols that must be imported to use the type reference.
*/
export function tryGetAutoImportableReferenceFromImportTypeNode(importTypeNode: TypeNode | undefined, type: Type | undefined, scriptTarget: ScriptTarget) {
if (importTypeNode && isLiteralImportTypeNode(importTypeNode) && importTypeNode.qualifier && (!type || type.symbol)) {
// Symbol for the left-most thing after the dot
const firstIdentifier = getFirstIdentifier(importTypeNode.qualifier);
const name = getNameForExportedSymbol(firstIdentifier.symbol, scriptTarget);
const qualifier = name !== firstIdentifier.text
? replaceFirstIdentifierOfEntityName(importTypeNode.qualifier, factory.createIdentifier(name))
: importTypeNode.qualifier;
export function tryGetAutoImportableReferenceFromTypeNode(importTypeNode: TypeNode | undefined, scriptTarget: ScriptTarget) {
let symbols: Symbol[] | undefined;
const typeNode = visitNode(importTypeNode, visit);
if (symbols && typeNode) {
return { typeNode, symbols };
}
const symbols = [firstIdentifier.symbol];
const typeArguments: TypeNode[] = [];
if (importTypeNode.typeArguments) {
importTypeNode.typeArguments.forEach(arg => {
const ref = tryGetAutoImportableReferenceFromImportTypeNode(arg, /*undefined*/ type, scriptTarget);
if (ref) {
symbols.push(...ref.symbols);
typeArguments.push(ref.typeReference);
}
else {
typeArguments.push(arg);
}
});
function visit(node: TypeNode): TypeNode;
function visit(node: Node): Node {
if (isLiteralImportTypeNode(node) && node.qualifier) {
// Symbol for the left-most thing after the dot
const firstIdentifier = getFirstIdentifier(node.qualifier);
const name = getNameForExportedSymbol(firstIdentifier.symbol, scriptTarget);
const qualifier = name !== firstIdentifier.text
? replaceFirstIdentifierOfEntityName(node.qualifier, factory.createIdentifier(name))
: node.qualifier;
symbols = append(symbols, firstIdentifier.symbol);
const typeArguments = node.typeArguments?.map(visit);
return factory.createTypeReferenceNode(qualifier, typeArguments);
}
return {
symbols,
typeReference: factory.createTypeReferenceNode(qualifier, typeArguments)
};
return visitEachChild(node, visit, nullTransformationContext);
}
}
+1 -1
View File
@@ -519,7 +519,7 @@ namespace ts.codefix {
program: Program,
useAutoImportProvider: boolean,
host: LanguageServiceHost
): ReadonlyMap<string, readonly SymbolExportInfo[]> {
): ReadonlyESMap<string, readonly SymbolExportInfo[]> {
// For each original symbol, keep all re-exports of that symbol together so we can call `getCodeActionsForImport` on the whole group at once.
// Maps symbol id to info for modules providing that symbol (original export + re-exports).
const originalSymbolToExportInfos = createMultiMap<SymbolExportInfo>();
+3 -4
View File
@@ -310,7 +310,7 @@ namespace ts.codefix {
const typeTag = isGetAccessorDeclaration(declaration) ? factory.createJSDocReturnTag(/*tagName*/ undefined, typeExpression, "") : factory.createJSDocTypeTag(/*tagName*/ undefined, typeExpression, "");
addJSDocTags(changes, sourceFile, parent, [typeTag]);
}
else if (!tryReplaceImportTypeNodeWithAutoImport(typeNode, declaration, type, sourceFile, changes, importAdder, getEmitScriptTarget(program.getCompilerOptions()))) {
else if (!tryReplaceImportTypeNodeWithAutoImport(typeNode, declaration, sourceFile, changes, importAdder, getEmitScriptTarget(program.getCompilerOptions()))) {
changes.tryInsertTypeAnnotation(sourceFile, declaration, typeNode);
}
}
@@ -319,14 +319,13 @@ namespace ts.codefix {
function tryReplaceImportTypeNodeWithAutoImport(
typeNode: TypeNode,
declaration: textChanges.TypeAnnotatable,
type: Type,
sourceFile: SourceFile,
changes: textChanges.ChangeTracker,
importAdder: ImportAdder,
scriptTarget: ScriptTarget
): boolean {
const importableReference = tryGetAutoImportableReferenceFromImportTypeNode(typeNode, type, scriptTarget);
if (importableReference && changes.tryInsertTypeAnnotation(sourceFile, declaration, importableReference.typeReference)) {
const importableReference = tryGetAutoImportableReferenceFromTypeNode(typeNode, scriptTarget);
if (importableReference && changes.tryInsertTypeAnnotation(sourceFile, declaration, importableReference.typeNode)) {
forEach(importableReference.symbols, s => importAdder.addImportFromExportedSymbol(s, /*usageIsTypeOnly*/ true));
return true;
}
+2 -6
View File
@@ -1464,7 +1464,7 @@ namespace ts.Completions {
function filterGlobalCompletion(symbols: Symbol[]): void {
const isTypeOnly = isTypeOnlyCompletion();
if (isTypeOnly) {
keywordFilters = isTypeAssertion()
keywordFilters = contextToken && isAssertionExpression(contextToken.parent)
? KeywordCompletionFilters.TypeAssertionKeywords
: KeywordCompletionFilters.TypeKeywords;
}
@@ -1494,10 +1494,6 @@ namespace ts.Completions {
});
}
function isTypeAssertion(): boolean {
return isAssertionExpression(contextToken.parent);
}
function isTypeOnlyCompletion(): boolean {
return insideJsDocTagTypeExpression
|| !isContextTokenValueLocation(contextToken) &&
@@ -2438,7 +2434,7 @@ namespace ts.Completions {
!existingMemberNames.has(propertySymbol.escapedName) &&
!!propertySymbol.declarations &&
!(getDeclarationModifierFlagsFromSymbol(propertySymbol) & ModifierFlags.Private) &&
!isPrivateIdentifierPropertyDeclaration(propertySymbol.valueDeclaration));
!(propertySymbol.valueDeclaration && isPrivateIdentifierPropertyDeclaration(propertySymbol.valueDeclaration)));
}
/**
+1 -1
View File
@@ -118,7 +118,7 @@ namespace ts {
export function createDocumentRegistryInternal(useCaseSensitiveFileNames?: boolean, currentDirectory = "", externalCache?: ExternalDocumentCache): DocumentRegistry {
// Maps from compiler setting target (ES3, ES5, etc.) to all the cached documents we have
// for those settings.
const buckets = new Map<string, Map<Path, DocumentRegistryEntry>>();
const buckets = new Map<string, ESMap<Path, DocumentRegistryEntry>>();
const getCanonicalFileName = createGetCanonicalFileName(!!useCaseSensitiveFileNames);
function reportStats() {
+1 -1
View File
@@ -1754,7 +1754,7 @@ namespace ts.FindAllReferences {
* @param parent Another class or interface Symbol
* @param cachedResults A map of symbol id pairs (i.e. "child,parent") to booleans indicating previous results
*/
function explicitlyInheritsFrom(symbol: Symbol, parent: Symbol, cachedResults: Map<string, boolean>, checker: TypeChecker): boolean {
function explicitlyInheritsFrom(symbol: Symbol, parent: Symbol, cachedResults: ESMap<string, boolean>, checker: TypeChecker): boolean {
if (symbol === parent) {
return true;
}
+2 -2
View File
@@ -348,8 +348,8 @@ namespace ts.formatting {
anyToken,
[isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext, isNotForContext],
RuleAction.InsertSpace),
// This low-pri rule takes care of "try {" and "finally {" in case the rule SpaceBeforeOpenBraceInControl didn't execute on FormatOnEnter.
rule("SpaceAfterTryFinally", [SyntaxKind.TryKeyword, SyntaxKind.FinallyKeyword], SyntaxKind.OpenBraceToken, [isNonJsxSameLineTokenContext], RuleAction.InsertSpace),
// This low-pri rule takes care of "try {", "catch {" and "finally {" in case the rule SpaceBeforeOpenBraceInControl didn't execute on FormatOnEnter.
rule("SpaceAfterTryCatchFinally", [SyntaxKind.TryKeyword, SyntaxKind.CatchKeyword, SyntaxKind.FinallyKeyword], SyntaxKind.OpenBraceToken, [isNonJsxSameLineTokenContext], RuleAction.InsertSpace),
];
return [
+2 -2
View File
@@ -40,7 +40,7 @@ namespace ts.FindAllReferences {
function getImportersForExport(
sourceFiles: readonly SourceFile[],
sourceFilesSet: ReadonlySet<string>,
allDirectImports: Map<string, ImporterOrCallExpression[]>,
allDirectImports: ESMap<string, ImporterOrCallExpression[]>,
{ exportingModuleSymbol, exportKind }: ExportInfo,
checker: TypeChecker,
cancellationToken: CancellationToken | undefined,
@@ -368,7 +368,7 @@ namespace ts.FindAllReferences {
}
/** Returns a map from a module symbol Id to all import statements that directly reference the module. */
function getDirectImportsMap(sourceFiles: readonly SourceFile[], checker: TypeChecker, cancellationToken: CancellationToken | undefined): Map<string, ImporterOrCallExpression[]> {
function getDirectImportsMap(sourceFiles: readonly SourceFile[], checker: TypeChecker, cancellationToken: CancellationToken | undefined): ESMap<string, ImporterOrCallExpression[]> {
const map = new Map<string, ImporterOrCallExpression[]>();
for (const sourceFile of sourceFiles) {
+2 -2
View File
@@ -33,8 +33,8 @@ namespace ts.NavigationBar {
let parentsStack: NavigationBarNode[] = [];
let parent: NavigationBarNode;
const trackedEs5ClassesStack: (Map<string, boolean> | undefined)[] = [];
let trackedEs5Classes: Map<string, boolean> | undefined;
const trackedEs5ClassesStack: (ESMap<string, boolean> | undefined)[] = [];
let trackedEs5Classes: ESMap<string, boolean> | undefined;
// NavigationBarItem requires an array, but will not mutate it, so just give it this for performance.
let emptyChildItemArray: NavigationBarItem[] = [];
@@ -227,6 +227,31 @@ namespace ts.OutliningElementsCollector {
return spanForTemplateLiteral(<TemplateExpression | NoSubstitutionTemplateLiteral>n);
case SyntaxKind.ArrayBindingPattern:
return spanForNode(n, /*autoCollapse*/ false, /*useFullStart*/ !isBindingElement(n.parent), SyntaxKind.OpenBracketToken);
case SyntaxKind.ArrowFunction:
return spanForArrowFunction(<ArrowFunction>n);
case SyntaxKind.CallExpression:
return spanForCallExpression(<CallExpression>n);
}
function spanForCallExpression(node: CallExpression): OutliningSpan | undefined {
if (!node.arguments.length) {
return undefined;
}
const openToken = findChildOfKind(node, SyntaxKind.OpenParenToken, sourceFile);
const closeToken = findChildOfKind(node, SyntaxKind.CloseParenToken, sourceFile);
if (!openToken || !closeToken || positionsAreOnSameLine(openToken.pos, closeToken.pos, sourceFile)) {
return undefined;
}
return spanBetweenTokens(openToken, closeToken, node, sourceFile, /*autoCollapse*/ false, /*useFullStart*/ true);
}
function spanForArrowFunction(node: ArrowFunction): OutliningSpan | undefined {
if (isBlock(node.body) || positionsAreOnSameLine(node.body.getFullStart(), node.body.getEnd(), sourceFile)) {
return undefined;
}
const textSpan = createTextSpanFromBounds(node.body.getFullStart(), node.body.getEnd());
return createOutliningSpan(textSpan, OutliningSpanKind.Code, createTextSpanFromNode(node));
}
function spanForJSXElement(node: JsxElement): OutliningSpan | undefined {
+4 -4
View File
@@ -115,7 +115,7 @@ namespace ts {
};
}
function getFullMatch(candidateContainers: readonly string[], candidate: string, dotSeparatedSegments: readonly Segment[], stringToWordSpans: Map<string, TextSpan[]>): PatternMatch | undefined {
function getFullMatch(candidateContainers: readonly string[], candidate: string, dotSeparatedSegments: readonly Segment[], stringToWordSpans: ESMap<string, TextSpan[]>): PatternMatch | undefined {
// First, check that the last part of the dot separated pattern matches the name of the
// candidate. If not, then there's no point in proceeding and doing the more
// expensive work.
@@ -141,7 +141,7 @@ namespace ts {
return bestMatch;
}
function getWordSpans(word: string, stringToWordSpans: Map<string, TextSpan[]>): TextSpan[] {
function getWordSpans(word: string, stringToWordSpans: ESMap<string, TextSpan[]>): TextSpan[] {
let spans = stringToWordSpans.get(word);
if (!spans) {
stringToWordSpans.set(word, spans = breakIntoWordSpans(word));
@@ -149,7 +149,7 @@ namespace ts {
return spans;
}
function matchTextChunk(candidate: string, chunk: TextChunk, stringToWordSpans: Map<string, TextSpan[]>): PatternMatch | undefined {
function matchTextChunk(candidate: string, chunk: TextChunk, stringToWordSpans: ESMap<string, TextSpan[]>): PatternMatch | undefined {
const index = indexOfIgnoringCase(candidate, chunk.textLowerCase);
if (index === 0) {
// a) Check if the word is a prefix of the candidate, in a case insensitive or
@@ -201,7 +201,7 @@ namespace ts {
}
}
function matchSegment(candidate: string, segment: Segment, stringToWordSpans: Map<string, TextSpan[]>): PatternMatch | undefined {
function matchSegment(candidate: string, segment: Segment, stringToWordSpans: ESMap<string, TextSpan[]>): PatternMatch | undefined {
// First check if the segment matches as is. This is also useful if the segment contains
// characters we would normally strip when splitting into parts that we also may want to
// match in the candidate. For example if the segment is "@int" and the candidate is
+1 -1
View File
@@ -2,7 +2,7 @@
namespace ts.refactor {
// A map with the refactor code as key, the refactor itself as value
// e.g. nonSuggestableRefactors[refactorCode] -> the refactor you want
const refactors: Map<string, Refactor> = new Map<string, Refactor>();
const refactors = new Map<string, Refactor>();
/** @param name An unique code associated with each refactor. Does not have to be human-readable. */
export function registerRefactor(name: string, refactor: Refactor) {
+20 -15
View File
@@ -43,11 +43,11 @@ namespace ts.refactor.extractSymbol {
}
const functionActions: RefactorActionInfo[] = [];
const usedFunctionNames: Map<string, boolean> = new Map();
const usedFunctionNames = new Map<string, boolean>();
let innermostErrorFunctionAction: RefactorActionInfo | undefined;
const constantActions: RefactorActionInfo[] = [];
const usedConstantNames: Map<string, boolean> = new Map();
const usedConstantNames = new Map<string, boolean>();
let innermostErrorConstantAction: RefactorActionInfo | undefined;
let i = 0;
@@ -915,6 +915,9 @@ namespace ts.refactor.extractSymbol {
if (range.facts & RangeFacts.IsAsyncFunction) {
call = factory.createAwaitExpression(call);
}
if (isInJSXContent(node)) {
call = factory.createJsxExpression(/*dotDotDotToken*/ undefined, call);
}
if (exposedVariableDeclarations.length && !writes) {
// No need to mix declarations and writes.
@@ -1118,12 +1121,16 @@ namespace ts.refactor.extractSymbol {
variableType,
initializer);
const localReference = factory.createPropertyAccessExpression(
let localReference: Expression = factory.createPropertyAccessExpression(
rangeFacts & RangeFacts.InStaticRegion
? factory.createIdentifier(scope.name!.getText()) // TODO: GH#18217
: factory.createThis(),
factory.createIdentifier(localNameText));
if (isInJSXContent(node)) {
localReference = factory.createJsxExpression(/*dotDotDotToken*/ undefined, localReference);
}
// Declare
const maxInsertionPos = node.pos;
const nodeToInsertBefore = getNodeToInsertPropertyBefore(maxInsertionPos, scope);
@@ -1194,12 +1201,6 @@ namespace ts.refactor.extractSymbol {
const renameLocation = getRenameLocation(edits, renameFilename, localNameText, /*isDeclaredBeforeUse*/ true);
return { renameFilename, renameLocation, edits };
function isInJSXContent(node: Node) {
if (!isJsxElement(node)) return false;
if (isJsxElement(node.parent)) return true;
return false;
}
function transformFunctionInitializerAndType(variableType: TypeNode | undefined, initializer: Expression): { variableType: TypeNode | undefined, initializer: Expression } {
// If no contextual type exists there is nothing to transfer to the function signature
if (variableType === undefined) return { variableType, initializer };
@@ -1321,7 +1322,7 @@ namespace ts.refactor.extractSymbol {
}
}
function transformFunctionBody(body: Node, exposedVariableDeclarations: readonly VariableDeclaration[], writes: readonly UsageEntry[] | undefined, substitutions: ReadonlyMap<string, Node>, hasReturn: boolean): { body: Block, returnValueProperty: string | undefined } {
function transformFunctionBody(body: Node, exposedVariableDeclarations: readonly VariableDeclaration[], writes: readonly UsageEntry[] | undefined, substitutions: ReadonlyESMap<string, Node>, hasReturn: boolean): { body: Block, returnValueProperty: string | undefined } {
const hasWritesOrVariableDeclarations = writes !== undefined || exposedVariableDeclarations.length > 0;
if (isBlock(body) && !hasWritesOrVariableDeclarations && substitutions.size === 0) {
// already block, no declarations or writes to propagate back, no substitutions - can use node as is
@@ -1377,7 +1378,7 @@ namespace ts.refactor.extractSymbol {
}
}
function transformConstantInitializer(initializer: Expression, substitutions: ReadonlyMap<string, Node>): Expression {
function transformConstantInitializer(initializer: Expression, substitutions: ReadonlyESMap<string, Node>): Expression {
return substitutions.size
? visitor(initializer) as Expression
: initializer;
@@ -1525,9 +1526,9 @@ namespace ts.refactor.extractSymbol {
}
interface ScopeUsages {
readonly usages: Map<string, UsageEntry>;
readonly typeParameterUsages: Map<string, TypeParameter>; // Key is type ID
readonly substitutions: Map<string, Node>;
readonly usages: ESMap<string, UsageEntry>;
readonly typeParameterUsages: ESMap<string, TypeParameter>; // Key is type ID
readonly substitutions: ESMap<string, Node>;
}
interface ReadsAndWrites {
@@ -1547,7 +1548,7 @@ namespace ts.refactor.extractSymbol {
const allTypeParameterUsages = new Map<string, TypeParameter>(); // Key is type ID
const usagesPerScope: ScopeUsages[] = [];
const substitutionsPerScope: Map<string, Node>[] = [];
const substitutionsPerScope: ESMap<string, Node>[] = [];
const functionErrorsPerScope: Diagnostic[][] = [];
const constantErrorsPerScope: Diagnostic[][] = [];
const visibleDeclarationsInExtractedRange: NamedDeclaration[] = [];
@@ -1953,4 +1954,8 @@ namespace ts.refactor.extractSymbol {
return false;
}
}
function isInJSXContent(node: Node) {
return (isJsxElement(node) || isJsxSelfClosingElement(node) || isJsxFragment(node)) && isJsxElement(node.parent);
}
}
+7 -7
View File
@@ -634,13 +634,13 @@ namespace ts {
public scriptKind!: ScriptKind;
public languageVersion!: ScriptTarget;
public languageVariant!: LanguageVariant;
public identifiers!: Map<string, string>;
public identifiers!: ESMap<string, string>;
public nameTable: UnderscoreEscapedMap<number> | undefined;
public resolvedModules: Map<string, ResolvedModuleFull> | undefined;
public resolvedTypeReferenceDirectiveNames!: Map<string, ResolvedTypeReferenceDirective>;
public resolvedModules: ESMap<string, ResolvedModuleFull> | undefined;
public resolvedTypeReferenceDirectiveNames!: ESMap<string, ResolvedTypeReferenceDirective>;
public imports!: readonly StringLiteralLike[];
public moduleAugmentations!: StringLiteral[];
private namedDeclarations: Map<string, Declaration[]> | undefined;
private namedDeclarations: ESMap<string, Declaration[]> | undefined;
public ambientModuleNames!: string[];
public checkJsDirective: CheckJsDirective | undefined;
public errorExpectations: TextRange[] | undefined;
@@ -686,7 +686,7 @@ namespace ts {
return fullText[lastCharPos] === "\n" && fullText[lastCharPos - 1] === "\r" ? lastCharPos - 1 : lastCharPos;
}
public getNamedDeclarations(): Map<string, Declaration[]> {
public getNamedDeclarations(): ESMap<string, Declaration[]> {
if (!this.namedDeclarations) {
this.namedDeclarations = this.computeNamedDeclarations();
}
@@ -694,7 +694,7 @@ namespace ts {
return this.namedDeclarations;
}
private computeNamedDeclarations(): Map<string, Declaration[]> {
private computeNamedDeclarations(): ESMap<string, Declaration[]> {
const result = createMultiMap<Declaration>();
this.forEachChild(visit);
@@ -937,7 +937,7 @@ namespace ts {
// at each language service public entry point, since we don't know when
// the set of scripts handled by the host changes.
class HostCache {
private fileNameToEntry: Map<Path, CachedHostFileInformation>;
private fileNameToEntry: ESMap<Path, CachedHostFileInformation>;
private _compilationSettings: CompilerOptions;
private currentDirectory: string;
+2 -2
View File
@@ -25,11 +25,11 @@ namespace ts {
fileNames: string[]; // The file names that belong to the same project.
projectRootPath: string; // The path to the project root directory
safeListPath: string; // The path used to retrieve the safe list
packageNameToTypingLocation: Map<string, JsTyping.CachedTyping>; // The map of package names to their cached typing locations and installed versions
packageNameToTypingLocation: ESMap<string, JsTyping.CachedTyping>; // The map of package names to their cached typing locations and installed versions
typeAcquisition: TypeAcquisition; // Used to customize the type acquisition process
compilerOptions: CompilerOptions; // Used as a source for typing inference
unresolvedImports: readonly string[]; // List of unresolved module ids from imports
typesRegistry: ReadonlyMap<string, MapLike<string>>; // The map of available typings in npm to maps of TS versions to their latest supported versions
typesRegistry: ReadonlyESMap<string, MapLike<string>>; // The map of available typings in npm to maps of TS versions to their latest supported versions
}
export interface ScriptSnapshotShim {
+13 -4
View File
@@ -120,14 +120,22 @@ namespace ts.SignatureHelp {
if (argumentInfo.invocation.kind === InvocationKind.Contextual) return undefined;
// See if we can find some symbol with the call expression name that has call signatures.
const expression = getExpressionFromInvocation(argumentInfo.invocation);
const name = isIdentifier(expression) ? expression.text : isPropertyAccessExpression(expression) ? expression.name.text : undefined;
const name = isPropertyAccessExpression(expression) ? expression.name.text : undefined;
const typeChecker = program.getTypeChecker();
return name === undefined ? undefined : firstDefined(program.getSourceFiles(), sourceFile =>
firstDefined(sourceFile.getNamedDeclarations().get(name), declaration => {
const type = declaration.symbol && typeChecker.getTypeOfSymbolAtLocation(declaration.symbol, declaration);
const callSignatures = type && type.getCallSignatures();
if (callSignatures && callSignatures.length) {
return typeChecker.runWithCancellationToken(cancellationToken, typeChecker => createSignatureHelpItems(callSignatures, callSignatures[0], argumentInfo, sourceFile, typeChecker));
return typeChecker.runWithCancellationToken(
cancellationToken,
typeChecker => createSignatureHelpItems(
callSignatures,
callSignatures[0],
argumentInfo,
sourceFile,
typeChecker,
/*useFullPrefix*/ true));
}
}));
}
@@ -496,10 +504,11 @@ namespace ts.SignatureHelp {
{ isTypeParameterList, argumentCount, argumentsSpan: applicableSpan, invocation, argumentIndex }: ArgumentListInfo,
sourceFile: SourceFile,
typeChecker: TypeChecker,
useFullPrefix?: boolean,
): SignatureHelpItems {
const enclosingDeclaration = getEnclosingDeclarationFromInvocation(invocation);
const callTargetSymbol = invocation.kind === InvocationKind.Contextual ? invocation.symbol : typeChecker.getSymbolAtLocation(getExpressionFromInvocation(invocation));
const callTargetDisplayParts = callTargetSymbol ? symbolToDisplayParts(typeChecker, callTargetSymbol, /*enclosingDeclaration*/ undefined, /*meaning*/ undefined) : emptyArray;
const callTargetSymbol = invocation.kind === InvocationKind.Contextual ? invocation.symbol : (typeChecker.getSymbolAtLocation(getExpressionFromInvocation(invocation)) || useFullPrefix && resolvedSignature.declaration?.symbol);
const callTargetDisplayParts = callTargetSymbol ? symbolToDisplayParts(typeChecker, callTargetSymbol, useFullPrefix ? sourceFile : undefined, /*meaning*/ undefined) : emptyArray;
const items = map(candidates, candidateSignature => getSignatureHelpItem(candidateSignature, callTargetDisplayParts, isTypeParameterList, typeChecker, enclosingDeclaration, sourceFile));
if (argumentIndex !== 0) {
+1
View File
@@ -76,6 +76,7 @@
"codefixes/fixEnableExperimentalDecorators.ts",
"codefixes/fixEnableJsxFlag.ts",
"codefixes/fixModuleAndTargetOptions.ts",
"codefixes/fixPropertyAssignment.ts",
"codefixes/fixExtendsInterfaceBecomesImplements.ts",
"codefixes/fixForgottenThisPropertyAccess.ts",
"codefixes/fixInvalidJsxCharacters.ts",
+6 -6
View File
@@ -92,7 +92,7 @@ namespace ts {
/* @internal */ scriptSnapshot: IScriptSnapshot | undefined;
/* @internal */ nameTable: UnderscoreEscapedMap<number> | undefined;
/* @internal */ getNamedDeclarations(): Map<string, readonly Declaration[]>;
/* @internal */ getNamedDeclarations(): ESMap<string, readonly Declaration[]>;
getLineAndCharacterOfPosition(pos: number): LineAndCharacter;
getLineEndOfPosition(pos: number): number;
@@ -196,10 +196,10 @@ namespace ts {
export interface PackageJsonInfo {
fileName: string;
parseable: boolean;
dependencies?: Map<string, string>;
devDependencies?: Map<string, string>;
peerDependencies?: Map<string, string>;
optionalDependencies?: Map<string, string>;
dependencies?: ESMap<string, string>;
devDependencies?: ESMap<string, string>;
peerDependencies?: ESMap<string, string>;
optionalDependencies?: ESMap<string, string>;
get(dependencyName: string, inGroups?: PackageJsonDependencyGroup): string | undefined;
has(dependencyName: string, inGroups?: PackageJsonDependencyGroup): boolean;
}
@@ -271,7 +271,7 @@ namespace ts {
/* @internal */
getGlobalTypingsCacheLocation?(): string | undefined;
/* @internal */
getProbableSymlinks?(files: readonly SourceFile[]): ReadonlyMap<string, string>;
getProbableSymlinks?(files: readonly SourceFile[]): ReadonlyESMap<string, string>;
/*
* Required for full import and type reference completions.
+2 -2
View File
@@ -2186,7 +2186,7 @@ namespace ts {
return clone;
}
export function getSynthesizedDeepCloneWithRenames<T extends Node>(node: T, includeTrivia = true, renameMap?: Map<string, Identifier>, checker?: TypeChecker, callback?: (originalNode: Node, clone: Node) => any): T {
export function getSynthesizedDeepCloneWithRenames<T extends Node>(node: T, includeTrivia = true, renameMap?: ESMap<string, Identifier>, checker?: TypeChecker, callback?: (originalNode: Node, clone: Node) => any): T {
let clone;
if (renameMap && checker && isBindingElement(node) && isIdentifier(node.name) && isObjectBindingPattern(node.parent)) {
const symbol = checker.getSymbolAtLocation(node.name);
@@ -2222,7 +2222,7 @@ namespace ts {
}
function getSynthesizedDeepCloneWorker<T extends Node>(node: T, renameMap?: Map<string, Identifier>, checker?: TypeChecker, callback?: (originalNode: Node, clone: Node) => any): T {
function getSynthesizedDeepCloneWorker<T extends Node>(node: T, renameMap?: ESMap<string, Identifier>, checker?: TypeChecker, callback?: (originalNode: Node, clone: Node) => any): T {
const visited = (renameMap || checker || callback) ?
visitEachChild(node, wrapper, nullTransformationContext) :
visitEachChild(node, getSynthesizedDeepClone, nullTransformationContext);
+2 -2
View File
@@ -301,9 +301,9 @@ namespace Harness.Parallel.Worker {
// The root suite for all unit tests.
let unitTestSuite: Suite;
let unitTestSuiteMap: ts.Map<string, Mocha.Suite>;
let unitTestSuiteMap: ts.ESMap<string, Mocha.Suite>;
// (Unit) Tests directly within the root suite
let unitTestTestMap: ts.Map<string, Mocha.Test>;
let unitTestTestMap: ts.ESMap<string, Mocha.Test>;
if (runUnitTests) {
unitTestSuite = new Suite("", new Mocha.Context());
@@ -493,7 +493,7 @@ namespace ts {
}
interface VerifyNullNonIncludedOption {
type: () => "string" | "number" | Map<string, number | string>;
type: () => "string" | "number" | ESMap<string, number | string>;
nonNullValue?: string;
}
function verifyNullNonIncludedOption({ type, nonNullValue }: VerifyNullNonIncludedOption) {
+4 -4
View File
@@ -35,7 +35,7 @@ namespace ts {
"Y"
];
function testMapIterationAddedValues<K>(keys: K[], map: Map<K, string>, useForEach: boolean): string {
function testMapIterationAddedValues<K>(keys: K[], map: ESMap<K, string>, useForEach: boolean): string {
let resultString = "";
map.set(keys[0], "1");
@@ -117,13 +117,13 @@ namespace ts {
let MapShim!: MapConstructor;
beforeEach(() => {
function getIterator<I extends readonly any[] | ReadonlySet<any> | ReadonlyMap<any, any> | undefined>(iterable: I): Iterator<
I extends ReadonlyMap<infer K, infer V> ? [K, V] :
function getIterator<I extends readonly any[] | ReadonlySet<any> | ReadonlyESMap<any, any> | undefined>(iterable: I): Iterator<
I extends ReadonlyESMap<infer K, infer V> ? [K, V] :
I extends ReadonlySet<infer T> ? T :
I extends readonly (infer T)[] ? T :
I extends undefined ? undefined :
never>;
function getIterator(iterable: readonly any[] | ReadonlySet<any> | ReadonlyMap<any, any> | undefined): Iterator<any> | undefined {
function getIterator(iterable: readonly any[] | ReadonlySet<any> | ReadonlyESMap<any, any> | undefined): Iterator<any> | undefined {
// override `ts.getIterator` with a version that allows us to iterate over a `MapShim` in an environment with a native `Map`.
if (iterable instanceof MapShim) return iterable.entries();
return ts.getIterator(iterable);
+3 -3
View File
@@ -115,13 +115,13 @@ namespace ts {
let SetShim!: SetConstructor;
beforeEach(() => {
function getIterator<I extends readonly any[] | ReadonlySet<any> | ReadonlyMap<any, any> | undefined>(iterable: I): Iterator<
I extends ReadonlyMap<infer K, infer V> ? [K, V] :
function getIterator<I extends readonly any[] | ReadonlySet<any> | ReadonlyESMap<any, any> | undefined>(iterable: I): Iterator<
I extends ReadonlyESMap<infer K, infer V> ? [K, V] :
I extends ReadonlySet<infer T> ? T :
I extends readonly (infer T)[] ? T :
I extends undefined ? undefined :
never>;
function getIterator(iterable: readonly any[] | ReadonlySet<any> | ReadonlyMap<any, any> | undefined): Iterator<any> | undefined {
function getIterator(iterable: readonly any[] | ReadonlySet<any> | ReadonlyESMap<any, any> | undefined): Iterator<any> | undefined {
// override `ts.getIterator` with a version that allows us to iterate over a `SetShim` in an environment with a native `Set`.
if (iterable instanceof SetShim) return iterable.values();
return ts.getIterator(iterable);
+6
View File
@@ -320,6 +320,12 @@ namespace ts {
`/**
* @author John Doe <john.doe@example.com>
* @author John Doe <john.doe@example.com> unexpected comment
*/`);
parsesCorrectly("consecutive newline tokens",
`/**
* @example
* Some\n\n * text\r\n * with newlines.
*/`);
});
});
+2 -2
View File
@@ -458,7 +458,7 @@ namespace ts {
});
describe("unittests:: moduleResolution:: Relative imports", () => {
function test(files: Map<string, string>, currentDirectory: string, rootFiles: string[], expectedFilesCount: number, relativeNamesToCheck: string[]) {
function test(files: ESMap<string, string>, currentDirectory: string, rootFiles: string[], expectedFilesCount: number, relativeNamesToCheck: string[]) {
const options: CompilerOptions = { module: ModuleKind.CommonJS };
const host: CompilerHost = {
getSourceFile: (fileName: string, languageVersion: ScriptTarget) => {
@@ -533,7 +533,7 @@ export = C;
describe("unittests:: moduleResolution:: Files with different casing with forceConsistentCasingInFileNames", () => {
let library: SourceFile;
function test(
files: Map<string, string>,
files: ESMap<string, string>,
options: CompilerOptions,
currentDirectory: string,
useCaseSensitiveFileNames: boolean,
+18
View File
@@ -53,6 +53,24 @@ describe("unittests:: Public APIs:: createPrivateIdentifier", () => {
});
});
describe("unittests:: Public APIs:: JSDoc newlines", () => {
it("are preserved verbatim", () => {
const testFilePath = "/file.ts";
const testFileText = `
/**
* @example
* Some\n * text\r\n * with newlines.
*/
function test() {}`;
const testSourceFile = ts.createSourceFile(testFilePath, testFileText, ts.ScriptTarget.Latest, /*setParentNodes*/ true);
const funcDec = testSourceFile.statements.find(ts.isFunctionDeclaration)!;
const tags = ts.getJSDocTags(funcDec);
assert.isDefined(tags[0].comment);
assert.equal(tags[0].comment, "Some\n text\r\n with newlines.");
});
});
describe("unittests:: Public APIs:: isPropertyName", () => {
it("checks if a PrivateIdentifier is a valid property name", () => {
const prop = ts.factory.createPrivateIdentifier("#foo");
@@ -175,7 +175,7 @@ namespace ts {
return true;
}
function checkCache<T>(caption: string, program: Program, fileName: string, expectedContent: Map<string, T> | undefined, getCache: (f: SourceFile) => Map<string, T> | undefined, entryChecker: (expected: T, original: T) => boolean): void {
function checkCache<T>(caption: string, program: Program, fileName: string, expectedContent: ESMap<string, T> | undefined, getCache: (f: SourceFile) => ESMap<string, T> | undefined, entryChecker: (expected: T, original: T) => boolean): void {
const file = program.getSourceFile(fileName);
assert.isTrue(file !== undefined, `cannot find file ${fileName}`);
const cache = getCache(file!);
@@ -189,7 +189,7 @@ namespace ts {
}
/** True if the maps have the same keys and values. */
function mapsAreEqual<T>(left: Map<string, T>, right: Map<string, T>, valuesAreEqual?: (left: T, right: T) => boolean): boolean {
function mapsAreEqual<T>(left: ESMap<string, T>, right: ESMap<string, T>, valuesAreEqual?: (left: T, right: T) => boolean): boolean {
if (left === right) return true;
if (!left || !right) return false;
const someInLeftHasNoMatch = forEachEntry(left, (leftValue, leftKey) => {
@@ -202,11 +202,11 @@ namespace ts {
return !someInRightHasNoMatch;
}
function checkResolvedModulesCache(program: Program, fileName: string, expectedContent: Map<string, ResolvedModule | undefined> | undefined): void {
function checkResolvedModulesCache(program: Program, fileName: string, expectedContent: ESMap<string, ResolvedModule | undefined> | undefined): void {
checkCache("resolved modules", program, fileName, expectedContent, f => f.resolvedModules, checkResolvedModule);
}
function checkResolvedTypeDirectivesCache(program: Program, fileName: string, expectedContent: Map<string, ResolvedTypeReferenceDirective> | undefined): void {
function checkResolvedTypeDirectivesCache(program: Program, fileName: string, expectedContent: ESMap<string, ResolvedTypeReferenceDirective> | undefined): void {
checkCache("resolved type directives", program, fileName, expectedContent, f => f.resolvedTypeReferenceDirectiveNames, checkResolvedTypeDirective);
}

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