mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Merge branch 'master' into fix37113
# Conflicts: # src/compiler/transformers/module/module.ts
This commit is contained in:
@@ -19,7 +19,7 @@ jobs:
|
||||
node-version: [10.x, 12.x, 13.x]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 5
|
||||
- name: Use node version ${{ matrix.node-version }}
|
||||
@@ -45,4 +45,4 @@ jobs:
|
||||
|
||||
- name: Validate the browser can import TypeScript
|
||||
run: gulp test-browser-integration
|
||||
|
||||
|
||||
|
||||
@@ -3,6 +3,8 @@ name: Publish Nightly
|
||||
on:
|
||||
schedule:
|
||||
- cron: '0 7 * * *'
|
||||
# enable users to manually trigger with workflow_dispatch
|
||||
workflow_dispatch: {}
|
||||
repository_dispatch:
|
||||
types: publish-nightly
|
||||
|
||||
|
||||
+1
-1
@@ -63,7 +63,7 @@ TypeScript is currently accepting contributions in the form of bug fixes. A bug
|
||||
|
||||
## Contributing features
|
||||
|
||||
Features (things that add new or improved functionality to TypeScript) may be accepted, but will need to first be approved (labelled ["help wanted"](https://github.com/Microsoft/TypeScript/issues?q=is%3Aopen+is%3Aissue+label%3A%22help+wanted%22) or in the "Backlog" milestone) by a TypeScript project maintainer) in the suggestion issue. Features with language design impact, or that are adequately satisfied with external tools, will not be accepted.
|
||||
Features (things that add new or improved functionality to TypeScript) may be accepted, but will need to first be approved (labelled ["help wanted"](https://github.com/Microsoft/TypeScript/issues?q=is%3Aopen+is%3Aissue+label%3A%22help+wanted%22) or in the "Backlog" milestone) by a TypeScript project maintainer in the suggestion issue. Features with language design impact, or that are adequately satisfied with external tools, will not be accepted.
|
||||
|
||||
Design changes will not be accepted at this time. If you have a design change proposal, please log a suggestion issue.
|
||||
|
||||
|
||||
@@ -1321,4 +1321,24 @@ namespace ts {
|
||||
});
|
||||
|
||||
// #endregion Renamed node Tests
|
||||
|
||||
// DEPRECATION: Renamed `Map` and `ReadonlyMap` interfaces
|
||||
// DEPRECATION PLAN:
|
||||
// - soft: 4.0
|
||||
// - remove: TBD (will remove for at least one release before replacing with `ESMap`/`ReadonlyESMap`)
|
||||
// - replace: TBD (will eventually replace with `ESMap`/`ReadonlyESMap`)
|
||||
// #region Renamed `Map` and `ReadonlyMap` interfaces
|
||||
|
||||
/**
|
||||
* @deprecated Use `ts.ReadonlyESMap<K, V>` instead.
|
||||
*/
|
||||
export interface ReadonlyMap<T> extends ReadonlyESMap<string, T> {
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use `ts.ESMap<K, V>` instead.
|
||||
*/
|
||||
export interface Map<T> extends ESMap<string, T> { }
|
||||
|
||||
// #endregion
|
||||
}
|
||||
@@ -218,7 +218,7 @@ namespace ts {
|
||||
let symbolCount = 0;
|
||||
|
||||
let Symbol: new (flags: SymbolFlags, name: __String) => Symbol;
|
||||
let classifiableNames: UnderscoreEscapedMap<true>;
|
||||
let classifiableNames: Set<__String>;
|
||||
|
||||
const unreachableFlow: FlowNode = { flags: FlowFlags.Unreachable };
|
||||
const reportedUnreachableFlow: FlowNode = { flags: FlowFlags.Unreachable };
|
||||
@@ -237,7 +237,7 @@ namespace ts {
|
||||
options = opts;
|
||||
languageVersion = getEmitScriptTarget(options);
|
||||
inStrictMode = bindInStrictMode(file, opts);
|
||||
classifiableNames = createUnderscoreEscapedMap<true>();
|
||||
classifiableNames = new Set();
|
||||
symbolCount = 0;
|
||||
|
||||
Symbol = objectAllocator.getSymbolConstructor();
|
||||
@@ -445,7 +445,7 @@ namespace ts {
|
||||
symbol = symbolTable.get(name);
|
||||
|
||||
if (includes & SymbolFlags.Classifiable) {
|
||||
classifiableNames.set(name, true);
|
||||
classifiableNames.add(name);
|
||||
}
|
||||
|
||||
if (!symbol) {
|
||||
@@ -1965,7 +1965,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
if (inStrictMode && !isAssignmentTarget(node)) {
|
||||
const seen = createUnderscoreEscapedMap<ElementKind>();
|
||||
const seen = new Map<__String, ElementKind>();
|
||||
|
||||
for (const prop of node.properties) {
|
||||
if (prop.kind === SyntaxKind.SpreadAssignment || prop.name.kind !== SyntaxKind.Identifier) {
|
||||
@@ -2980,6 +2980,9 @@ namespace ts {
|
||||
}
|
||||
|
||||
function bindPotentiallyMissingNamespaces(namespaceSymbol: Symbol | undefined, entityName: BindableStaticNameExpression, isToplevel: boolean, isPrototypeProperty: boolean, containerIsClass: boolean) {
|
||||
if (namespaceSymbol?.flags! & SymbolFlags.Alias) {
|
||||
return namespaceSymbol;
|
||||
}
|
||||
if (isToplevel && !isPrototypeProperty) {
|
||||
// make symbols or add declarations for intermediate containers
|
||||
const flags = SymbolFlags.Module | SymbolFlags.Assignment;
|
||||
@@ -3143,7 +3146,7 @@ namespace ts {
|
||||
bindAnonymousDeclaration(node, SymbolFlags.Class, bindingName);
|
||||
// Add name of class expression into the map for semantic classifier
|
||||
if (node.name) {
|
||||
classifiableNames.set(node.name.escapedText, true);
|
||||
classifiableNames.add(node.name.escapedText);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+198
-202
File diff suppressed because it is too large
Load Diff
@@ -83,33 +83,33 @@ namespace ts {
|
||||
export const optionsForWatch: CommandLineOption[] = [
|
||||
{
|
||||
name: "watchFile",
|
||||
type: createMapFromTemplate({
|
||||
type: new Map(getEntries({
|
||||
fixedpollinginterval: WatchFileKind.FixedPollingInterval,
|
||||
prioritypollinginterval: WatchFileKind.PriorityPollingInterval,
|
||||
dynamicprioritypolling: WatchFileKind.DynamicPriorityPolling,
|
||||
usefsevents: WatchFileKind.UseFsEvents,
|
||||
usefseventsonparentdirectory: WatchFileKind.UseFsEventsOnParentDirectory,
|
||||
}),
|
||||
})),
|
||||
category: Diagnostics.Advanced_Options,
|
||||
description: Diagnostics.Specify_strategy_for_watching_file_Colon_FixedPollingInterval_default_PriorityPollingInterval_DynamicPriorityPolling_UseFsEvents_UseFsEventsOnParentDirectory,
|
||||
},
|
||||
{
|
||||
name: "watchDirectory",
|
||||
type: createMapFromTemplate({
|
||||
type: new Map(getEntries({
|
||||
usefsevents: WatchDirectoryKind.UseFsEvents,
|
||||
fixedpollinginterval: WatchDirectoryKind.FixedPollingInterval,
|
||||
dynamicprioritypolling: WatchDirectoryKind.DynamicPriorityPolling,
|
||||
}),
|
||||
})),
|
||||
category: Diagnostics.Advanced_Options,
|
||||
description: Diagnostics.Specify_strategy_for_watching_directory_on_platforms_that_don_t_support_recursive_watching_natively_Colon_UseFsEvents_default_FixedPollingInterval_DynamicPriorityPolling,
|
||||
},
|
||||
{
|
||||
name: "fallbackPolling",
|
||||
type: createMapFromTemplate({
|
||||
type: new Map(getEntries({
|
||||
fixedinterval: PollingWatchKind.FixedInterval,
|
||||
priorityinterval: PollingWatchKind.PriorityInterval,
|
||||
dynamicpriority: PollingWatchKind.DynamicPriority,
|
||||
}),
|
||||
})),
|
||||
category: Diagnostics.Advanced_Options,
|
||||
description: Diagnostics.Specify_strategy_for_creating_a_polling_watch_when_it_fails_to_create_using_file_system_events_Colon_FixedInterval_default_PriorityInterval_DynamicPriority,
|
||||
},
|
||||
@@ -286,7 +286,7 @@ namespace ts {
|
||||
{
|
||||
name: "target",
|
||||
shortName: "t",
|
||||
type: createMapFromTemplate({
|
||||
type: new Map(getEntries({
|
||||
es3: ScriptTarget.ES3,
|
||||
es5: ScriptTarget.ES5,
|
||||
es6: ScriptTarget.ES2015,
|
||||
@@ -297,7 +297,7 @@ namespace ts {
|
||||
es2019: ScriptTarget.ES2019,
|
||||
es2020: ScriptTarget.ES2020,
|
||||
esnext: ScriptTarget.ESNext,
|
||||
}),
|
||||
})),
|
||||
affectsSourceFile: true,
|
||||
affectsModuleResolution: true,
|
||||
affectsEmit: true,
|
||||
@@ -309,7 +309,7 @@ namespace ts {
|
||||
{
|
||||
name: "module",
|
||||
shortName: "m",
|
||||
type: createMapFromTemplate({
|
||||
type: new Map(getEntries({
|
||||
none: ModuleKind.None,
|
||||
commonjs: ModuleKind.CommonJS,
|
||||
amd: ModuleKind.AMD,
|
||||
@@ -319,7 +319,7 @@ namespace ts {
|
||||
es2015: ModuleKind.ES2015,
|
||||
es2020: ModuleKind.ES2020,
|
||||
esnext: ModuleKind.ESNext
|
||||
}),
|
||||
})),
|
||||
affectsModuleResolution: true,
|
||||
affectsEmit: true,
|
||||
paramType: Diagnostics.KIND,
|
||||
@@ -356,11 +356,11 @@ namespace ts {
|
||||
},
|
||||
{
|
||||
name: "jsx",
|
||||
type: createMapFromTemplate({
|
||||
type: new Map(getEntries({
|
||||
"preserve": JsxEmit.Preserve,
|
||||
"react-native": JsxEmit.ReactNative,
|
||||
"react": JsxEmit.React
|
||||
}),
|
||||
})),
|
||||
affectsSourceFile: true,
|
||||
paramType: Diagnostics.KIND,
|
||||
showInSimplifiedHelpView: true,
|
||||
@@ -476,11 +476,11 @@ namespace ts {
|
||||
},
|
||||
{
|
||||
name: "importsNotUsedAsValues",
|
||||
type: createMapFromTemplate({
|
||||
type: new Map(getEntries({
|
||||
remove: ImportsNotUsedAsValues.Remove,
|
||||
preserve: ImportsNotUsedAsValues.Preserve,
|
||||
error: ImportsNotUsedAsValues.Error
|
||||
}),
|
||||
})),
|
||||
affectsEmit: true,
|
||||
affectsSemanticDiagnostics: true,
|
||||
category: Diagnostics.Advanced_Options,
|
||||
@@ -610,10 +610,10 @@ namespace ts {
|
||||
// Module Resolution
|
||||
{
|
||||
name: "moduleResolution",
|
||||
type: createMapFromTemplate({
|
||||
type: new Map(getEntries({
|
||||
node: ModuleResolutionKind.NodeJs,
|
||||
classic: ModuleResolutionKind.Classic,
|
||||
}),
|
||||
})),
|
||||
affectsModuleResolution: true,
|
||||
paramType: Diagnostics.STRATEGY,
|
||||
category: Diagnostics.Module_Resolution_Options,
|
||||
@@ -818,10 +818,10 @@ namespace ts {
|
||||
},
|
||||
{
|
||||
name: "newLine",
|
||||
type: createMapFromTemplate({
|
||||
type: new Map(getEntries({
|
||||
crlf: NewLineKind.CarriageReturnLineFeed,
|
||||
lf: NewLineKind.LineFeed
|
||||
}),
|
||||
})),
|
||||
affectsEmit: true,
|
||||
paramType: Diagnostics.NEWLINE,
|
||||
category: Diagnostics.Advanced_Options,
|
||||
@@ -1096,8 +1096,8 @@ namespace ts {
|
||||
|
||||
/*@internal*/
|
||||
export function createOptionNameMap(optionDeclarations: readonly CommandLineOption[]): OptionsNameMap {
|
||||
const optionsNameMap = createMap<CommandLineOption>();
|
||||
const shortOptionNames = createMap<string>();
|
||||
const optionsNameMap = new Map<string, CommandLineOption>();
|
||||
const shortOptionNames = new Map<string, string>();
|
||||
forEach(optionDeclarations, option => {
|
||||
optionsNameMap.set(option.name.toLowerCase(), option);
|
||||
if (option.shortName) {
|
||||
@@ -2032,7 +2032,7 @@ namespace ts {
|
||||
{ optionsNameMap }: OptionsNameMap,
|
||||
pathOptions?: { configFilePath: string, useCaseSensitiveFileNames: boolean }
|
||||
): ESMap<string, CompilerOptionsValue> {
|
||||
const result = createMap<CompilerOptionsValue>();
|
||||
const result = new Map<string, CompilerOptionsValue>();
|
||||
const getCanonicalFileName = pathOptions && createGetCanonicalFileName(pathOptions.useCaseSensitiveFileNames);
|
||||
|
||||
for (const name in options) {
|
||||
@@ -2962,17 +2962,17 @@ namespace ts {
|
||||
// Literal file names (provided via the "files" array in tsconfig.json) are stored in a
|
||||
// file map with a possibly case insensitive key. We use this map later when when including
|
||||
// wildcard paths.
|
||||
const literalFileMap = createMap<string>();
|
||||
const literalFileMap = new Map<string, string>();
|
||||
|
||||
// Wildcard paths (provided via the "includes" array in tsconfig.json) are stored in a
|
||||
// file map with a possibly case insensitive key. We use this map to store paths matched
|
||||
// via wildcard, and to handle extension priority.
|
||||
const wildcardFileMap = createMap<string>();
|
||||
const wildcardFileMap = new Map<string, string>();
|
||||
|
||||
// Wildcard paths of json files (provided via the "includes" array in tsconfig.json) are stored in a
|
||||
// file map with a possibly case insensitive key. We use this map to store paths matched
|
||||
// via wildcard of *.json kind
|
||||
const wildCardJsonFileMap = createMap<string>();
|
||||
const wildCardJsonFileMap = new Map<string, string>();
|
||||
const { filesSpecs, validatedIncludeSpecs, validatedExcludeSpecs, wildcardDirectories } = spec;
|
||||
|
||||
// Rather than requery this for each file and filespec, we query the supported extensions
|
||||
|
||||
+48
-4
@@ -40,15 +40,23 @@ namespace ts {
|
||||
}
|
||||
|
||||
export const emptyArray: never[] = [] as never[];
|
||||
export const emptyMap: ReadonlyESMap<never, never> = new Map<never, never>();
|
||||
export const emptySet: ReadonlySet<never> = new Set<never>();
|
||||
|
||||
/** Create a new map. */
|
||||
/**
|
||||
* Create a new map.
|
||||
* @deprecated Use `new Map()` instead.
|
||||
*/
|
||||
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>();
|
||||
}
|
||||
|
||||
/** Create a new map from a template object is provided, the map will copy entries from it. */
|
||||
/**
|
||||
* 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>): ESMap<string, T> {
|
||||
const map: ESMap<string, T> = new Map<string, T>();
|
||||
|
||||
@@ -590,6 +598,15 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
export function getOrUpdate<K, V>(map: ESMap<K, V>, key: K, callback: () => V) {
|
||||
if (map.has(key)) {
|
||||
return map.get(key)!;
|
||||
}
|
||||
const value = callback();
|
||||
map.set(key, value);
|
||||
return value;
|
||||
}
|
||||
|
||||
export function tryAddToSet<T>(set: Set<T>, value: T) {
|
||||
if (!set.has(value)) {
|
||||
set.add(value);
|
||||
@@ -819,6 +836,18 @@ namespace ts {
|
||||
return deduplicateSorted(sort(array, comparer), equalityComparer || comparer || compareStringsCaseSensitive as any as Comparer<T>);
|
||||
}
|
||||
|
||||
export function arrayIsSorted<T>(array: readonly T[], comparer: Comparer<T>) {
|
||||
if (array.length < 2) return true;
|
||||
let prevElement = array[0];
|
||||
for (const element of array.slice(1)) {
|
||||
if (comparer(prevElement, element) === Comparison.GreaterThan) {
|
||||
return false;
|
||||
}
|
||||
prevElement = element;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
export function arrayIsEqualTo<T>(array1: readonly T[] | undefined, array2: readonly T[] | undefined, equalityComparer: (a: T, b: T, index: number) => boolean = equateValues): boolean {
|
||||
if (!array1 || !array2) {
|
||||
return array1 === array2;
|
||||
@@ -1275,6 +1304,19 @@ namespace ts {
|
||||
return values;
|
||||
}
|
||||
|
||||
const _entries = Object.entries ? Object.entries : <T>(obj: MapLike<T>) => {
|
||||
const keys = getOwnKeys(obj);
|
||||
const result: [string, T][] = Array(keys.length);
|
||||
for (const key of keys) {
|
||||
result.push([key, obj[key]]);
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
export function getEntries<T>(obj: MapLike<T>): [string, T][] {
|
||||
return obj ? _entries(obj) : [];
|
||||
}
|
||||
|
||||
export function arrayOf<T>(count: number, f: (index: number) => T): T[] {
|
||||
const result = new Array(count);
|
||||
for (let i = 0; i < count; i++) {
|
||||
@@ -1375,9 +1417,11 @@ namespace ts {
|
||||
return result;
|
||||
}
|
||||
|
||||
export function group<T, K>(values: readonly T[], getGroupId: (value: T) => K): readonly (readonly T[])[];
|
||||
export function group<T, K, R>(values: readonly T[], getGroupId: (value: T) => K, resultSelector: (values: readonly T[]) => R): R[];
|
||||
export function group<T>(values: readonly T[], getGroupId: (value: T) => string): readonly (readonly T[])[];
|
||||
export function group<T, R>(values: readonly T[], getGroupId: (value: T) => string, resultSelector: (values: readonly T[]) => R): R[];
|
||||
export function group<T>(values: readonly T[], getGroupId: (value: T) => string, resultSelector: (values: readonly T[]) => readonly T[] = identity): readonly (readonly T[])[] {
|
||||
export function group<T, K>(values: readonly T[], getGroupId: (value: T) => K, resultSelector: (values: readonly T[]) => readonly T[] = identity): readonly (readonly T[])[] {
|
||||
return arrayFrom(arrayToMultiMap(values, getGroupId).values(), resultSelector);
|
||||
}
|
||||
|
||||
@@ -1596,7 +1640,7 @@ namespace ts {
|
||||
|
||||
/** A version of `memoize` that supports a single primitive argument */
|
||||
export function memoizeOne<A extends string | number | boolean | undefined, T>(callback: (arg: A) => T): (arg: A) => T {
|
||||
const map = createMap<T>();
|
||||
const map = new Map<string, T>();
|
||||
return (arg: A) => {
|
||||
const key = `${typeof arg}:${arg}`;
|
||||
let value = map.get(key);
|
||||
|
||||
@@ -45,7 +45,6 @@ namespace ts {
|
||||
|
||||
/**
|
||||
* ES6 Map interface, only read methods included.
|
||||
* @deprecated Use `ts.ReadonlyESMap<K, V>` instead.
|
||||
*/
|
||||
export interface ReadonlyMap<T> extends ReadonlyESMap<string, T> {
|
||||
}
|
||||
@@ -57,7 +56,6 @@ namespace ts {
|
||||
|
||||
/**
|
||||
* ES6 Map interface.
|
||||
* @deprecated Use `ts.ESMap<K, V>` instead.
|
||||
*/
|
||||
export interface Map<T> extends ESMap<string, T> {
|
||||
}
|
||||
|
||||
@@ -682,9 +682,9 @@ namespace ts {
|
||||
|
||||
function createSourceFilesFromBundleBuildInfo(bundle: BundleBuildInfo, buildInfoDirectory: string, host: EmitUsingBuildInfoHost): readonly SourceFile[] {
|
||||
const jsBundle = Debug.checkDefined(bundle.js);
|
||||
const prologueMap = jsBundle.sources?.prologues && arrayToMap(jsBundle.sources.prologues, prologueInfo => "" + prologueInfo.file);
|
||||
const prologueMap = jsBundle.sources?.prologues && arrayToMap(jsBundle.sources.prologues, prologueInfo => prologueInfo.file);
|
||||
return bundle.sourceFiles.map((fileName, index) => {
|
||||
const prologueInfo = prologueMap?.get("" + index);
|
||||
const prologueInfo = prologueMap?.get(index);
|
||||
const statements = prologueInfo?.directives.map(directive => {
|
||||
const literal = setTextRange(factory.createStringLiteral(directive.expression.text), directive.expression);
|
||||
const statement = setTextRange(factory.createExpressionStatement(literal), directive);
|
||||
@@ -834,7 +834,7 @@ namespace ts {
|
||||
const extendedDiagnostics = !!printerOptions.extendedDiagnostics;
|
||||
const newLine = getNewLineCharacter(printerOptions);
|
||||
const moduleKind = getEmitModuleKind(printerOptions);
|
||||
const bundledHelpers = createMap<boolean>();
|
||||
const bundledHelpers = new Map<string, boolean>();
|
||||
|
||||
let currentSourceFile: SourceFile | undefined;
|
||||
let nodeIdToGeneratedName: string[]; // Map of generated names for specific nodes.
|
||||
@@ -1682,7 +1682,7 @@ namespace ts {
|
||||
if (moduleKind === ModuleKind.None || printerOptions.noEmitHelpers) {
|
||||
return undefined;
|
||||
}
|
||||
const bundledHelpers = createMap<boolean>();
|
||||
const bundledHelpers = new Map<string, boolean>();
|
||||
for (const sourceFile of bundle.sourceFiles) {
|
||||
const shouldSkip = getExternalHelpersModuleName(sourceFile) !== undefined;
|
||||
const helpers = getSortedEmitHelpers(sourceFile);
|
||||
|
||||
@@ -580,7 +580,7 @@ namespace ts {
|
||||
var extendStatics = function (d, b) {
|
||||
extendStatics = Object.setPrototypeOf ||
|
||||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
||||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
||||
return extendStatics(d, b);
|
||||
};
|
||||
|
||||
@@ -810,7 +810,7 @@ namespace ts {
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};`
|
||||
@@ -836,7 +836,7 @@ namespace ts {
|
||||
priority: 2,
|
||||
text: `
|
||||
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
||||
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
|
||||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
||||
};`
|
||||
};
|
||||
|
||||
|
||||
@@ -5654,7 +5654,7 @@ namespace ts {
|
||||
left.splice(0, 0, ...declarations.slice(0, rightStandardPrologueEnd));
|
||||
}
|
||||
else {
|
||||
const leftPrologues = createMap<boolean>();
|
||||
const leftPrologues = new Map<string, boolean>();
|
||||
for (let i = 0; i < leftStandardPrologueEnd; i++) {
|
||||
const leftPrologue = statements[i] as PrologueDirective;
|
||||
leftPrologues.set(leftPrologue.expression.text, true);
|
||||
@@ -6159,7 +6159,7 @@ namespace ts {
|
||||
): InputFiles {
|
||||
const node = parseNodeFactory.createInputFiles();
|
||||
if (!isString(javascriptTextOrReadFileText)) {
|
||||
const cache = createMap<string | false>();
|
||||
const cache = new Map<string, string | false>();
|
||||
const textGetter = (path: string | undefined) => {
|
||||
if (path === undefined) return undefined;
|
||||
let value = cache.get(path);
|
||||
|
||||
@@ -482,7 +482,7 @@ namespace ts {
|
||||
|
||||
/*@internal*/
|
||||
export function createCacheWithRedirects<T>(options?: CompilerOptions): CacheWithRedirects<T> {
|
||||
let ownMap: ESMap<string, T> = createMap();
|
||||
let ownMap: ESMap<string, T> = new Map();
|
||||
const redirectsMap = new Map<Path, ESMap<string, T>>();
|
||||
return {
|
||||
ownMap,
|
||||
@@ -509,7 +509,7 @@ namespace ts {
|
||||
let redirects = redirectsMap.get(path);
|
||||
if (!redirects) {
|
||||
// Reuse map if redirected reference map uses same resolution
|
||||
redirects = !options || optionsHaveModuleResolutionChanges(options, redirectedReference.commandLine.options) ? createMap() : ownMap;
|
||||
redirects = !options || optionsHaveModuleResolutionChanges(options, redirectedReference.commandLine.options) ? new Map() : ownMap;
|
||||
redirectsMap.set(path, redirects);
|
||||
}
|
||||
return redirects;
|
||||
@@ -532,7 +532,7 @@ namespace ts {
|
||||
|
||||
function getOrCreateCacheForDirectory(directoryName: string, redirectedReference?: ResolvedProjectReference) {
|
||||
const path = toPath(directoryName, currentDirectory, getCanonicalFileName);
|
||||
return getOrCreateCache<ESMap<string, ResolvedModuleWithFailedLookupLocations>>(directoryToModuleNameMap, redirectedReference, path, createMap);
|
||||
return getOrCreateCache<ESMap<string, ResolvedModuleWithFailedLookupLocations>>(directoryToModuleNameMap, redirectedReference, path, () => new Map());
|
||||
}
|
||||
|
||||
function getOrCreateCacheForModuleName(nonRelativeModuleName: string, redirectedReference?: ResolvedProjectReference): PerModuleNameCache {
|
||||
@@ -551,7 +551,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function createPerModuleNameCache(): PerModuleNameCache {
|
||||
const directoryPathMap = createMap<ResolvedModuleWithFailedLookupLocations>();
|
||||
const directoryPathMap = new Map<string, ResolvedModuleWithFailedLookupLocations>();
|
||||
|
||||
return { get, set };
|
||||
|
||||
|
||||
@@ -216,7 +216,7 @@ namespace ts.moduleSpecifiers {
|
||||
function getAllModulePaths(importingFileName: string, importedFileName: string, host: ModuleSpecifierResolutionHost): readonly string[] {
|
||||
const cwd = host.getCurrentDirectory();
|
||||
const getCanonicalFileName = hostGetCanonicalFileName(host);
|
||||
const allFileNames = createMap<string>();
|
||||
const allFileNames = new Map<string, string>();
|
||||
let importedFileFromNodeModules = false;
|
||||
forEachFileNameOfModule(
|
||||
importingFileName,
|
||||
|
||||
@@ -820,7 +820,7 @@ namespace ts {
|
||||
result.libReferenceDirectives = emptyArray;
|
||||
result.amdDependencies = emptyArray;
|
||||
result.hasNoDefaultLib = false;
|
||||
result.pragmas = emptyMap;
|
||||
result.pragmas = emptyMap as ReadonlyPragmaMap;
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -929,8 +929,8 @@ namespace ts {
|
||||
|
||||
parseDiagnostics = [];
|
||||
parsingContext = 0;
|
||||
identifiers = createMap<string>();
|
||||
privateIdentifiers = createMap<string>();
|
||||
identifiers = new Map<string, string>();
|
||||
privateIdentifiers = new Map<string, string>();
|
||||
identifierCount = 0;
|
||||
nodeCount = 0;
|
||||
sourceFlags = 0;
|
||||
@@ -8669,7 +8669,7 @@ namespace ts {
|
||||
extractPragmas(pragmas, range, comment);
|
||||
}
|
||||
|
||||
context.pragmas = createMap() as PragmaMap;
|
||||
context.pragmas = new Map() as PragmaMap;
|
||||
for (const pragma of pragmas) {
|
||||
if (context.pragmas.has(pragma.name)) {
|
||||
const currentValue = context.pragmas.get(pragma.name);
|
||||
@@ -8767,7 +8767,7 @@ namespace ts {
|
||||
});
|
||||
}
|
||||
|
||||
const namedArgRegExCache = createMap<RegExp>();
|
||||
const namedArgRegExCache = new Map<string, RegExp>();
|
||||
function getNamedArgRegEx(name: string): RegExp {
|
||||
if (namedArgRegExCache.has(name)) {
|
||||
return namedArgRegExCache.get(name)!;
|
||||
|
||||
@@ -108,9 +108,9 @@ namespace ts.performance {
|
||||
|
||||
/** Enables (and resets) performance measurements for the compiler. */
|
||||
export function enable() {
|
||||
counts = createMap<number>();
|
||||
marks = createMap<number>();
|
||||
measures = createMap<number>();
|
||||
counts = new Map<string, number>();
|
||||
marks = new Map<string, number>();
|
||||
measures = new Map<string, number>();
|
||||
enabled = true;
|
||||
profilerStart = timestamp();
|
||||
}
|
||||
|
||||
+21
-23
@@ -71,7 +71,7 @@ namespace ts {
|
||||
/*@internal*/
|
||||
// TODO(shkamat): update this after reworking ts build API
|
||||
export function createCompilerHostWorker(options: CompilerOptions, setParentNodes?: boolean, system = sys): CompilerHost {
|
||||
const existingDirectories = createMap<boolean>();
|
||||
const existingDirectories = new Map<string, boolean>();
|
||||
const getCanonicalFileName = createGetCanonicalFileName(system.useCaseSensitiveFileNames);
|
||||
function getSourceFile(fileName: string, languageVersion: ScriptTarget, onError?: (message: string) => void): SourceFile | undefined {
|
||||
let text: string | undefined;
|
||||
@@ -134,7 +134,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
if (!outputFingerprints) {
|
||||
outputFingerprints = createMap<OutputFingerprint>();
|
||||
outputFingerprints = new Map<string, OutputFingerprint>();
|
||||
}
|
||||
|
||||
const hash = system.createHash(data);
|
||||
@@ -211,10 +211,10 @@ namespace ts {
|
||||
const originalDirectoryExists = host.directoryExists;
|
||||
const originalCreateDirectory = host.createDirectory;
|
||||
const originalWriteFile = host.writeFile;
|
||||
const readFileCache = createMap<string | false>();
|
||||
const fileExistsCache = createMap<boolean>();
|
||||
const directoryExistsCache = createMap<boolean>();
|
||||
const sourceFileCache = createMap<SourceFile>();
|
||||
const readFileCache = new Map<string, string | false>();
|
||||
const fileExistsCache = new Map<string, boolean>();
|
||||
const directoryExistsCache = new Map<string, boolean>();
|
||||
const sourceFileCache = new Map<string, SourceFile>();
|
||||
|
||||
const readFileWithCache = (fileName: string): string | undefined => {
|
||||
const key = toPath(fileName);
|
||||
@@ -515,7 +515,7 @@ namespace ts {
|
||||
return [];
|
||||
}
|
||||
const resolutions: T[] = [];
|
||||
const cache = createMap<T>();
|
||||
const cache = new Map<string, T>();
|
||||
for (const name of names) {
|
||||
let result: T;
|
||||
if (cache.has(name)) {
|
||||
@@ -706,15 +706,15 @@ namespace ts {
|
||||
let commonSourceDirectory: string;
|
||||
let diagnosticsProducingTypeChecker: TypeChecker;
|
||||
let noDiagnosticsTypeChecker: TypeChecker;
|
||||
let classifiableNames: UnderscoreEscapedMap<true>;
|
||||
const ambientModuleNameToUnmodifiedFileName = createMap<string>();
|
||||
let classifiableNames: Set<__String>;
|
||||
const ambientModuleNameToUnmodifiedFileName = new Map<string, string>();
|
||||
// Todo:: Use this to report why file was included in --extendedDiagnostics
|
||||
let refFileMap: MultiMap<Path, ts.RefFile> | undefined;
|
||||
|
||||
const cachedBindAndCheckDiagnosticsForFile: DiagnosticCache<Diagnostic> = {};
|
||||
const cachedDeclarationDiagnosticsForFile: DiagnosticCache<DiagnosticWithLocation> = {};
|
||||
|
||||
let resolvedTypeReferenceDirectives = createMap<ResolvedTypeReferenceDirective | undefined>();
|
||||
let resolvedTypeReferenceDirectives = new Map<string, ResolvedTypeReferenceDirective | undefined>();
|
||||
let fileProcessingDiagnostics = createDiagnosticCollection();
|
||||
|
||||
// The below settings are to track if a .js file should be add to the program if loaded via searching under node_modules.
|
||||
@@ -729,10 +729,10 @@ namespace ts {
|
||||
|
||||
// If a module has some of its imports skipped due to being at the depth limit under node_modules, then track
|
||||
// this, as it may be imported at a shallower depth later, and then it will need its skipped imports processed.
|
||||
const modulesWithElidedImports = createMap<boolean>();
|
||||
const modulesWithElidedImports = new Map<string, boolean>();
|
||||
|
||||
// Track source files that are source files found by searching under node_modules, as these shouldn't be compiled.
|
||||
const sourceFilesFoundSearchingNodeModules = createMap<boolean>();
|
||||
const sourceFilesFoundSearchingNodeModules = new Map<string, boolean>();
|
||||
|
||||
performance.mark("beforeProgram");
|
||||
|
||||
@@ -748,7 +748,7 @@ namespace ts {
|
||||
const supportedExtensionsWithJsonIfResolveJsonModule = getSuppoertedExtensionsWithJsonIfResolveJsonModule(options, supportedExtensions);
|
||||
|
||||
// Map storing if there is emit blocking diagnostics for given input
|
||||
const hasEmitBlockingDiagnostics = createMap<boolean>();
|
||||
const hasEmitBlockingDiagnostics = new Map<string, boolean>();
|
||||
let _compilerOptionsObjectLiteralSyntax: ObjectLiteralExpression | null | undefined;
|
||||
|
||||
let moduleResolutionCache: ModuleResolutionCache | undefined;
|
||||
@@ -783,9 +783,9 @@ namespace ts {
|
||||
// Map from a stringified PackageId to the source file with that id.
|
||||
// Only one source file may have a given packageId. Others become redirects (see createRedirectSourceFile).
|
||||
// `packageIdToSourceFile` is only used while building the program, while `sourceFileToPackageName` and `isSourceFileTargetOfRedirect` are kept around.
|
||||
const packageIdToSourceFile = createMap<SourceFile>();
|
||||
const packageIdToSourceFile = new Map<string, SourceFile>();
|
||||
// Maps from a SourceFile's `.path` to the name of the package it was imported with.
|
||||
let sourceFileToPackageName = createMap<string>();
|
||||
let sourceFileToPackageName = new Map<string, string>();
|
||||
// Key is a file name. Value is the (non-empty, or undefined) list of files that redirect to it.
|
||||
let redirectTargetsMap = createMultiMap<string>();
|
||||
|
||||
@@ -795,11 +795,11 @@ namespace ts {
|
||||
* - false if sourceFile missing for source of project reference redirect
|
||||
* - undefined otherwise
|
||||
*/
|
||||
const filesByName = createMap<SourceFile | false | undefined>();
|
||||
const filesByName = new Map<string, SourceFile | false | undefined>();
|
||||
let missingFilePaths: readonly Path[] | undefined;
|
||||
// stores 'filename -> file association' ignoring case
|
||||
// used to track cases when two file names differ only in casing
|
||||
const filesByNameIgnoreCase = host.useCaseSensitiveFileNames() ? createMap<SourceFile>() : undefined;
|
||||
const filesByNameIgnoreCase = host.useCaseSensitiveFileNames() ? new Map<string, SourceFile>() : undefined;
|
||||
|
||||
// A parallel array to projectReferences storing the results of reading in the referenced tsconfig files
|
||||
let resolvedProjectReferences: readonly (ResolvedProjectReference | undefined)[] | undefined;
|
||||
@@ -1051,10 +1051,10 @@ namespace ts {
|
||||
if (!classifiableNames) {
|
||||
// Initialize a checker so that all our files are bound.
|
||||
getTypeChecker();
|
||||
classifiableNames = createUnderscoreEscapedMap<true>();
|
||||
classifiableNames = new Set();
|
||||
|
||||
for (const sourceFile of files) {
|
||||
copyEntries(sourceFile.classifiableNames!, classifiableNames);
|
||||
sourceFile.classifiableNames?.forEach(value => classifiableNames.add(value));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1236,8 +1236,6 @@ namespace ts {
|
||||
return oldProgram.structureIsReused = StructureIsReused.Not;
|
||||
}
|
||||
|
||||
Debug.assert(!(oldProgram.structureIsReused! & (StructureIsReused.Completely | StructureIsReused.SafeModules)));
|
||||
|
||||
// there is an old program, check if we can reuse its structure
|
||||
const oldRootNames = oldProgram.getRootFileNames();
|
||||
if (!arrayIsEqualTo(oldRootNames, rootNames)) {
|
||||
@@ -1270,7 +1268,7 @@ namespace ts {
|
||||
|
||||
const oldSourceFiles = oldProgram.getSourceFiles();
|
||||
const enum SeenPackageName { Exists, Modified }
|
||||
const seenPackageNames = createMap<SeenPackageName>();
|
||||
const seenPackageNames = new Map<string, SeenPackageName>();
|
||||
|
||||
for (const oldSourceFile of oldSourceFiles) {
|
||||
let newSourceFile = host.getSourceFileByPath
|
||||
@@ -2571,7 +2569,7 @@ namespace ts {
|
||||
function getSourceOfProjectReferenceRedirect(file: string) {
|
||||
if (!isDeclarationFileName(file)) return undefined;
|
||||
if (mapFromToProjectReferenceRedirectSource === undefined) {
|
||||
mapFromToProjectReferenceRedirectSource = createMap();
|
||||
mapFromToProjectReferenceRedirectSource = new Map();
|
||||
forEachResolvedProjectReference(resolvedRef => {
|
||||
if (resolvedRef) {
|
||||
const out = outFile(resolvedRef.commandLine.options);
|
||||
|
||||
@@ -181,15 +181,15 @@ namespace ts {
|
||||
* Note that .d.ts file also has .d.ts extension hence will be part of default extensions
|
||||
*/
|
||||
const failedLookupDefaultExtensions = [Extension.Ts, Extension.Tsx, Extension.Js, Extension.Jsx, Extension.Json];
|
||||
const customFailedLookupPaths = createMap<number>();
|
||||
const customFailedLookupPaths = new Map<string, number>();
|
||||
|
||||
const directoryWatchesOfFailedLookups = createMap<DirectoryWatchesOfFailedLookup>();
|
||||
const directoryWatchesOfFailedLookups = new Map<string, DirectoryWatchesOfFailedLookup>();
|
||||
const rootDir = rootDirForResolution && removeTrailingDirectorySeparator(getNormalizedAbsolutePath(rootDirForResolution, getCurrentDirectory()));
|
||||
const rootPath = (rootDir && resolutionHost.toPath(rootDir)) as Path; // TODO: GH#18217
|
||||
const rootSplitLength = rootPath !== undefined ? rootPath.split(directorySeparator).length : 0;
|
||||
|
||||
// TypeRoot watches for the types that get added as part of getAutomaticTypeDirectiveNames
|
||||
const typeRootsWatches = createMap<FileWatcher>();
|
||||
const typeRootsWatches = new Map<string, FileWatcher>();
|
||||
|
||||
return {
|
||||
startRecordingFilesWithChangedResolutions,
|
||||
@@ -349,12 +349,12 @@ namespace ts {
|
||||
shouldRetryResolution, reusedNames, logChanges
|
||||
}: ResolveNamesWithLocalCacheInput<T, R>): (R | undefined)[] {
|
||||
const path = resolutionHost.toPath(containingFile);
|
||||
const resolutionsInFile = cache.get(path) || cache.set(path, createMap()).get(path)!;
|
||||
const resolutionsInFile = cache.get(path) || cache.set(path, new Map()).get(path)!;
|
||||
const dirPath = getDirectoryPath(path);
|
||||
const perDirectoryCache = perDirectoryCacheWithRedirects.getOrCreateMapOfCacheRedirects(redirectedReference);
|
||||
let perDirectoryResolution = perDirectoryCache.get(dirPath);
|
||||
if (!perDirectoryResolution) {
|
||||
perDirectoryResolution = createMap();
|
||||
perDirectoryResolution = new Map();
|
||||
perDirectoryCache.set(dirPath, perDirectoryResolution);
|
||||
}
|
||||
const resolvedModules: (R | undefined)[] = [];
|
||||
@@ -368,7 +368,7 @@ namespace ts {
|
||||
!redirectedReference || redirectedReference.sourceFile.path !== oldRedirect.sourceFile.path :
|
||||
!!redirectedReference;
|
||||
|
||||
const seenNamesInFile = createMap<true>();
|
||||
const seenNamesInFile = new Map<string, true>();
|
||||
for (const name of names) {
|
||||
let resolution = resolutionsInFile.get(name);
|
||||
// Resolution is valid if it is present and not invalidated
|
||||
|
||||
@@ -154,9 +154,9 @@ namespace ts {
|
||||
of: SyntaxKind.OfKeyword,
|
||||
};
|
||||
|
||||
const textToKeyword = createMapFromTemplate(textToKeywordObj);
|
||||
const textToKeyword = new Map(getEntries(textToKeywordObj));
|
||||
|
||||
const textToToken = createMapFromTemplate<SyntaxKind>({
|
||||
const textToToken = new Map(getEntries({
|
||||
...textToKeywordObj,
|
||||
"{": SyntaxKind.OpenBraceToken,
|
||||
"}": SyntaxKind.CloseBraceToken,
|
||||
@@ -218,7 +218,7 @@ namespace ts {
|
||||
"??=": SyntaxKind.QuestionQuestionEqualsToken,
|
||||
"@": SyntaxKind.AtToken,
|
||||
"`": SyntaxKind.BacktickToken
|
||||
});
|
||||
}));
|
||||
|
||||
/*
|
||||
As per ECMAScript Language Specification 3th Edition, Section 7.6: Identifiers
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace ts {
|
||||
// Current source map file and its index in the sources list
|
||||
const rawSources: string[] = [];
|
||||
const sources: string[] = [];
|
||||
const sourceToSourceIndexMap = createMap<number>();
|
||||
const sourceToSourceIndexMap = new Map<string, number>();
|
||||
let sourcesContent: (string | null)[] | undefined;
|
||||
|
||||
const names: string[] = [];
|
||||
@@ -84,7 +84,7 @@ namespace ts {
|
||||
|
||||
function addName(name: string) {
|
||||
enter();
|
||||
if (!nameToNameIndexMap) nameToNameIndexMap = createMap();
|
||||
if (!nameToNameIndexMap) nameToNameIndexMap = new Map();
|
||||
let nameIndex = nameToNameIndexMap.get(name);
|
||||
if (nameIndex === undefined) {
|
||||
nameIndex = names.length;
|
||||
|
||||
@@ -890,7 +890,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function getPrivateIdentifierEnvironment() {
|
||||
return currentPrivateIdentifierEnvironment || (currentPrivateIdentifierEnvironment = createUnderscoreEscapedMap());
|
||||
return currentPrivateIdentifierEnvironment || (currentPrivateIdentifierEnvironment = new Map());
|
||||
}
|
||||
|
||||
function getPendingExpressions() {
|
||||
|
||||
@@ -60,7 +60,7 @@ namespace ts {
|
||||
let enclosingDeclaration: Node;
|
||||
let necessaryTypeReferences: Set<string> | undefined;
|
||||
let lateMarkedStatements: LateVisibilityPaintedStatement[] | undefined;
|
||||
let lateStatementReplacementMap: ESMap<string, VisitResult<LateVisibilityPaintedStatement | ExportAssignment>>;
|
||||
let lateStatementReplacementMap: ESMap<NodeId, VisitResult<LateVisibilityPaintedStatement | ExportAssignment>>;
|
||||
let suppressNewDiagnosticContexts: boolean;
|
||||
let exportedModulesFromDeclarationEmit: Symbol[] | undefined;
|
||||
|
||||
@@ -81,7 +81,7 @@ namespace ts {
|
||||
let errorNameNode: DeclarationName | undefined;
|
||||
|
||||
let currentSourceFile: SourceFile;
|
||||
let refs: ESMap<string, SourceFile>;
|
||||
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();
|
||||
@@ -107,7 +107,7 @@ namespace ts {
|
||||
}
|
||||
// Otherwise we should emit a path-based reference
|
||||
const container = getSourceFileOfNode(node);
|
||||
refs.set("" + getOriginalNodeId(container), container);
|
||||
refs.set(getOriginalNodeId(container), container);
|
||||
}
|
||||
|
||||
function handleSymbolAccessibilityError(symbolAccessibilityResult: SymbolAccessibilityResult) {
|
||||
@@ -231,8 +231,8 @@ namespace ts {
|
||||
|
||||
if (node.kind === SyntaxKind.Bundle) {
|
||||
isBundledEmit = true;
|
||||
refs = createMap<SourceFile>();
|
||||
libs = createMap<boolean>();
|
||||
refs = new Map();
|
||||
libs = new Map();
|
||||
let hasNoDefaultLib = false;
|
||||
const bundle = factory.createBundle(map(node.sourceFiles,
|
||||
sourceFile => {
|
||||
@@ -242,7 +242,7 @@ namespace ts {
|
||||
enclosingDeclaration = sourceFile;
|
||||
lateMarkedStatements = undefined;
|
||||
suppressNewDiagnosticContexts = false;
|
||||
lateStatementReplacementMap = createMap();
|
||||
lateStatementReplacementMap = new Map();
|
||||
getSymbolAccessibilityDiagnostic = throwDiagnostic;
|
||||
needsScopeFixMarker = false;
|
||||
resultHasScopeMarker = false;
|
||||
@@ -296,10 +296,10 @@ namespace ts {
|
||||
resultHasExternalModuleIndicator = false;
|
||||
suppressNewDiagnosticContexts = false;
|
||||
lateMarkedStatements = undefined;
|
||||
lateStatementReplacementMap = createMap();
|
||||
lateStatementReplacementMap = new Map();
|
||||
necessaryTypeReferences = undefined;
|
||||
refs = collectReferences(currentSourceFile, createMap());
|
||||
libs = collectLibs(currentSourceFile, createMap());
|
||||
refs = collectReferences(currentSourceFile, new Map());
|
||||
libs = collectLibs(currentSourceFile, new Map());
|
||||
const references: FileReference[] = [];
|
||||
const outputFilePath = getDirectoryPath(normalizeSlashes(getOutputPathsFor(node, host, /*forceDtsPaths*/ true).declarationFilePath!));
|
||||
const referenceVisitor = mapReferencesIntoArray(references, outputFilePath);
|
||||
@@ -402,12 +402,12 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function collectReferences(sourceFile: SourceFile | UnparsedSource, ret: ESMap<string, 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);
|
||||
if (elem) {
|
||||
ret.set("" + getOriginalNodeId(elem), elem);
|
||||
ret.set(getOriginalNodeId(elem), elem);
|
||||
}
|
||||
});
|
||||
return ret;
|
||||
@@ -772,7 +772,7 @@ namespace ts {
|
||||
needsDeclare = i.parent && isSourceFile(i.parent) && !(isExternalModule(i.parent) && isBundledEmit);
|
||||
const result = transformTopLevelDeclaration(i);
|
||||
needsDeclare = priorNeedsDeclare;
|
||||
lateStatementReplacementMap.set("" + getOriginalNodeId(i), result);
|
||||
lateStatementReplacementMap.set(getOriginalNodeId(i), result);
|
||||
}
|
||||
|
||||
// And lastly, we need to get the final form of all those indetermine import declarations from before and add them to the output list
|
||||
@@ -781,7 +781,7 @@ namespace ts {
|
||||
|
||||
function visitLateVisibilityMarkedStatements(statement: Statement) {
|
||||
if (isLateVisibilityPaintedStatement(statement)) {
|
||||
const key = "" + getOriginalNodeId(statement);
|
||||
const key = getOriginalNodeId(statement);
|
||||
if (lateStatementReplacementMap.has(key)) {
|
||||
const result = lateStatementReplacementMap.get(key);
|
||||
lateStatementReplacementMap.delete(key);
|
||||
@@ -1103,7 +1103,7 @@ namespace ts {
|
||||
|
||||
const result = transformTopLevelDeclaration(input);
|
||||
// Don't actually transform yet; just leave as original node - will be elided/swapped by late pass
|
||||
lateStatementReplacementMap.set("" + getOriginalNodeId(input), result);
|
||||
lateStatementReplacementMap.set(getOriginalNodeId(input), result);
|
||||
return input;
|
||||
}
|
||||
|
||||
@@ -1305,7 +1305,7 @@ namespace ts {
|
||||
needsDeclare = false;
|
||||
visitNode(inner, visitDeclarationStatements);
|
||||
// eagerly transform nested namespaces (the nesting doesn't need any elision or painting done)
|
||||
const id = "" + getOriginalNodeId(inner!); // TODO: GH#18217
|
||||
const id = getOriginalNodeId(inner!); // TODO: GH#18217
|
||||
const body = lateStatementReplacementMap.get(id);
|
||||
lateStatementReplacementMap.delete(id);
|
||||
return cleanup(factory.updateModuleDeclaration(
|
||||
|
||||
@@ -2242,7 +2242,7 @@ namespace ts {
|
||||
|
||||
function visitLabeledStatement(node: LabeledStatement): VisitResult<Statement> {
|
||||
if (convertedLoopState && !convertedLoopState.labels) {
|
||||
convertedLoopState.labels = createMap<boolean>();
|
||||
convertedLoopState.labels = new Map<string, boolean>();
|
||||
}
|
||||
const statement = unwrapInnermostStatementOfLabel(node, convertedLoopState && recordLabel);
|
||||
return isIterationStatement(statement, /*lookInLabeledStatements*/ false)
|
||||
@@ -3279,13 +3279,13 @@ namespace ts {
|
||||
function setLabeledJump(state: ConvertedLoopState, isBreak: boolean, labelText: string, labelMarker: string): void {
|
||||
if (isBreak) {
|
||||
if (!state.labeledNonLocalBreaks) {
|
||||
state.labeledNonLocalBreaks = createMap<string>();
|
||||
state.labeledNonLocalBreaks = new Map<string, string>();
|
||||
}
|
||||
state.labeledNonLocalBreaks.set(labelText, labelMarker);
|
||||
}
|
||||
else {
|
||||
if (!state.labeledNonLocalContinues) {
|
||||
state.labeledNonLocalContinues = createMap<string>();
|
||||
state.labeledNonLocalContinues = new Map<string, string>();
|
||||
}
|
||||
state.labeledNonLocalContinues.set(labelText, labelMarker);
|
||||
}
|
||||
|
||||
@@ -37,12 +37,12 @@ namespace ts {
|
||||
*/
|
||||
let enclosingSuperContainerFlags: NodeCheckFlags = 0;
|
||||
|
||||
let enclosingFunctionParameterNames: UnderscoreEscapedMap<true>;
|
||||
let enclosingFunctionParameterNames: Set<__String>;
|
||||
|
||||
/**
|
||||
* Keeps track of property names accessed on super (`super.x`) within async functions.
|
||||
*/
|
||||
let capturedSuperProperties: UnderscoreEscapedMap<true>;
|
||||
let capturedSuperProperties: Set<__String>;
|
||||
/** Whether the async function contains an element access on super (`super[x]`). */
|
||||
let hasSuperElementAccess: boolean;
|
||||
/** A set of node IDs for generated super accessors (variable statements). */
|
||||
@@ -129,7 +129,7 @@ namespace ts {
|
||||
|
||||
case SyntaxKind.PropertyAccessExpression:
|
||||
if (capturedSuperProperties && isPropertyAccessExpression(node) && node.expression.kind === SyntaxKind.SuperKeyword) {
|
||||
capturedSuperProperties.set(node.name.escapedText, true);
|
||||
capturedSuperProperties.add(node.name.escapedText);
|
||||
}
|
||||
return visitEachChild(node, visitor, context);
|
||||
|
||||
@@ -184,15 +184,15 @@ namespace ts {
|
||||
}
|
||||
|
||||
function visitCatchClauseInAsyncBody(node: CatchClause) {
|
||||
const catchClauseNames = createUnderscoreEscapedMap<true>();
|
||||
const catchClauseNames = new Set<__String>();
|
||||
recordDeclarationName(node.variableDeclaration!, catchClauseNames); // TODO: GH#18217
|
||||
|
||||
// names declared in a catch variable are block scoped
|
||||
let catchClauseUnshadowedNames: UnderscoreEscapedMap<true> | undefined;
|
||||
let catchClauseUnshadowedNames: Set<__String> | undefined;
|
||||
catchClauseNames.forEach((_, escapedName) => {
|
||||
if (enclosingFunctionParameterNames.has(escapedName)) {
|
||||
if (!catchClauseUnshadowedNames) {
|
||||
catchClauseUnshadowedNames = cloneMap(enclosingFunctionParameterNames);
|
||||
catchClauseUnshadowedNames = new Set(enclosingFunctionParameterNames);
|
||||
}
|
||||
catchClauseUnshadowedNames.delete(escapedName);
|
||||
}
|
||||
@@ -372,9 +372,9 @@ namespace ts {
|
||||
);
|
||||
}
|
||||
|
||||
function recordDeclarationName({ name }: ParameterDeclaration | VariableDeclaration | BindingElement, names: UnderscoreEscapedMap<true>) {
|
||||
function recordDeclarationName({ name }: ParameterDeclaration | VariableDeclaration | BindingElement, names: Set<__String>) {
|
||||
if (isIdentifier(name)) {
|
||||
names.set(name.escapedText, true);
|
||||
names.add(name.escapedText);
|
||||
}
|
||||
else {
|
||||
for (const element of name.elements) {
|
||||
@@ -466,7 +466,7 @@ namespace ts {
|
||||
// promise constructor.
|
||||
|
||||
const savedEnclosingFunctionParameterNames = enclosingFunctionParameterNames;
|
||||
enclosingFunctionParameterNames = createUnderscoreEscapedMap<true>();
|
||||
enclosingFunctionParameterNames = new Set();
|
||||
for (const parameter of node.parameters) {
|
||||
recordDeclarationName(parameter, enclosingFunctionParameterNames);
|
||||
}
|
||||
@@ -474,7 +474,7 @@ namespace ts {
|
||||
const savedCapturedSuperProperties = capturedSuperProperties;
|
||||
const savedHasSuperElementAccess = hasSuperElementAccess;
|
||||
if (!isArrowFunction) {
|
||||
capturedSuperProperties = createUnderscoreEscapedMap<true>();
|
||||
capturedSuperProperties = new Set();
|
||||
hasSuperElementAccess = false;
|
||||
}
|
||||
|
||||
@@ -501,7 +501,7 @@ namespace ts {
|
||||
|
||||
if (emitSuperHelpers) {
|
||||
enableSubstitutionForAsyncMethodsWithSuper();
|
||||
if (hasEntries(capturedSuperProperties)) {
|
||||
if (capturedSuperProperties.size) {
|
||||
const variableStatement = createSuperAccessVariableStatement(factory, resolver, node, capturedSuperProperties);
|
||||
substitutedSuperAccessors[getNodeId(variableStatement)] = true;
|
||||
insertStatementsAfterStandardPrologue(statements, [variableStatement]);
|
||||
@@ -727,7 +727,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
/** Creates a variable named `_super` with accessor properties for the given property names. */
|
||||
export function createSuperAccessVariableStatement(factory: NodeFactory, resolver: EmitResolver, node: FunctionLikeDeclaration, names: UnderscoreEscapedMap<true>) {
|
||||
export function createSuperAccessVariableStatement(factory: NodeFactory, resolver: EmitResolver, node: FunctionLikeDeclaration, names: Set<__String>) {
|
||||
// Create a variable declaration with a getter/setter (if binding) definition for each name:
|
||||
// const _super = Object.create(null, { x: { get: () => super.x, set: (v) => super.x = v }, ... });
|
||||
const hasBinding = (resolver.getNodeCheckFlags(node) & NodeCheckFlags.AsyncMethodWithSuperBinding) !== 0;
|
||||
|
||||
@@ -66,7 +66,7 @@ namespace ts {
|
||||
let taggedTemplateStringDeclarations: VariableDeclaration[];
|
||||
|
||||
/** Keeps track of property names accessed on super (`super.x`) within async functions. */
|
||||
let capturedSuperProperties: UnderscoreEscapedMap<true>;
|
||||
let capturedSuperProperties: Set<__String>;
|
||||
/** Whether the async function contains an element access on super (`super[x]`). */
|
||||
let hasSuperElementAccess: boolean;
|
||||
/** A set of node IDs for generated super accessors. */
|
||||
@@ -240,7 +240,7 @@ namespace ts {
|
||||
return visitTaggedTemplateExpression(node as TaggedTemplateExpression);
|
||||
case SyntaxKind.PropertyAccessExpression:
|
||||
if (capturedSuperProperties && isPropertyAccessExpression(node) && node.expression.kind === SyntaxKind.SuperKeyword) {
|
||||
capturedSuperProperties.set(node.name.escapedText, true);
|
||||
capturedSuperProperties.add(node.name.escapedText);
|
||||
}
|
||||
return visitEachChild(node, visitor, context);
|
||||
case SyntaxKind.ElementAccessExpression:
|
||||
@@ -911,7 +911,7 @@ namespace ts {
|
||||
|
||||
const savedCapturedSuperProperties = capturedSuperProperties;
|
||||
const savedHasSuperElementAccess = hasSuperElementAccess;
|
||||
capturedSuperProperties = createUnderscoreEscapedMap<true>();
|
||||
capturedSuperProperties = new Set();
|
||||
hasSuperElementAccess = false;
|
||||
|
||||
const returnStatement = factory.createReturnStatement(
|
||||
|
||||
@@ -2111,7 +2111,7 @@ namespace ts {
|
||||
const text = idText(<Identifier>variable.name);
|
||||
name = declareLocal(text);
|
||||
if (!renamedCatchVariables) {
|
||||
renamedCatchVariables = createMap<boolean>();
|
||||
renamedCatchVariables = new Map<string, boolean>();
|
||||
renamedCatchVariableDeclarations = [];
|
||||
context.enableSubstitution(SyntaxKind.Identifier);
|
||||
}
|
||||
|
||||
@@ -315,7 +315,7 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
const entities = createMapFromTemplate<number>({
|
||||
const entities = new Map(getEntries({
|
||||
quot: 0x0022,
|
||||
amp: 0x0026,
|
||||
apos: 0x0027,
|
||||
@@ -569,5 +569,5 @@ namespace ts {
|
||||
clubs: 0x2663,
|
||||
hearts: 0x2665,
|
||||
diams: 0x2666
|
||||
});
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -124,7 +124,7 @@ namespace ts {
|
||||
function onEmitNode(hint: EmitHint, node: Node, emitCallback: (hint: EmitHint, node: Node) => void): void {
|
||||
if (isSourceFile(node)) {
|
||||
if ((isExternalModule(node) || compilerOptions.isolatedModules) && compilerOptions.importHelpers) {
|
||||
helperNameSubstitutions = createMap<Identifier>();
|
||||
helperNameSubstitutions = new Map<string, Identifier>();
|
||||
}
|
||||
previousOnEmitNode(hint, node, emitCallback);
|
||||
helperNameSubstitutions = undefined;
|
||||
|
||||
@@ -144,7 +144,7 @@ namespace ts {
|
||||
* @param externalImports The imports for the file.
|
||||
*/
|
||||
function collectDependencyGroups(externalImports: (ImportDeclaration | ImportEqualsDeclaration | ExportDeclaration)[]) {
|
||||
const groupIndices = createMap<number>();
|
||||
const groupIndices = new Map<string, number>();
|
||||
const dependencyGroups: DependencyGroup[] = [];
|
||||
for (const externalImport of externalImports) {
|
||||
const externalModuleName = getExternalModuleNameLiteral(factory, externalImport, currentSourceFile, host, resolver, compilerOptions);
|
||||
|
||||
@@ -1531,6 +1531,7 @@ namespace ts {
|
||||
case SyntaxKind.LiteralType:
|
||||
switch ((<LiteralTypeNode>node).literal.kind) {
|
||||
case SyntaxKind.StringLiteral:
|
||||
case SyntaxKind.NoSubstitutionTemplateLiteral:
|
||||
return factory.createIdentifier("String");
|
||||
|
||||
case SyntaxKind.PrefixUnaryExpression:
|
||||
@@ -2528,7 +2529,7 @@ namespace ts {
|
||||
*/
|
||||
function recordEmittedDeclarationInScope(node: FunctionDeclaration | ClassDeclaration | ModuleDeclaration | EnumDeclaration) {
|
||||
if (!currentScopeFirstDeclarationsOfName) {
|
||||
currentScopeFirstDeclarationsOfName = createUnderscoreEscapedMap<Node>();
|
||||
currentScopeFirstDeclarationsOfName = new Map();
|
||||
}
|
||||
|
||||
const name = declaredNameInScope(node);
|
||||
|
||||
@@ -69,7 +69,7 @@ namespace ts {
|
||||
const externalImports: (ImportDeclaration | ImportEqualsDeclaration | ExportDeclaration)[] = [];
|
||||
const exportSpecifiers = createMultiMap<ExportSpecifier>();
|
||||
const exportedBindings: Identifier[][] = [];
|
||||
const uniqueExports = createMap<boolean>();
|
||||
const uniqueExports = new Map<string, boolean>();
|
||||
let exportedNames: Identifier[] | undefined;
|
||||
let hasExportDefault = false;
|
||||
let exportEquals: ExportAssignment | undefined;
|
||||
|
||||
@@ -63,7 +63,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function getOrCreateValueMapFromConfigFileMap<T>(configFileMap: ESMap<ResolvedConfigFilePath, ESMap<string, T>>, resolved: ResolvedConfigFilePath): ESMap<string, T> {
|
||||
return getOrCreateValueFromConfigFileMap<ESMap<string, T>>(configFileMap, resolved, createMap);
|
||||
return getOrCreateValueFromConfigFileMap<ESMap<string, T>>(configFileMap, resolved, () => new Map());
|
||||
}
|
||||
|
||||
function newer(date1: Date, date2: Date): Date {
|
||||
@@ -439,10 +439,12 @@ namespace ts {
|
||||
|
||||
// Clear all to ResolvedConfigFilePaths cache to start fresh
|
||||
state.resolvedConfigFilePaths.clear();
|
||||
const currentProjects = arrayToSet(
|
||||
getBuildOrderFromAnyBuildOrder(buildOrder),
|
||||
resolved => toResolvedConfigFilePath(state, resolved)
|
||||
) as ESMap<ResolvedConfigFilePath, true>;
|
||||
|
||||
// TODO(rbuckton): Should be a `Set`, but that requires changing the code below that uses `mutateMapSkippingNewValues`
|
||||
const currentProjects = new Map(
|
||||
getBuildOrderFromAnyBuildOrder(buildOrder).map(
|
||||
resolved => [toResolvedConfigFilePath(state, resolved), true as true])
|
||||
);
|
||||
|
||||
const noopOnDelete = { onDeleteValue: noop };
|
||||
// Config file cache
|
||||
@@ -1796,7 +1798,7 @@ namespace ts {
|
||||
if (!state.watch) return;
|
||||
updateWatchingWildcardDirectories(
|
||||
getOrCreateValueMapFromConfigFileMap(state.allWatchedWildcardDirectories, resolvedPath),
|
||||
createMapFromTemplate(parsed.configFileSpecs!.wildcardDirectories),
|
||||
new Map(getEntries(parsed.configFileSpecs!.wildcardDirectories)),
|
||||
(dir, flags) => state.watchDirectory(
|
||||
state.hostWithWatch,
|
||||
dir,
|
||||
|
||||
+62
-40
@@ -822,6 +822,9 @@ namespace ts {
|
||||
ReportsMask = ReportsUnmeasurable | ReportsUnreliable
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
export type NodeId = number;
|
||||
|
||||
export interface Node extends ReadonlyTextRange {
|
||||
readonly kind: SyntaxKind;
|
||||
readonly flags: NodeFlags;
|
||||
@@ -829,7 +832,7 @@ namespace ts {
|
||||
/* @internal */ readonly transformFlags: TransformFlags; // Flags for transforms
|
||||
readonly decorators?: NodeArray<Decorator>; // Array of decorators (in document order)
|
||||
readonly modifiers?: ModifiersArray; // Array of modifiers
|
||||
/* @internal */ id?: number; // Unique id (used to look up NodeLinks)
|
||||
/* @internal */ id?: NodeId; // Unique id (used to look up NodeLinks)
|
||||
readonly parent: Node; // Parent node (initialized by binding)
|
||||
/* @internal */ original?: Node; // The original node if this is an updated node.
|
||||
/* @internal */ symbol: Symbol; // Symbol declared by node (initialized by binding)
|
||||
@@ -3445,7 +3448,7 @@ namespace ts {
|
||||
// Stores a line map for the file.
|
||||
// This field should never be used directly to obtain line map, use getLineMap function instead.
|
||||
/* @internal */ lineMap: readonly number[];
|
||||
/* @internal */ classifiableNames?: ReadonlyUnderscoreEscapedMap<true>;
|
||||
/* @internal */ classifiableNames?: ReadonlySet<__String>;
|
||||
// Comments containing @ts-* directives, in order.
|
||||
/* @internal */ commentDirectives?: CommentDirective[];
|
||||
// Stores a mapping 'external module reference text' -> 'resolved file name' | undefined
|
||||
@@ -3724,7 +3727,7 @@ namespace ts {
|
||||
/* @internal */ getDiagnosticsProducingTypeChecker(): TypeChecker;
|
||||
/* @internal */ dropDiagnosticsProducingTypeChecker(): void;
|
||||
|
||||
/* @internal */ getClassifiableNames(): UnderscoreEscapedMap<true>;
|
||||
/* @internal */ getClassifiableNames(): Set<__String>;
|
||||
|
||||
getNodeCount(): number;
|
||||
getIdentifierCount(): number;
|
||||
@@ -4160,6 +4163,7 @@ namespace ts {
|
||||
UseAliasDefinedOutsideCurrentScope = 1 << 14, // Allow non-visible aliases
|
||||
UseSingleQuotesForStringLiteralType = 1 << 28, // Use single quotes for string literal type
|
||||
NoTypeReduction = 1 << 29, // Don't call getReducedType
|
||||
NoUndefinedOptionalParameterType = 1 << 30, // Do not add undefined to optional parameter type
|
||||
|
||||
// Error handling
|
||||
AllowThisInObjectLiteral = 1 << 15,
|
||||
@@ -4336,6 +4340,9 @@ namespace ts {
|
||||
/* @internal */
|
||||
export type AnyImportOrRequire = AnyImportSyntax | RequireVariableDeclaration;
|
||||
|
||||
/* @internal */
|
||||
export type AnyImportOrRequireStatement = AnyImportSyntax | RequireVariableStatement;
|
||||
|
||||
|
||||
/* @internal */
|
||||
export type AnyImportOrReExport = AnyImportSyntax | ExportDeclaration;
|
||||
@@ -4357,8 +4364,17 @@ namespace ts {
|
||||
|
||||
/* @internal */
|
||||
export interface RequireVariableDeclaration extends VariableDeclaration {
|
||||
readonly initializer: RequireOrImportCall;
|
||||
}
|
||||
|
||||
initializer: RequireOrImportCall;
|
||||
/* @internal */
|
||||
export interface RequireVariableStatement extends VariableStatement {
|
||||
readonly declarationList: RequireVariableDeclarationList;
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
export interface RequireVariableDeclarationList extends VariableDeclarationList {
|
||||
readonly declarations: NodeArray<RequireVariableDeclaration>;
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
@@ -4574,6 +4590,9 @@ namespace ts {
|
||||
LateBindingContainer = Class | Interface | TypeLiteral | ObjectLiteral | Function,
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
export type SymbolId = number;
|
||||
|
||||
export interface Symbol {
|
||||
flags: SymbolFlags; // Symbol flags
|
||||
escapedName: __String; // Name of symbol
|
||||
@@ -4582,7 +4601,7 @@ namespace ts {
|
||||
members?: SymbolTable; // Class, interface or object literal instance members
|
||||
exports?: SymbolTable; // Module exports
|
||||
globalExports?: SymbolTable; // Conditional global UMD exports
|
||||
/* @internal */ id?: number; // Unique id (used to look up SymbolLinks)
|
||||
/* @internal */ id?: SymbolId; // Unique id (used to look up SymbolLinks)
|
||||
/* @internal */ mergeId?: number; // Merge id (used to look up merged symbol)
|
||||
/* @internal */ parent?: Symbol; // Parent symbol
|
||||
/* @internal */ exportSymbol?: Symbol; // Exported symbol associated with this symbol
|
||||
@@ -4603,8 +4622,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?: ESMap<string, Type>; // Instantiations of generic type alias (undefined if non-generic)
|
||||
inferredClassSymbol?: ESMap<string, 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)
|
||||
@@ -4622,16 +4641,16 @@ namespace ts {
|
||||
exportsSomeValue?: boolean; // True if module exports some value (not just types)
|
||||
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
|
||||
lateSymbol?: Symbol; // Late-bound symbol for a computed property
|
||||
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?: ESMap<string, 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
|
||||
cjsExportMerged?: Symbol; // Version of the symbol with all non export= exports merged with the export= target
|
||||
extendedContainers?: 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
|
||||
cjsExportMerged?: Symbol; // Version of the symbol with all non export= exports merged with the export= target
|
||||
typeOnlyDeclaration?: TypeOnlyCompatibleAliasDeclaration | false; // First resolved alias declaration that makes the symbol only usable in type constructs
|
||||
isConstructorDeclaredProperty?: boolean; // Property declared through 'this.x = ...' assignment in constructor
|
||||
isConstructorDeclaredProperty?: boolean; // Property declared through 'this.x = ...' assignment in constructor
|
||||
tupleLabelDeclaration?: NamedTupleMember | ParameterDeclaration; // Declaration associated with the tuple's label
|
||||
}
|
||||
|
||||
@@ -4714,7 +4733,7 @@ namespace ts {
|
||||
* with a normal string (which is good, it cannot be misused on assignment or on usage),
|
||||
* while still being comparable with a normal string via === (also good) and castable from a string.
|
||||
*/
|
||||
export type __String = (string & { __escapedIdentifier: void }) | (void & { __escapedIdentifier: void }) | InternalSymbolName;
|
||||
export type __String = (string & { __escapedIdentifier: void }) | (void & { __escapedIdentifier: void }) | InternalSymbolName; // eslint-disable-line @typescript-eslint/naming-convention
|
||||
|
||||
/** ReadonlyMap where keys are `__String`s. */
|
||||
export interface ReadonlyUnderscoreEscapedMap<T> extends ReadonlyESMap<__String, T> {
|
||||
@@ -4763,31 +4782,31 @@ namespace ts {
|
||||
|
||||
/* @internal */
|
||||
export interface NodeLinks {
|
||||
flags: NodeCheckFlags; // Set of flags specific to Node
|
||||
resolvedType?: Type; // Cached type of type node
|
||||
resolvedEnumType?: Type; // Cached constraint type from enum jsdoc tag
|
||||
resolvedSignature?: Signature; // Cached signature of signature node or call expression
|
||||
resolvedSymbol?: Symbol; // Cached name resolution result
|
||||
resolvedIndexInfo?: IndexInfo; // Cached indexing info resolution result
|
||||
effectsSignature?: Signature; // Signature with possible control flow effects
|
||||
flags: NodeCheckFlags; // Set of flags specific to Node
|
||||
resolvedType?: Type; // Cached type of type node
|
||||
resolvedEnumType?: Type; // Cached constraint type from enum jsdoc tag
|
||||
resolvedSignature?: Signature; // Cached signature of signature node or call expression
|
||||
resolvedSymbol?: Symbol; // Cached name resolution result
|
||||
resolvedIndexInfo?: IndexInfo; // Cached indexing info resolution result
|
||||
effectsSignature?: Signature; // Signature with possible control flow effects
|
||||
enumMemberValue?: string | number; // Constant value of enum member
|
||||
isVisible?: boolean; // Is this node visible
|
||||
isVisible?: boolean; // Is this node visible
|
||||
containsArgumentsReference?: boolean; // Whether a function-like declaration contains an 'arguments' reference
|
||||
hasReportedStatementInAmbientContext?: boolean; // Cache boolean if we report statements in ambient context
|
||||
jsxFlags: JsxFlags; // flags for knowing what kind of element/attributes we're dealing with
|
||||
resolvedJsxElementAttributesType?: Type; // resolved element attributes type of a JSX openinglike element
|
||||
resolvedJsxElementAllAttributesType?: Type; // resolved all element attributes type of a JSX openinglike element
|
||||
resolvedJSDocType?: Type; // Resolved type of a JSDoc type reference
|
||||
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?: ESMap<string, Node>; // Set of nodes whose checking has been deferred
|
||||
hasReportedStatementInAmbientContext?: boolean; // Cache boolean if we report statements in ambient context
|
||||
jsxFlags: JsxFlags; // flags for knowing what kind of element/attributes we're dealing with
|
||||
resolvedJsxElementAttributesType?: Type; // resolved element attributes type of a JSX openinglike element
|
||||
resolvedJsxElementAllAttributesType?: Type; // resolved all element attributes type of a JSX openinglike element
|
||||
resolvedJSDocType?: Type; // Resolved type of a JSDoc type reference
|
||||
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?: 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?: ESMap<string, Type>; // Instantiations of generic type alias (undefined if non-generic)
|
||||
isExhaustive?: boolean; // Is node an exhaustive switch statement
|
||||
outerTypeParameters?: TypeParameter[]; // Outer type parameters of anonymous object type
|
||||
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.
|
||||
declarationRequiresScopeChange?: boolean; // Set by `useOuterVariableScopeInParameter` in checker when downlevel emit would change the name resolution scope inside of a parameter.
|
||||
}
|
||||
|
||||
export const enum TypeFlags {
|
||||
@@ -4878,16 +4897,19 @@ namespace ts {
|
||||
|
||||
export type DestructuringPattern = BindingPattern | ObjectLiteralExpression | ArrayLiteralExpression;
|
||||
|
||||
/* @internal */
|
||||
export type TypeId = number;
|
||||
|
||||
// Properties common to all types
|
||||
export interface Type {
|
||||
flags: TypeFlags; // Flags
|
||||
/* @internal */ id: number; // Unique ID
|
||||
/* @internal */ id: TypeId; // Unique ID
|
||||
/* @internal */ checker: TypeChecker;
|
||||
symbol: Symbol; // Symbol associated with type (if any)
|
||||
pattern?: DestructuringPattern; // Destructuring pattern represented by type (if any)
|
||||
aliasSymbol?: Symbol; // Alias associated with type
|
||||
aliasTypeArguments?: readonly Type[]; // Alias type arguments (if any)
|
||||
/* @internal */ aliasTypeArgumentsContainsMarker?: boolean; // Alias type arguments (if any)
|
||||
aliasTypeArguments?: readonly Type[]; // Alias type arguments (if any)
|
||||
/* @internal */ aliasTypeArgumentsContainsMarker?: boolean; // Alias type arguments (if any)
|
||||
/* @internal */
|
||||
permissiveInstantiation?: Type; // Instantiation with type parameters mapped to wildcard type
|
||||
/* @internal */
|
||||
|
||||
+34
-111
@@ -1,8 +1,6 @@
|
||||
/* @internal */
|
||||
namespace ts {
|
||||
export const resolvingEmptyArray: never[] = [] as never[];
|
||||
export const emptyMap = createMap<never, never>() as ReadonlyESMap<never, never> & ReadonlyPragmaMap;
|
||||
export const emptyUnderscoreEscapedMap: ReadonlyUnderscoreEscapedMap<never> = emptyMap as ReadonlyUnderscoreEscapedMap<never>;
|
||||
export const resolvingEmptyArray: never[] = [];
|
||||
|
||||
export const externalHelpersModuleNameText = "tslib";
|
||||
|
||||
@@ -22,17 +20,23 @@ namespace ts {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
/** Create a new escaped identifier map. */
|
||||
/**
|
||||
* Create a new escaped identifier map.
|
||||
* @deprecated Use `new Map<__String, T>()` instead.
|
||||
*/
|
||||
export function createUnderscoreEscapedMap<T>(): UnderscoreEscapedMap<T> {
|
||||
return new Map<string, T>() as UnderscoreEscapedMap<T>;
|
||||
return new Map<__String, T>();
|
||||
}
|
||||
|
||||
export function hasEntries(map: ReadonlyUnderscoreEscapedMap<any> | undefined): map is ReadonlyUnderscoreEscapedMap<any> {
|
||||
/**
|
||||
* @deprecated Use `!!map?.size` instead
|
||||
*/
|
||||
export function hasEntries(map: ReadonlyCollection<any> | undefined): map is ReadonlyCollection<any> {
|
||||
return !!map && !!map.size;
|
||||
}
|
||||
|
||||
export function createSymbolTable(symbols?: readonly Symbol[]): SymbolTable {
|
||||
const result = createMap<Symbol>() as SymbolTable;
|
||||
const result = new Map<__String, Symbol>();
|
||||
if (symbols) {
|
||||
for (const symbol of symbols) {
|
||||
result.set(symbol.escapedName, symbol);
|
||||
@@ -163,27 +167,6 @@ namespace ts {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a set from the elements of an array.
|
||||
*
|
||||
* @param array the array of input elements.
|
||||
*/
|
||||
export function arrayToSet(array: readonly string[]): ESMap<string, true>;
|
||||
export function arrayToSet<T>(array: readonly T[], makeKey: (value: T) => string | undefined): ESMap<string, true>;
|
||||
export function arrayToSet<T>(array: readonly T[], makeKey: (value: T) => __String | undefined): UnderscoreEscapedMap<true>;
|
||||
export function arrayToSet(array: readonly any[], makeKey?: (value: any) => string | __String | undefined): ESMap<string, true> | UnderscoreEscapedMap<true> {
|
||||
return arrayToMap<any, true>(array, makeKey || (s => s), returnTrue);
|
||||
}
|
||||
|
||||
export function cloneMap(map: SymbolTable): SymbolTable;
|
||||
export function cloneMap<T>(map: ReadonlyUnderscoreEscapedMap<T>): UnderscoreEscapedMap<T>;
|
||||
export function cloneMap<K, V>(map: ReadonlyESMap<K, V>): ESMap<K, V>;
|
||||
export function cloneMap<K, V>(map: ReadonlyESMap<K, V>): ESMap<K, V> {
|
||||
const clone = createMap<K, V>();
|
||||
copyEntries(map, clone);
|
||||
return clone;
|
||||
}
|
||||
|
||||
export function usingSingleLineStringWriter(action: (writer: EmitTextWriter) => void): string {
|
||||
const oldString = stringWriter.getText();
|
||||
try {
|
||||
@@ -206,7 +189,7 @@ namespace ts {
|
||||
|
||||
export function setResolvedModule(sourceFile: SourceFile, moduleNameText: string, resolvedModule: ResolvedModuleFull): void {
|
||||
if (!sourceFile.resolvedModules) {
|
||||
sourceFile.resolvedModules = createMap<ResolvedModuleFull>();
|
||||
sourceFile.resolvedModules = new Map<string, ResolvedModuleFull>();
|
||||
}
|
||||
|
||||
sourceFile.resolvedModules.set(moduleNameText, resolvedModule);
|
||||
@@ -214,7 +197,7 @@ namespace ts {
|
||||
|
||||
export function setResolvedTypeReferenceDirective(sourceFile: SourceFile, typeReferenceDirectiveName: string, resolvedTypeReferenceDirective?: ResolvedTypeReferenceDirective): void {
|
||||
if (!sourceFile.resolvedTypeReferenceDirectiveNames) {
|
||||
sourceFile.resolvedTypeReferenceDirectiveNames = createMap<ResolvedTypeReferenceDirective | undefined>();
|
||||
sourceFile.resolvedTypeReferenceDirectiveNames = new Map<string, ResolvedTypeReferenceDirective | undefined>();
|
||||
}
|
||||
|
||||
sourceFile.resolvedTypeReferenceDirectiveNames.set(typeReferenceDirectiveName, resolvedTypeReferenceDirective);
|
||||
@@ -473,7 +456,7 @@ namespace ts {
|
||||
]))
|
||||
);
|
||||
|
||||
const usedLines = createMap<boolean>();
|
||||
const usedLines = new Map<string, boolean>();
|
||||
|
||||
return { getUnusedExpectations, markUsed };
|
||||
|
||||
@@ -1934,8 +1917,10 @@ namespace ts {
|
||||
return isVariableDeclaration(node) && !!node.initializer && isRequireCall(node.initializer, requireStringLiteralLikeArgument);
|
||||
}
|
||||
|
||||
export function isRequireVariableDeclarationStatement(node: Node, requireStringLiteralLikeArgument = true): node is VariableStatement {
|
||||
return isVariableStatement(node) && every(node.declarationList.declarations, decl => isRequireVariableDeclaration(decl, requireStringLiteralLikeArgument));
|
||||
export function isRequireVariableStatement(node: Node, requireStringLiteralLikeArgument = true): node is RequireVariableStatement {
|
||||
return isVariableStatement(node)
|
||||
&& node.declarationList.declarations.length > 0
|
||||
&& every(node.declarationList.declarations, decl => isRequireVariableDeclaration(decl, requireStringLiteralLikeArgument));
|
||||
}
|
||||
|
||||
export function isSingleOrDoubleQuote(charCode: number) {
|
||||
@@ -3590,7 +3575,7 @@ namespace ts {
|
||||
export function createDiagnosticCollection(): DiagnosticCollection {
|
||||
let nonFileDiagnostics = [] as Diagnostic[] as SortedArray<Diagnostic>; // See GH#19873
|
||||
const filesWithDiagnostics = [] as string[] as SortedArray<string>;
|
||||
const fileDiagnostics = createMap<SortedArray<DiagnosticWithLocation>>();
|
||||
const fileDiagnostics = new Map<string, SortedArray<DiagnosticWithLocation>>();
|
||||
let hasReadNonFileDiagnostics = false;
|
||||
|
||||
return {
|
||||
@@ -3688,7 +3673,7 @@ namespace ts {
|
||||
const singleQuoteEscapedCharsRegExp = /[\\\'\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g;
|
||||
// Template strings should be preserved as much as possible
|
||||
const backtickQuoteEscapedCharsRegExp = /[\\`]/g;
|
||||
const escapedCharsMap = createMapFromTemplate({
|
||||
const escapedCharsMap = new Map(getEntries({
|
||||
"\t": "\\t",
|
||||
"\v": "\\v",
|
||||
"\f": "\\f",
|
||||
@@ -3702,7 +3687,7 @@ namespace ts {
|
||||
"\u2028": "\\u2028", // lineSeparator
|
||||
"\u2029": "\\u2029", // paragraphSeparator
|
||||
"\u0085": "\\u0085" // nextLine
|
||||
});
|
||||
}));
|
||||
|
||||
function encodeUtf16EscapeSequence(charCode: number): string {
|
||||
const hexCharCode = charCode.toString(16).toUpperCase();
|
||||
@@ -3752,10 +3737,10 @@ namespace ts {
|
||||
// the map below must be updated.
|
||||
const jsxDoubleQuoteEscapedCharsRegExp = /[\"\u0000-\u001f\u2028\u2029\u0085]/g;
|
||||
const jsxSingleQuoteEscapedCharsRegExp = /[\'\u0000-\u001f\u2028\u2029\u0085]/g;
|
||||
const jsxEscapedCharsMap = createMapFromTemplate({
|
||||
const jsxEscapedCharsMap = new Map(getEntries({
|
||||
"\"": """,
|
||||
"\'": "'"
|
||||
});
|
||||
}));
|
||||
|
||||
function encodeJsxCharacterEntity(charCode: number): string {
|
||||
const hexCharCode = charCode.toString(16).toUpperCase();
|
||||
@@ -4755,7 +4740,7 @@ namespace ts {
|
||||
if (isPropertyAccessExpression(expr)) {
|
||||
const baseStr = tryGetPropertyAccessOrIdentifierToString(expr.expression);
|
||||
if (baseStr !== undefined) {
|
||||
return baseStr + "." + expr.name;
|
||||
return baseStr + "." + entityNameToString(expr.name);
|
||||
}
|
||||
}
|
||||
else if (isIdentifier(expr)) {
|
||||
@@ -5942,7 +5927,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
export function discoverProbableSymlinks(files: readonly SourceFile[], getCanonicalFileName: GetCanonicalFileName, cwd: string): ReadonlyESMap<string, string> {
|
||||
const result = createMap<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 =>
|
||||
res && res.originalPath && res.resolvedFileName !== res.originalPath ? [res.resolvedFileName, res.originalPath] as const : undefined)))));
|
||||
@@ -6200,7 +6185,7 @@ namespace ts {
|
||||
// Associate an array of results with each include regex. This keeps results in order of the "include" order.
|
||||
// If there are no "includes", then just put everything in results[0].
|
||||
const results: string[][] = includeFileRegexes ? includeFileRegexes.map(() => []) : [[]];
|
||||
const visited = createMap<true>();
|
||||
const visited = new Map<string, true>();
|
||||
const toCanonical = createGetCanonicalFileName(useCaseSensitiveFileNames);
|
||||
for (const basePath of patterns.basePaths) {
|
||||
visitDirectory(basePath, combinePaths(currentDirectory, basePath), depth);
|
||||
@@ -6564,67 +6549,17 @@ namespace ts {
|
||||
return { min, max };
|
||||
}
|
||||
|
||||
export interface ReadonlyNodeSet<TNode extends Node> {
|
||||
has(node: TNode): boolean;
|
||||
forEach(cb: (node: TNode) => void): void;
|
||||
some(pred: (node: TNode) => boolean): boolean;
|
||||
}
|
||||
/** @deprecated Use `ReadonlySet<TNode>` instead. */
|
||||
export type ReadonlyNodeSet<TNode extends Node> = ReadonlySet<TNode>;
|
||||
|
||||
export class NodeSet<TNode extends Node> implements ReadonlyNodeSet<TNode> {
|
||||
private map = createMap<TNode>();
|
||||
/** @deprecated Use `Set<TNode>` instead. */
|
||||
export type NodeSet<TNode extends Node> = Set<TNode>;
|
||||
|
||||
add(node: TNode): void {
|
||||
this.map.set(String(getNodeId(node)), node);
|
||||
}
|
||||
tryAdd(node: TNode): boolean {
|
||||
if (this.has(node)) return false;
|
||||
this.add(node);
|
||||
return true;
|
||||
}
|
||||
has(node: TNode): boolean {
|
||||
return this.map.has(String(getNodeId(node)));
|
||||
}
|
||||
forEach(cb: (node: TNode) => void): void {
|
||||
this.map.forEach(cb);
|
||||
}
|
||||
some(pred: (node: TNode) => boolean): boolean {
|
||||
return forEachEntry(this.map, pred) || false;
|
||||
}
|
||||
}
|
||||
/** @deprecated Use `ReadonlyMap<TNode, TValue>` instead. */
|
||||
export type ReadonlyNodeMap<TNode extends Node, TValue> = ReadonlyESMap<TNode, TValue>;
|
||||
|
||||
export interface ReadonlyNodeMap<TNode extends Node, TValue> {
|
||||
get(node: TNode): TValue | undefined;
|
||||
has(node: TNode): boolean;
|
||||
}
|
||||
|
||||
export class NodeMap<TNode extends Node, TValue> implements ReadonlyNodeMap<TNode, TValue> {
|
||||
private map = createMap<{ node: TNode, value: TValue }>();
|
||||
|
||||
get(node: TNode): TValue | undefined {
|
||||
const res = this.map.get(String(getNodeId(node)));
|
||||
return res && res.value;
|
||||
}
|
||||
|
||||
getOrUpdate(node: TNode, setValue: () => TValue): TValue {
|
||||
const res = this.get(node);
|
||||
if (res) return res;
|
||||
const value = setValue();
|
||||
this.set(node, value);
|
||||
return value;
|
||||
}
|
||||
|
||||
set(node: TNode, value: TValue): void {
|
||||
this.map.set(String(getNodeId(node)), { node, value });
|
||||
}
|
||||
|
||||
has(node: TNode): boolean {
|
||||
return this.map.has(String(getNodeId(node)));
|
||||
}
|
||||
|
||||
forEach(cb: (value: TValue, node: TNode) => void): void {
|
||||
this.map.forEach(({ node, value }) => cb(value, node));
|
||||
}
|
||||
}
|
||||
/** @deprecated Use `Map<TNode, TValue>` instead. */
|
||||
export type NodeMap<TNode extends Node, TValue> = ESMap<TNode, TValue>;
|
||||
|
||||
export function rangeOfNode(node: Node): TextRange {
|
||||
return { pos: getTokenPosOfNode(node), end: node.end };
|
||||
@@ -6652,18 +6587,6 @@ namespace ts {
|
||||
return a === b || typeof a === "object" && a !== null && typeof b === "object" && b !== null && equalOwnProperties(a as MapLike<unknown>, b as MapLike<unknown>, isJsonEqual);
|
||||
}
|
||||
|
||||
export function getOrUpdate<T>(map: ESMap<string, T>, key: string, getDefault: () => T): T {
|
||||
const got = map.get(key);
|
||||
if (got === undefined) {
|
||||
const value = getDefault();
|
||||
map.set(key, value);
|
||||
return value;
|
||||
}
|
||||
else {
|
||||
return got;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a bigint literal string, e.g. `0x1234n`,
|
||||
* to its decimal string representation, e.g. `4660`.
|
||||
|
||||
@@ -252,7 +252,7 @@ namespace ts {
|
||||
let timerToInvalidateFailedLookupResolutions: any; // timer callback to invalidate resolutions for changes in failed lookup locations
|
||||
|
||||
|
||||
const sourceFilesCache = createMap<HostFileInfo>(); // Cache that stores the source file and version info
|
||||
const sourceFilesCache = new Map<string, HostFileInfo>(); // Cache that stores the source file and version info
|
||||
let missingFilePathsRequestedForRelease: Path[] | undefined; // These paths are held temparirly so that we can remove the entry from source file cache if the file is not tracked by missing files
|
||||
let hasChangedCompilerOptions = false; // True if the compiler options have changed between compilations
|
||||
|
||||
@@ -717,8 +717,8 @@ namespace ts {
|
||||
function watchConfigFileWildCardDirectories() {
|
||||
if (configFileSpecs) {
|
||||
updateWatchingWildcardDirectories(
|
||||
watchedWildcardDirectories || (watchedWildcardDirectories = createMap()),
|
||||
createMapFromTemplate(configFileSpecs.wildcardDirectories),
|
||||
watchedWildcardDirectories || (watchedWildcardDirectories = new Map()),
|
||||
new Map(getEntries(configFileSpecs.wildcardDirectories)),
|
||||
watchWildcardDirectory
|
||||
);
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ namespace ts {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const cachedReadDirectoryResult = createMap<MutableFileSystemEntries>();
|
||||
const cachedReadDirectoryResult = new Map<string, MutableFileSystemEntries>();
|
||||
const getCanonicalFileName = createGetCanonicalFileName(useCaseSensitiveFileNames);
|
||||
return {
|
||||
useCaseSensitiveFileNames,
|
||||
@@ -266,7 +266,8 @@ namespace ts {
|
||||
createMissingFileWatch: (missingFilePath: Path) => FileWatcher,
|
||||
) {
|
||||
const missingFilePaths = program.getMissingFilePaths();
|
||||
const newMissingFilePathMap = arrayToSet(missingFilePaths);
|
||||
// TODO(rbuckton): Should be a `Set` but that requires changing the below code that uses `mutateMap`
|
||||
const newMissingFilePathMap = arrayToMap(missingFilePaths, identity, returnTrue);
|
||||
// Update the missing file paths watcher
|
||||
mutateMap(
|
||||
missingFileWatches,
|
||||
|
||||
@@ -75,7 +75,7 @@ namespace ts {
|
||||
const usageColumn: string[] = []; // Things like "-d, --declaration" go in here.
|
||||
const descriptionColumn: string[] = [];
|
||||
|
||||
const optionsDescriptionMap = createMap<string[]>(); // Map between option.description and list of option.type if it is a kind
|
||||
const optionsDescriptionMap = new Map<string, string[]>(); // Map between option.description and list of option.type if it is a kind
|
||||
|
||||
for (const option of optionsList) {
|
||||
// If an option lacks a description,
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace ts.server {
|
||||
|
||||
export class SessionClient implements LanguageService {
|
||||
private sequence = 0;
|
||||
private lineMaps: ESMap<string, number[]> = createMap<number[]>();
|
||||
private lineMaps = new Map<string, number[]>();
|
||||
private messages: string[] = [];
|
||||
private lastRenameEntry: RenameEntry | undefined;
|
||||
|
||||
|
||||
@@ -177,7 +177,7 @@ namespace FourSlash {
|
||||
|
||||
public formatCodeSettings: ts.FormatCodeSettings;
|
||||
|
||||
private inputFiles = ts.createMap<string>(); // Map between inputFile's fileName and its content for easily looking up when resolving references
|
||||
private inputFiles = new ts.Map<string, string>(); // Map between inputFile's fileName and its content for easily looking up when resolving references
|
||||
|
||||
private static getDisplayPartsJson(displayParts: ts.SymbolDisplayPart[] | undefined) {
|
||||
let result = "";
|
||||
@@ -830,7 +830,7 @@ namespace FourSlash {
|
||||
this.raiseError(`Expected 'isGlobalCompletion to be ${options.isGlobalCompletion}, got ${actualCompletions.isGlobalCompletion}`);
|
||||
}
|
||||
|
||||
const nameToEntries = ts.createMap<ts.CompletionEntry[]>();
|
||||
const nameToEntries = new ts.Map<string, ts.CompletionEntry[]>();
|
||||
for (const entry of actualCompletions.entries) {
|
||||
const entries = nameToEntries.get(entry.name);
|
||||
if (!entries) {
|
||||
@@ -995,7 +995,7 @@ namespace FourSlash {
|
||||
}
|
||||
|
||||
public setTypesRegistry(map: ts.MapLike<void>): void {
|
||||
this.languageServiceAdapterHost.typesRegistry = ts.createMapFromTemplate(map);
|
||||
this.languageServiceAdapterHost.typesRegistry = new ts.Map(ts.getEntries(map));
|
||||
}
|
||||
|
||||
public verifyTypeOfSymbolAtLocation(range: Range, symbol: ts.Symbol, expected: string): void {
|
||||
@@ -2889,7 +2889,7 @@ namespace FourSlash {
|
||||
|
||||
public verifyBraceCompletionAtPosition(negative: boolean, openingBrace: string) {
|
||||
|
||||
const openBraceMap = ts.createMapFromTemplate<ts.CharacterCodes>({
|
||||
const openBraceMap = new ts.Map(ts.getEntries<ts.CharacterCodes>({
|
||||
"(": ts.CharacterCodes.openParen,
|
||||
"{": ts.CharacterCodes.openBrace,
|
||||
"[": ts.CharacterCodes.openBracket,
|
||||
@@ -2897,7 +2897,7 @@ namespace FourSlash {
|
||||
'"': ts.CharacterCodes.doubleQuote,
|
||||
"`": ts.CharacterCodes.backtick,
|
||||
"<": ts.CharacterCodes.lessThan
|
||||
});
|
||||
}));
|
||||
|
||||
const charCode = openBraceMap.get(openingBrace);
|
||||
|
||||
@@ -3510,7 +3510,7 @@ namespace FourSlash {
|
||||
let text = "";
|
||||
if (callHierarchyItem) {
|
||||
const file = this.findFile(callHierarchyItem.file);
|
||||
text += this.formatCallHierarchyItem(file, callHierarchyItem, CallHierarchyItemDirection.Root, ts.createMap(), "");
|
||||
text += this.formatCallHierarchyItem(file, callHierarchyItem, CallHierarchyItemDirection.Root, new ts.Map(), "");
|
||||
}
|
||||
return text;
|
||||
}
|
||||
@@ -3806,7 +3806,7 @@ namespace FourSlash {
|
||||
const lines = contents.split("\n");
|
||||
let i = 0;
|
||||
|
||||
const markerPositions = ts.createMap<Marker>();
|
||||
const markerPositions = new ts.Map<string, Marker>();
|
||||
const markers: Marker[] = [];
|
||||
const ranges: Range[] = [];
|
||||
|
||||
@@ -4195,7 +4195,7 @@ namespace FourSlash {
|
||||
|
||||
/** Collects an array of unique outputs. */
|
||||
function unique<T>(inputs: readonly T[], getOutput: (t: T) => string): string[] {
|
||||
const set = ts.createMap<true>();
|
||||
const set = new ts.Map<string, true>();
|
||||
for (const input of inputs) {
|
||||
const out = getOutput(input);
|
||||
set.set(out, true);
|
||||
|
||||
@@ -251,9 +251,9 @@ namespace Harness {
|
||||
}
|
||||
|
||||
if (!libFileNameSourceFileMap) {
|
||||
libFileNameSourceFileMap = ts.createMapFromTemplate({
|
||||
libFileNameSourceFileMap = new ts.Map(ts.getEntries({
|
||||
[defaultLibFileName]: createSourceFileAndAssertInvariants(defaultLibFileName, IO.readFile(libFolder + "lib.es5.d.ts")!, /*languageVersion*/ ts.ScriptTarget.Latest)
|
||||
});
|
||||
}));
|
||||
}
|
||||
|
||||
let sourceFile = libFileNameSourceFileMap.get(fileName);
|
||||
@@ -316,7 +316,7 @@ namespace Harness {
|
||||
let optionsIndex: ts.ESMap<string, ts.CommandLineOption>;
|
||||
function getCommandLineOption(name: string): ts.CommandLineOption | undefined {
|
||||
if (!optionsIndex) {
|
||||
optionsIndex = ts.createMap<ts.CommandLineOption>();
|
||||
optionsIndex = new ts.Map<string, ts.CommandLineOption>();
|
||||
const optionDeclarations = harnessOptionDeclarations.concat(ts.optionDeclarations);
|
||||
for (const option of optionDeclarations) {
|
||||
optionsIndex.set(option.name.toLowerCase(), option);
|
||||
@@ -595,7 +595,7 @@ namespace Harness {
|
||||
errorsReported = 0;
|
||||
|
||||
// 'merge' the lines of each input file with any errors associated with it
|
||||
const dupeCase = ts.createMap<number>();
|
||||
const dupeCase = new ts.Map<string, number>();
|
||||
for (const inputFile of inputFiles.filter(f => f.content !== undefined)) {
|
||||
// Filter down to the errors in the file
|
||||
const fileErrors = diagnostics.filter((e): e is ts.DiagnosticWithLocation => {
|
||||
@@ -775,7 +775,7 @@ namespace Harness {
|
||||
if (skipBaseline) {
|
||||
return;
|
||||
}
|
||||
const dupeCase = ts.createMap<number>();
|
||||
const dupeCase = new ts.Map<string, number>();
|
||||
|
||||
for (const file of allFiles) {
|
||||
const { unitName } = file;
|
||||
@@ -946,7 +946,7 @@ namespace Harness {
|
||||
// Collect, test, and sort the fileNames
|
||||
const files = Array.from(outputFiles);
|
||||
files.slice().sort((a, b) => ts.compareStringsCaseSensitive(cleanName(a.file), cleanName(b.file)));
|
||||
const dupeCase = ts.createMap<number>();
|
||||
const dupeCase = new ts.Map<string, number>();
|
||||
// Yield them
|
||||
for (const outputFile of files) {
|
||||
yield [checkDuplicatedFileName(outputFile.file, dupeCase), "/*====== " + outputFile.file + " ======*/\r\n" + Utils.removeByteOrderMark(outputFile.text)];
|
||||
@@ -1075,10 +1075,10 @@ namespace Harness {
|
||||
return option.type;
|
||||
}
|
||||
if (option.type === "boolean") {
|
||||
return booleanVaryByStarSettingValues || (booleanVaryByStarSettingValues = ts.createMapFromTemplate({
|
||||
return booleanVaryByStarSettingValues || (booleanVaryByStarSettingValues = new ts.Map(ts.getEntries({
|
||||
true: 1,
|
||||
false: 0
|
||||
}));
|
||||
})));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1403,7 +1403,7 @@ namespace Harness {
|
||||
|
||||
export function runMultifileBaseline(relativeFileBase: string, extension: string, generateContent: () => IterableIterator<[string, string, number]> | IterableIterator<[string, string]> | null, opts?: BaselineOptions, referencedExtensions?: string[]): void {
|
||||
const gen = generateContent();
|
||||
const writtenFiles = ts.createMap<true>();
|
||||
const writtenFiles = new ts.Map<string, true>();
|
||||
const errors: Error[] = [];
|
||||
|
||||
// eslint-disable-next-line no-null/no-null
|
||||
|
||||
@@ -52,7 +52,7 @@ namespace Utils {
|
||||
}
|
||||
|
||||
export function memoize<T extends ts.AnyFunction>(f: T, memoKey: (...anything: any[]) => string): T {
|
||||
const cache = ts.createMap<any>();
|
||||
const cache = new ts.Map<string, any>();
|
||||
|
||||
return <any>(function (this: any, ...args: any[]) {
|
||||
const key = memoKey(...args);
|
||||
|
||||
@@ -219,7 +219,7 @@ namespace Playback {
|
||||
replayLog = log;
|
||||
// Remove non-found files from the log (shouldn't really need them, but we still record them for diagnostic purposes)
|
||||
replayLog.filesRead = replayLog.filesRead.filter(f => f.result!.contents !== undefined);
|
||||
replayFilesRead = ts.createMap();
|
||||
replayFilesRead = new ts.Map();
|
||||
for (const file of replayLog.filesRead) {
|
||||
replayFilesRead.set(ts.normalizeSlashes(file.path).toLowerCase(), file);
|
||||
}
|
||||
|
||||
@@ -325,7 +325,7 @@ namespace Harness.SourceMapRecorder {
|
||||
export function getSourceMapRecordWithSystem(sys: ts.System, sourceMapFile: string) {
|
||||
const sourceMapRecorder = new Compiler.WriterAggregator();
|
||||
let prevSourceFile: documents.TextDocument | undefined;
|
||||
const files = ts.createMap<documents.TextDocument>();
|
||||
const files = new ts.Map<string, documents.TextDocument>();
|
||||
const sourceMap = ts.tryParseRawSourceMap(sys.readFile(sourceMapFile, "utf8")!);
|
||||
if (sourceMap) {
|
||||
const mapDirectory = ts.getDirectoryPath(sourceMapFile);
|
||||
|
||||
@@ -133,7 +133,7 @@ interface Array<T> { length: number; [n: number]: T; }`
|
||||
}
|
||||
const notInActual: string[] = [];
|
||||
const duplicates: string[] = [];
|
||||
const seen = createMap<true>();
|
||||
const seen = new Map<string, true>();
|
||||
forEach(expectedKeys, expectedKey => {
|
||||
if (seen.has(expectedKey)) {
|
||||
duplicates.push(expectedKey);
|
||||
@@ -260,20 +260,20 @@ interface Array<T> { length: number; [n: number]: T; }`
|
||||
}
|
||||
|
||||
export function checkOutputContains(host: TestServerHost, expected: readonly string[]) {
|
||||
const mapExpected = arrayToSet(expected);
|
||||
const mapSeen = createMap<true>();
|
||||
const mapExpected = new Set(expected);
|
||||
const mapSeen = new Set<string>();
|
||||
for (const f of host.getOutput()) {
|
||||
assert.isUndefined(mapSeen.get(f), `Already found ${f} in ${JSON.stringify(host.getOutput())}`);
|
||||
assert.isFalse(mapSeen.has(f), `Already found ${f} in ${JSON.stringify(host.getOutput())}`);
|
||||
if (mapExpected.has(f)) {
|
||||
mapExpected.delete(f);
|
||||
mapSeen.set(f, true);
|
||||
mapSeen.add(f);
|
||||
}
|
||||
}
|
||||
assert.equal(mapExpected.size, 0, `Output has missing ${JSON.stringify(arrayFrom(mapExpected.keys()))} in ${JSON.stringify(host.getOutput())}`);
|
||||
}
|
||||
|
||||
export function checkOutputDoesNotContain(host: TestServerHost, expectedToBeAbsent: string[] | readonly string[]) {
|
||||
const mapExpectedToBeAbsent = arrayToSet(expectedToBeAbsent);
|
||||
const mapExpectedToBeAbsent = new Set(expectedToBeAbsent);
|
||||
for (const f of host.getOutput()) {
|
||||
assert.isFalse(mapExpectedToBeAbsent.has(f), `Contains ${f} in ${JSON.stringify(host.getOutput())}`);
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ namespace ts.JsTyping {
|
||||
"zlib"
|
||||
];
|
||||
|
||||
export const nodeCoreModules = arrayToSet(nodeCoreModuleList);
|
||||
export const nodeCoreModules = new Set(nodeCoreModuleList);
|
||||
|
||||
export function nonRelativeModuleNameForTypingCache(moduleName: string) {
|
||||
return nodeCoreModules.has(moduleName) ? "node" : moduleName;
|
||||
@@ -81,13 +81,13 @@ namespace ts.JsTyping {
|
||||
|
||||
export function loadSafeList(host: TypingResolutionHost, safeListPath: Path): SafeList {
|
||||
const result = readConfigFile(safeListPath, path => host.readFile(path));
|
||||
return createMapFromTemplate<string>(result.config);
|
||||
return new Map(getEntries<string>(result.config));
|
||||
}
|
||||
|
||||
export function loadTypesMap(host: TypingResolutionHost, typesMapPath: Path): SafeList | undefined {
|
||||
const result = readConfigFile(typesMapPath, path => host.readFile(path));
|
||||
if (result.config) {
|
||||
return createMapFromTemplate<string>(result.config.simpleMap);
|
||||
return new Map(getEntries<string>(result.config.simpleMap));
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
@@ -118,7 +118,7 @@ namespace ts.JsTyping {
|
||||
}
|
||||
|
||||
// A typing name to typing file path mapping
|
||||
const inferredTypings = createMap<string>();
|
||||
const inferredTypings = new Map<string, string>();
|
||||
|
||||
// Only infer typings for .js and .jsx files
|
||||
fileNames = mapDefined(fileNames, fileName => {
|
||||
@@ -134,9 +134,9 @@ namespace ts.JsTyping {
|
||||
const exclude = typeAcquisition.exclude || [];
|
||||
|
||||
// Directories to search for package.json, bower.json and other typing information
|
||||
const possibleSearchDirs = arrayToSet(fileNames, getDirectoryPath);
|
||||
possibleSearchDirs.set(projectRootPath, true);
|
||||
possibleSearchDirs.forEach((_true, searchDir) => {
|
||||
const possibleSearchDirs = new Set(fileNames.map(getDirectoryPath));
|
||||
possibleSearchDirs.add(projectRootPath);
|
||||
possibleSearchDirs.forEach((searchDir) => {
|
||||
const packageJsonPath = combinePaths(searchDir, "package.json");
|
||||
getTypingNamesFromJson(packageJsonPath, filesToWatch);
|
||||
|
||||
|
||||
@@ -4068,11 +4068,11 @@
|
||||
</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">
|
||||
<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 ':'? When following property names in an object literal, '=' implies a destructuring assignment.]]></Val>
|
||||
<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>
|
||||
<Val><![CDATA[要使用 ':' 嗎? 當包含的物件常值是解構模式的一部分時,'=' 就只能位於屬性名稱後面。]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
|
||||
@@ -4077,11 +4077,11 @@
|
||||
</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">
|
||||
<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 ':'? When following property names in an object literal, '=' implies a destructuring assignment.]]></Val>
|
||||
<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[Nechtěli jste použít :? Když se budou dodržovat názvy vlastností v literálu objektu, = znamená destrukční přiřazení.]]></Val>
|
||||
<Val><![CDATA[Neměli jste v úmyslu použít znak :? Znak = může následovat pouze po názvu vlastnosti, když je obsahující objekt literálu součástí vzoru destrukturalizace.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
|
||||
@@ -4065,11 +4065,11 @@
|
||||
</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">
|
||||
<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 ':'? When following property names in an object literal, '=' implies a destructuring assignment.]]></Val>
|
||||
<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[Wollten Sie ":" verwenden? Bei Eigenschaftennamen in einem Objektliteral impliziert "=" eine Destrukturierungszuweisung.]]></Val>
|
||||
<Val><![CDATA[Wollten Sie ":" verwenden? Ein "=" kann nur dann auf einen Eigenschaftennamen folgen, wenn das enthaltende Objektliteral Teil eines Destrukturierungsmusters ist.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
|
||||
@@ -4080,11 +4080,11 @@
|
||||
</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">
|
||||
<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 ':'? When following property names in an object literal, '=' implies a destructuring assignment.]]></Val>
|
||||
<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[¿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>
|
||||
<Val><![CDATA[¿Pretendía usar ":"? El símbolo "=" solo puede seguir a un nombre de propiedad cuando el literal de objeto contenedor forma parte de un patrón de desestructuración.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
|
||||
@@ -4080,11 +4080,11 @@
|
||||
</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">
|
||||
<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 ':'? When following property names in an object literal, '=' implies a destructuring assignment.]]></Val>
|
||||
<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[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>
|
||||
<Val><![CDATA[Voulez-vous vraiment utiliser le signe ':' ? Le signe '=' peut suivre uniquement un nom de propriété quand le littéral d'objet conteneur fait partie d'un modèle de déstructuration.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
|
||||
@@ -4068,11 +4068,11 @@
|
||||
</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">
|
||||
<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 ':'? When following property names in an object literal, '=' implies a destructuring assignment.]]></Val>
|
||||
<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[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>
|
||||
<Val><![CDATA[Si intendeva usare i due punti (':')? È possibile usare il carattere '=' dopo un nome di proprietà, solo quando il valore letterale di oggetto che lo contiene fa parte di un criterio di destrutturazione.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
|
||||
@@ -4068,11 +4068,11 @@
|
||||
</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">
|
||||
<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 ':'? When following property names in an object literal, '=' implies a destructuring assignment.]]></Val>
|
||||
<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>
|
||||
<Val><![CDATA[':' を使用するつもりでしたか? 含まれるオブジェクト リテラルが非構造化パターンの一部である場合、'=' はプロパティ名の後にのみ使用することができます。]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
|
||||
@@ -4068,11 +4068,11 @@
|
||||
</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">
|
||||
<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 ':'? When following property names in an object literal, '=' implies a destructuring assignment.]]></Val>
|
||||
<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>
|
||||
<Val><![CDATA[':'을 사용하려고 하셨습니까? '='은 포함하는 개체 리터럴이 구조 파괴 패턴에 속하는 경우에만 속성 이름 뒤에 올 수 있습니다.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
|
||||
@@ -4058,11 +4058,11 @@
|
||||
</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">
|
||||
<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 ':'? When following property names in an object literal, '=' implies a destructuring assignment.]]></Val>
|
||||
<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[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>
|
||||
<Val><![CDATA[Czy chodziło o użycie znaku „:”? Znak „=” może występować po nazwie właściwości tylko wtedy, gdy zawierający literał obiektu jest częścią wzorca usuwającego strukturę.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
|
||||
@@ -4061,11 +4061,11 @@
|
||||
</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">
|
||||
<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 ':'? When following property names in an object literal, '=' implies a destructuring assignment.]]></Val>
|
||||
<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[Você quis usar um ':'? Após os nomes de propriedade em um literal de objeto, '=' implica uma atribuição de desestruturação.]]></Val>
|
||||
<Val><![CDATA[Você quis usar ':'? '=' só pode estar após um nome de propriedade quando o literal de objeto contentor faz parte de um padrão de desestruturação.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
|
||||
@@ -4067,11 +4067,11 @@
|
||||
</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">
|
||||
<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 ':'? When following property names in an object literal, '=' implies a destructuring assignment.]]></Val>
|
||||
<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>
|
||||
<Val><![CDATA[Вы хотели использовать ":"? Знак равенства "=" после имени свойства может указываться только в том случае, если внутренний объектный литерал является частью шаблона деструктурирования.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
|
||||
@@ -4061,11 +4061,11 @@
|
||||
</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">
|
||||
<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 ':'? When following property names in an object literal, '=' implies a destructuring assignment.]]></Val>
|
||||
<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[':' 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>
|
||||
<Val><![CDATA[':' kullanmak mı istediniz? İçeren nesne sabit değeri, yok etme deseninin parçası olduğunda özellik adının ardından yalnızca '=' gelebilir.]]></Val>
|
||||
</Tgt>
|
||||
</Str>
|
||||
<Disp Icon="Str" />
|
||||
|
||||
@@ -158,7 +158,7 @@ namespace ts.server {
|
||||
}
|
||||
|
||||
function prepareConvertersForEnumLikeCompilerOptions(commandLineOptions: CommandLineOption[]): ESMap<string, ESMap<string, number>> {
|
||||
const map: ESMap<string, ESMap<string, number>> = createMap<ESMap<string, number>>();
|
||||
const map = new Map<string, ESMap<string, number>>();
|
||||
for (const option of commandLineOptions) {
|
||||
if (typeof option.type === "object") {
|
||||
const optionMap = <ESMap<string, number>>option.type;
|
||||
@@ -174,11 +174,11 @@ namespace ts.server {
|
||||
|
||||
const compilerOptionConverters = prepareConvertersForEnumLikeCompilerOptions(optionDeclarations);
|
||||
const watchOptionsConverters = prepareConvertersForEnumLikeCompilerOptions(optionsForWatch);
|
||||
const indentStyle = createMapFromTemplate({
|
||||
const indentStyle = new Map(getEntries({
|
||||
none: IndentStyle.None,
|
||||
block: IndentStyle.Block,
|
||||
smart: IndentStyle.Smart
|
||||
});
|
||||
}));
|
||||
|
||||
export interface TypesMapFile {
|
||||
typesMap: SafeList;
|
||||
@@ -571,16 +571,16 @@ namespace ts.server {
|
||||
* Container of all known scripts
|
||||
*/
|
||||
/*@internal*/
|
||||
readonly filenameToScriptInfo = createMap<ScriptInfo>();
|
||||
private readonly scriptInfoInNodeModulesWatchers = createMap <ScriptInfoInNodeModulesWatcher>();
|
||||
readonly filenameToScriptInfo = new Map<string, ScriptInfo>();
|
||||
private readonly scriptInfoInNodeModulesWatchers = new Map<string, ScriptInfoInNodeModulesWatcher>();
|
||||
/**
|
||||
* Contains all the deleted script info's version information so that
|
||||
* it does not reset when creating script info again
|
||||
* (and could have potentially collided with version where contents mismatch)
|
||||
*/
|
||||
private readonly filenameToScriptInfoVersion = createMap<ScriptInfoVersion>();
|
||||
private readonly filenameToScriptInfoVersion = new Map<string, ScriptInfoVersion>();
|
||||
// Set of all '.js' files ever opened.
|
||||
private readonly allJsFilesForOpenFileTelemetry = createMap<true>();
|
||||
private readonly allJsFilesForOpenFileTelemetry = new Map<string, true>();
|
||||
|
||||
/**
|
||||
* Map to the real path of the infos
|
||||
@@ -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: ESMap<string, NormalizedPath[]> = createMap<NormalizedPath[]>();
|
||||
private readonly externalProjectToConfiguredProjectMap = new Map<string, NormalizedPath[]>();
|
||||
|
||||
/**
|
||||
* external projects (configuration and list of root files is not controlled by tsserver)
|
||||
@@ -603,7 +603,7 @@ namespace ts.server {
|
||||
/**
|
||||
* projects specified by a tsconfig.json file
|
||||
*/
|
||||
readonly configuredProjects: Map<ConfiguredProject> = createMap<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
|
||||
*/
|
||||
@@ -611,16 +611,16 @@ namespace ts.server {
|
||||
/**
|
||||
* Map of open files that are opened without complete path but have projectRoot as current directory
|
||||
*/
|
||||
private readonly openFilesWithNonRootedDiskPath = createMap<ScriptInfo>();
|
||||
private readonly openFilesWithNonRootedDiskPath = new Map<string, ScriptInfo>();
|
||||
|
||||
private compilerOptionsForInferredProjects: CompilerOptions | undefined;
|
||||
private compilerOptionsForInferredProjectsPerProjectRoot = createMap<CompilerOptions>();
|
||||
private compilerOptionsForInferredProjectsPerProjectRoot = new Map<string, CompilerOptions>();
|
||||
private watchOptionsForInferredProjects: WatchOptions | undefined;
|
||||
private watchOptionsForInferredProjectsPerProjectRoot = createMap<WatchOptions | false>();
|
||||
private watchOptionsForInferredProjectsPerProjectRoot = new Map<string, WatchOptions | false>();
|
||||
/**
|
||||
* Project size for configured or external projects
|
||||
*/
|
||||
private readonly projectToSizeMap: ESMap<string, number> = createMap<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
|
||||
@@ -628,14 +628,14 @@ namespace ts.server {
|
||||
* - Or it is present if we have configured project open with config file at that location
|
||||
* In this case the exists property is always true
|
||||
*/
|
||||
private readonly configFileExistenceInfoCache = createMap<ConfigFileExistenceInfo>();
|
||||
private readonly configFileExistenceInfoCache = new Map<string, ConfigFileExistenceInfo>();
|
||||
/*@internal*/ readonly throttledOperations: ThrottledOperations;
|
||||
|
||||
private readonly hostConfiguration: HostConfiguration;
|
||||
private safelist: SafeList = defaultTypeSafeList;
|
||||
private readonly legacySafelist = createMap<string>();
|
||||
private readonly legacySafelist = new Map<string, string>();
|
||||
|
||||
private pendingProjectUpdates = createMap<Project>();
|
||||
private pendingProjectUpdates = new Map<string, Project>();
|
||||
/* @internal */
|
||||
pendingEnsureProjectForOpenFiles = false;
|
||||
|
||||
@@ -663,7 +663,7 @@ namespace ts.server {
|
||||
public readonly syntaxOnly?: boolean;
|
||||
|
||||
/** Tracks projects that we have already sent telemetry for. */
|
||||
private readonly seenProjects = createMap<true>();
|
||||
private readonly seenProjects = new Map<string, true>();
|
||||
|
||||
/*@internal*/
|
||||
readonly watchFactory: WatchFactory<WatchType, Project>;
|
||||
@@ -2039,7 +2039,7 @@ namespace ts.server {
|
||||
project.setCompilerOptions(compilerOptions);
|
||||
project.setWatchOptions(parsedCommandLine.watchOptions);
|
||||
project.enableLanguageService();
|
||||
project.watchWildcards(createMapFromTemplate(parsedCommandLine.wildcardDirectories!)); // TODO: GH#18217
|
||||
project.watchWildcards(new Map(getEntries(parsedCommandLine.wildcardDirectories!))); // TODO: GH#18217
|
||||
}
|
||||
project.enablePluginsWithOptions(compilerOptions, this.currentPluginConfigOverrides);
|
||||
const filesToAdd = parsedCommandLine.fileNames.concat(project.getExternalFiles());
|
||||
@@ -2048,7 +2048,7 @@ namespace ts.server {
|
||||
|
||||
private updateNonInferredProjectFiles<T>(project: ExternalProject | ConfiguredProject | AutoImportProviderProject, files: T[], propertyReader: FilePropertyReader<T>) {
|
||||
const projectRootFilesMap = project.getRootFilesMap();
|
||||
const newRootScriptInfoMap = createMap<true>();
|
||||
const newRootScriptInfoMap = new Map<string, true>();
|
||||
|
||||
for (const f of files) {
|
||||
const newRootFile = propertyReader.getFileName(f);
|
||||
@@ -2772,7 +2772,7 @@ namespace ts.server {
|
||||
* reloadForInfo provides a way to filter out files to reload configured project for
|
||||
*/
|
||||
private reloadConfiguredProjectForFiles<T>(openFiles: ESMap<Path, T>, delayReload: boolean, shouldReloadProjectFor: (openFileValue: T) => boolean, reason: string) {
|
||||
const updatedProjects = createMap<true>();
|
||||
const updatedProjects = new Map<string, true>();
|
||||
// try to reload config file for all open files
|
||||
openFiles.forEach((openFileValue, path) => {
|
||||
// Filter out the files that need to be ignored
|
||||
@@ -3153,7 +3153,7 @@ namespace ts.server {
|
||||
}
|
||||
|
||||
private removeOrphanConfiguredProjects(toRetainConfiguredProjects: readonly ConfiguredProject[] | ConfiguredProject | undefined) {
|
||||
const toRemoveConfiguredProjects = cloneMap(this.configuredProjects);
|
||||
const toRemoveConfiguredProjects = new Map(this.configuredProjects);
|
||||
const markOriginalProjectsAsUsed = (project: Project) => {
|
||||
if (!project.isOrphan() && project.originalConfiguredProjects) {
|
||||
project.originalConfiguredProjects.forEach(
|
||||
@@ -3208,7 +3208,7 @@ namespace ts.server {
|
||||
}
|
||||
|
||||
private removeOrphanScriptInfos() {
|
||||
const toRemoveScriptInfos = cloneMap(this.filenameToScriptInfo);
|
||||
const toRemoveScriptInfos = new Map(this.filenameToScriptInfo);
|
||||
this.filenameToScriptInfo.forEach(info => {
|
||||
// If script info is open or orphan, retain it and its dependencies
|
||||
if (!info.isScriptOpen() && info.isOrphan() && !info.isContainedByAutoImportProvider()) {
|
||||
@@ -3686,7 +3686,7 @@ namespace ts.server {
|
||||
|
||||
// Also save the current configuration to pass on to any projects that are yet to be loaded.
|
||||
// If a plugin is configured twice, only the latest configuration will be remembered.
|
||||
this.currentPluginConfigOverrides = this.currentPluginConfigOverrides || createMap();
|
||||
this.currentPluginConfigOverrides = this.currentPluginConfigOverrides || new Map();
|
||||
this.currentPluginConfigOverrides.set(args.pluginName, args.configuration);
|
||||
}
|
||||
|
||||
@@ -3721,7 +3721,7 @@ namespace ts.server {
|
||||
|
||||
/*@internal*/
|
||||
private watchPackageJsonFile(path: Path) {
|
||||
const watchers = this.packageJsonFilesMap || (this.packageJsonFilesMap = createMap());
|
||||
const watchers = this.packageJsonFilesMap || (this.packageJsonFilesMap = new Map());
|
||||
if (!watchers.has(path)) {
|
||||
this.invalidateProjectAutoImports(path);
|
||||
watchers.set(path, this.watchFactory.watchFile(
|
||||
|
||||
@@ -11,8 +11,8 @@ namespace ts.server {
|
||||
}
|
||||
|
||||
export function createPackageJsonCache(host: ProjectService): PackageJsonCache {
|
||||
const packageJsons = createMap<PackageJsonInfo>();
|
||||
const directoriesWithoutPackageJson = createMap<true>();
|
||||
const packageJsons = new Map<string, PackageJsonInfo>();
|
||||
const directoriesWithoutPackageJson = new Map<string, true>();
|
||||
return {
|
||||
addOrUpdate,
|
||||
forEach: packageJsons.forEach.bind(packageJsons),
|
||||
|
||||
@@ -127,7 +127,7 @@ namespace ts.server {
|
||||
|
||||
export abstract class Project implements LanguageServiceHost, ModuleResolutionHost {
|
||||
private rootFiles: ScriptInfo[] = [];
|
||||
private rootFilesMap = createMap<ProjectRootFile>();
|
||||
private rootFilesMap = new Map<string, ProjectRootFile>();
|
||||
private program: Program | undefined;
|
||||
private externalFiles: SortedReadonlyArray<string> | undefined;
|
||||
private missingFilesMap: ESMap<Path, FileWatcher> | undefined;
|
||||
@@ -1282,7 +1282,7 @@ namespace ts.server {
|
||||
if (this.generatedFilesMap.has(path)) return;
|
||||
}
|
||||
else {
|
||||
this.generatedFilesMap = createMap();
|
||||
this.generatedFilesMap = new Map();
|
||||
}
|
||||
this.generatedFilesMap.set(path, this.createGeneratedFileWatcher(generatedFile));
|
||||
}
|
||||
@@ -1948,7 +1948,7 @@ namespace ts.server {
|
||||
* Otherwise it will create an InferredProject.
|
||||
*/
|
||||
export class ConfiguredProject extends Project {
|
||||
private typeAcquisition!: TypeAcquisition; // TODO: GH#18217
|
||||
private typeAcquisition: TypeAcquisition | undefined;
|
||||
/* @internal */
|
||||
configFileWatcher: FileWatcher | undefined;
|
||||
private directoriesWatchedForWildcards: ESMap<string, WildcardDirectoryWatcher> | undefined;
|
||||
@@ -1960,7 +1960,7 @@ namespace ts.server {
|
||||
pendingReloadReason: string | undefined;
|
||||
|
||||
/* @internal */
|
||||
openFileWatchTriggered = createMap<true>();
|
||||
openFileWatchTriggered = new Map<string, true>();
|
||||
|
||||
/*@internal*/
|
||||
configFileSpecs: ConfigFileSpecs | undefined;
|
||||
@@ -2164,13 +2164,13 @@ namespace ts.server {
|
||||
}
|
||||
|
||||
getTypeAcquisition() {
|
||||
return this.typeAcquisition;
|
||||
return this.typeAcquisition || {};
|
||||
}
|
||||
|
||||
/*@internal*/
|
||||
watchWildcards(wildcardDirectories: ESMap<string, WatchDirectoryFlags>) {
|
||||
updateWatchingWildcardDirectories(
|
||||
this.directoriesWatchedForWildcards || (this.directoriesWatchedForWildcards = createMap()),
|
||||
this.directoriesWatchedForWildcards || (this.directoriesWatchedForWildcards = new Map()),
|
||||
wildcardDirectories,
|
||||
// Create new directory watcher
|
||||
(directory, flags) => this.projectService.watchWildcardDirectory(directory as Path, flags, this),
|
||||
@@ -2282,7 +2282,7 @@ namespace ts.server {
|
||||
*/
|
||||
export class ExternalProject extends Project {
|
||||
excludedFiles: readonly NormalizedPath[] = [];
|
||||
private typeAcquisition!: TypeAcquisition; // TODO: GH#18217
|
||||
private typeAcquisition: TypeAcquisition | undefined;
|
||||
/*@internal*/
|
||||
constructor(public externalProjectName: string,
|
||||
projectService: ProjectService,
|
||||
@@ -2318,7 +2318,7 @@ namespace ts.server {
|
||||
}
|
||||
|
||||
getTypeAcquisition() {
|
||||
return this.typeAcquisition;
|
||||
return this.typeAcquisition || {};
|
||||
}
|
||||
|
||||
setTypeAcquisition(newTypeAcquisition: TypeAcquisition): void {
|
||||
|
||||
@@ -1434,7 +1434,7 @@ namespace ts.server {
|
||||
}
|
||||
|
||||
private toSpanGroups(locations: readonly RenameLocation[]): readonly protocol.SpanGroup[] {
|
||||
const map = createMap<protocol.SpanGroup>();
|
||||
const map = new Map<string, protocol.SpanGroup>();
|
||||
for (const { fileName, textSpan, contextSpan, originalContextSpan: _2, originalTextSpan: _, originalFileName: _1, ...prefixSuffixText } of locations) {
|
||||
let group = map.get(fileName);
|
||||
if (!group) map.set(fileName, group = { file: fileName, locs: [] });
|
||||
@@ -2338,7 +2338,7 @@ namespace ts.server {
|
||||
return { response, responseRequired: true };
|
||||
}
|
||||
|
||||
private handlers = createMapFromTemplate<(request: protocol.Request) => HandlerResponse>({
|
||||
private handlers = new Map(getEntries<(request: protocol.Request) => HandlerResponse>({
|
||||
[CommandNames.Status]: () => {
|
||||
const response: protocol.StatusResponseBody = { version: ts.version }; // eslint-disable-line @typescript-eslint/no-unnecessary-qualifier
|
||||
return this.requiredResponse(response);
|
||||
@@ -2697,7 +2697,7 @@ namespace ts.server {
|
||||
[CommandNames.ProvideCallHierarchyOutgoingCalls]: (request: protocol.ProvideCallHierarchyOutgoingCallsRequest) => {
|
||||
return this.requiredResponse(this.provideCallHierarchyOutgoingCalls(request.arguments));
|
||||
},
|
||||
});
|
||||
}));
|
||||
|
||||
public addProtocolHandler(command: string, handler: (request: protocol.Request) => HandlerResponse) {
|
||||
if (this.handlers.has(command)) {
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace ts.server {
|
||||
if ((arr1 || emptyArray).length === 0 && (arr2 || emptyArray).length === 0) {
|
||||
return true;
|
||||
}
|
||||
const set: ESMap<string, boolean> = createMap<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: ESMap<string, TypingsCacheEntry> = createMap<TypingsCacheEntry>();
|
||||
private readonly perProjectCache = new Map<string, TypingsCacheEntry>();
|
||||
|
||||
constructor(private readonly installer: ITypingsInstaller) {
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* @internal */
|
||||
namespace ts.server {
|
||||
export class ThrottledOperations {
|
||||
private readonly pendingTimeouts: ESMap<string, any> = createMap<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;
|
||||
|
||||
@@ -80,7 +80,7 @@ namespace ts.server {
|
||||
}
|
||||
|
||||
export function createNormalizedPathMap<T>(): NormalizedPathMap<T> {
|
||||
const map = createMap<T>();
|
||||
const map = new Map<string, T>();
|
||||
return {
|
||||
get(path) {
|
||||
return map.get(path);
|
||||
|
||||
@@ -304,7 +304,7 @@ namespace ts.CallHierarchy {
|
||||
}
|
||||
|
||||
function getCallSiteGroupKey(entry: CallSite) {
|
||||
return "" + getNodeId(entry.declaration);
|
||||
return getNodeId(entry.declaration);
|
||||
}
|
||||
|
||||
function createCallHierarchyIncomingCall(from: CallHierarchyItem, fromSpans: TextSpan[]): CallHierarchyIncomingCall {
|
||||
|
||||
@@ -452,7 +452,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
export function getSemanticClassifications(typeChecker: TypeChecker, cancellationToken: CancellationToken, sourceFile: SourceFile, classifiableNames: UnderscoreEscapedMap<true>, span: TextSpan): ClassifiedSpan[] {
|
||||
export function getSemanticClassifications(typeChecker: TypeChecker, cancellationToken: CancellationToken, sourceFile: SourceFile, classifiableNames: ReadonlySet<__String>, span: TextSpan): ClassifiedSpan[] {
|
||||
return convertClassificationsToSpans(getEncodedSemanticClassifications(typeChecker, cancellationToken, sourceFile, classifiableNames, span));
|
||||
}
|
||||
|
||||
@@ -472,12 +472,15 @@ namespace ts {
|
||||
case SyntaxKind.ClassDeclaration:
|
||||
case SyntaxKind.InterfaceDeclaration:
|
||||
case SyntaxKind.FunctionDeclaration:
|
||||
case SyntaxKind.ClassExpression:
|
||||
case SyntaxKind.FunctionExpression:
|
||||
case SyntaxKind.ArrowFunction:
|
||||
cancellationToken.throwIfCancellationRequested();
|
||||
}
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
export function getEncodedSemanticClassifications(typeChecker: TypeChecker, cancellationToken: CancellationToken, sourceFile: SourceFile, classifiableNames: UnderscoreEscapedMap<true>, span: TextSpan): Classifications {
|
||||
export function getEncodedSemanticClassifications(typeChecker: TypeChecker, cancellationToken: CancellationToken, sourceFile: SourceFile, classifiableNames: ReadonlySet<__String>, span: TextSpan): Classifications {
|
||||
const spans: number[] = [];
|
||||
sourceFile.forEachChild(function cb(node: Node): void {
|
||||
// Only walk into nodes that intersect the requested span.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* @internal */
|
||||
namespace ts.codefix {
|
||||
const errorCodeToFixes = createMultiMap<CodeFixRegistration>();
|
||||
const fixIdToRegistration = createMap<CodeFixRegistration>();
|
||||
const fixIdToRegistration = new Map<string, CodeFixRegistration>();
|
||||
|
||||
export type DiagnosticAndArguments = DiagnosticMessage | [DiagnosticMessage, string] | [DiagnosticMessage, string, string];
|
||||
function diagnosticToString(diag: DiagnosticAndArguments): string {
|
||||
|
||||
@@ -16,12 +16,12 @@ namespace ts.codefix {
|
||||
},
|
||||
fixIds: [fixId],
|
||||
getAllCodeActions: context => {
|
||||
const fixedNodes = new NodeSet();
|
||||
const fixedNodes = new Set<Node>();
|
||||
return codeFixAll(context, errorCodes, (changes, diag) => makeChange(changes, diag.file, diag.start, context.program, fixedNodes));
|
||||
},
|
||||
});
|
||||
|
||||
function makeChange(changeTracker: textChanges.ChangeTracker, sourceFile: SourceFile, pos: number, program: Program, fixedNodes?: NodeSet<Node>) {
|
||||
function makeChange(changeTracker: textChanges.ChangeTracker, sourceFile: SourceFile, pos: number, program: Program, fixedNodes?: Set<Node>) {
|
||||
const token = getTokenAtPosition(sourceFile, pos);
|
||||
const forInitializer = findAncestor(token, node =>
|
||||
isForInOrOfStatement(node.parent) ? node.parent.initializer === node :
|
||||
@@ -57,8 +57,8 @@ namespace ts.codefix {
|
||||
}
|
||||
}
|
||||
|
||||
function applyChange(changeTracker: textChanges.ChangeTracker, initializer: Node, sourceFile: SourceFile, fixedNodes?: NodeSet<Node>) {
|
||||
if (!fixedNodes || fixedNodes.tryAdd(initializer)) {
|
||||
function applyChange(changeTracker: textChanges.ChangeTracker, initializer: Node, sourceFile: SourceFile, fixedNodes?: Set<Node>) {
|
||||
if (!fixedNodes || tryAddToSet(fixedNodes, initializer)) {
|
||||
changeTracker.insertModifierBefore(sourceFile, SyntaxKind.ConstKeyword, initializer);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,19 +15,19 @@ namespace ts.codefix {
|
||||
},
|
||||
fixIds: [fixId],
|
||||
getAllCodeActions: context => {
|
||||
const fixedNodes = new NodeSet();
|
||||
const fixedNodes = new Set<Node>();
|
||||
return codeFixAll(context, errorCodes, (changes, diag) => makeChange(changes, diag.file, diag.start, fixedNodes));
|
||||
},
|
||||
});
|
||||
|
||||
function makeChange(changeTracker: textChanges.ChangeTracker, sourceFile: SourceFile, pos: number, fixedNodes?: NodeSet<Node>) {
|
||||
function makeChange(changeTracker: textChanges.ChangeTracker, sourceFile: SourceFile, pos: number, fixedNodes?: Set<Node>) {
|
||||
const token = getTokenAtPosition(sourceFile, pos);
|
||||
if (!isIdentifier(token)) {
|
||||
return;
|
||||
}
|
||||
const declaration = token.parent;
|
||||
if (declaration.kind === SyntaxKind.PropertyDeclaration &&
|
||||
(!fixedNodes || fixedNodes.tryAdd(declaration))) {
|
||||
(!fixedNodes || tryAddToSet(fixedNodes, declaration))) {
|
||||
changeTracker.insertModifierBefore(sourceFile, SyntaxKind.DeclareKeyword, declaration);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ namespace ts.codefix {
|
||||
return;
|
||||
}
|
||||
|
||||
const synthNamesMap: ESMap<string, SynthIdentifier> = createMap();
|
||||
const synthNamesMap = new Map<string, SynthIdentifier>();
|
||||
const isInJavascript = isInJSFile(functionToConvert);
|
||||
const setOfExpressionsToReturn = getAllPromiseExpressionsToReturn(functionToConvert, checker);
|
||||
const functionToConvertRenamed = renameCollidingVarNames(functionToConvert, checker, synthNamesMap, context.sourceFile);
|
||||
@@ -149,7 +149,7 @@ namespace ts.codefix {
|
||||
It then checks for any collisions and renames them through getSynthesizedDeepClone
|
||||
*/
|
||||
function renameCollidingVarNames(nodeToRename: FunctionLikeDeclaration, checker: TypeChecker, synthNamesMap: ESMap<string, SynthIdentifier>, sourceFile: SourceFile): FunctionLikeDeclaration {
|
||||
const identsToRenameMap = createMap<Identifier>(); // key is the symbol id
|
||||
const identsToRenameMap = new Map<string, Identifier>(); // key is the symbol id
|
||||
const collidingSymbolMap = createMultiMap<Symbol>();
|
||||
forEachChild(nodeToRename, function visit(node: Node) {
|
||||
if (!isIdentifier(node)) {
|
||||
|
||||
@@ -63,7 +63,7 @@ namespace ts.codefix {
|
||||
type ExportRenames = ReadonlyESMap<string, string>;
|
||||
|
||||
function collectExportRenames(sourceFile: SourceFile, checker: TypeChecker, identifiers: Identifiers): ExportRenames {
|
||||
const res = createMap<string>();
|
||||
const res = new Map<string, string>();
|
||||
forEachExportReference(sourceFile, node => {
|
||||
const { text, originalKeywordKind } = node.name;
|
||||
if (!res.has(text) && (originalKeywordKind !== undefined && isNonContextualKeyword(originalKeywordKind)
|
||||
@@ -274,9 +274,9 @@ namespace ts.codefix {
|
||||
// `module.exports = require("x");` ==> `export * from "x"; export { default } from "x";`
|
||||
const moduleSpecifier = reExported.text;
|
||||
const moduleSymbol = checker.getSymbolAtLocation(reExported);
|
||||
const exports = moduleSymbol ? moduleSymbol.exports! : emptyUnderscoreEscapedMap;
|
||||
return exports.has("export=" as __String) ? [[reExportDefault(moduleSpecifier)], true] :
|
||||
!exports.has("default" as __String) ? [[reExportStar(moduleSpecifier)], false] :
|
||||
const exports = moduleSymbol ? moduleSymbol.exports! : emptyMap as ReadonlyCollection<__String>;
|
||||
return exports.has(InternalSymbolName.ExportEquals) ? [[reExportDefault(moduleSpecifier)], true] :
|
||||
!exports.has(InternalSymbolName.Default) ? [[reExportStar(moduleSpecifier)], false] :
|
||||
// If there's some non-default export, must include both `export *` and `export default`.
|
||||
exports.size > 1 ? [[reExportStar(moduleSpecifier), reExportDefault(moduleSpecifier)], true] : [[reExportDefault(moduleSpecifier)], true];
|
||||
}
|
||||
@@ -388,7 +388,7 @@ namespace ts.codefix {
|
||||
function convertSingleIdentifierImport(file: SourceFile, name: Identifier, moduleSpecifier: StringLiteralLike, changes: textChanges.ChangeTracker, checker: TypeChecker, identifiers: Identifiers, quotePreference: QuotePreference): readonly Node[] {
|
||||
const nameSymbol = checker.getSymbolAtLocation(name);
|
||||
// Maps from module property name to name actually used. (The same if there isn't shadowing.)
|
||||
const namedBindingsNames = createMap<string>();
|
||||
const namedBindingsNames = new Map<string, string>();
|
||||
// True if there is some non-property use like `x()` or `f(x)`.
|
||||
let needDefaultImport = false;
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace ts.codefix {
|
||||
},
|
||||
fixIds: [fixId],
|
||||
getAllCodeActions: context => {
|
||||
const fixedExportDeclarations = createMap<true>();
|
||||
const fixedExportDeclarations = new Map<string, true>();
|
||||
return codeFixAll(context, errorCodes, (changes, diag) => {
|
||||
const exportSpecifier = getExportSpecifierForDiagnosticSpan(diag, context.sourceFile);
|
||||
if (exportSpecifier && !addToSeen(fixedExportDeclarations, getNodeId(exportSpecifier.parent.parent))) {
|
||||
|
||||
@@ -27,9 +27,9 @@ namespace ts.codefix {
|
||||
getAllCodeActions: context => {
|
||||
const { program } = context;
|
||||
const checker = program.getTypeChecker();
|
||||
const seen = createMap<true>();
|
||||
const seen = new Map<string, true>();
|
||||
|
||||
const typeDeclToMembers = new NodeMap<ClassOrInterface, ClassOrInterfaceInfo[]>();
|
||||
const typeDeclToMembers = new Map<ClassOrInterface, ClassOrInterfaceInfo[]>();
|
||||
|
||||
return createCombinedCodeActions(textChanges.ChangeTracker.with(context, changes => {
|
||||
eachDiagnostic(context, errorCodes, diag => {
|
||||
@@ -44,7 +44,7 @@ namespace ts.codefix {
|
||||
}
|
||||
else {
|
||||
const { parentDeclaration, token } = info;
|
||||
const infos = typeDeclToMembers.getOrUpdate(parentDeclaration, () => []);
|
||||
const infos = getOrUpdate(typeDeclToMembers, parentDeclaration, () => []);
|
||||
if (!infos.some(i => i.token.text === token.text)) infos.push(info);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace ts.codefix {
|
||||
},
|
||||
fixIds: [fixId],
|
||||
getAllCodeActions: context => {
|
||||
const seen = createMap<true>();
|
||||
const seen = new Map<string, true>();
|
||||
return codeFixAll(context, errorCodes, (changes, diag) => {
|
||||
const nodes = getNodes(diag.file, diag.start);
|
||||
if (!nodes || !addToSeen(seen, getNodeId(nodes.insertBefore))) return;
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace ts.codefix {
|
||||
},
|
||||
fixIds: [fixId],
|
||||
getAllCodeActions: context => {
|
||||
const seenClassDeclarations = createMap<true>();
|
||||
const seenClassDeclarations = new Map<string, true>();
|
||||
return codeFixAll(context, errorCodes, (changes, diag) => {
|
||||
const classDeclaration = getClass(diag.file, diag.start);
|
||||
if (addToSeen(seenClassDeclarations, getNodeId(classDeclaration))) {
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace ts.codefix {
|
||||
},
|
||||
fixIds: [fixId],
|
||||
getAllCodeActions(context) {
|
||||
const seenClassDeclarations = createMap<true>();
|
||||
const seenClassDeclarations = new Map<string, true>();
|
||||
return codeFixAll(context, errorCodes, (changes, diag) => {
|
||||
const classDeclaration = getClass(diag.file, diag.start);
|
||||
if (addToSeen(seenClassDeclarations, getNodeId(classDeclaration))) {
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace ts.codefix {
|
||||
fixIds: [fixId],
|
||||
getAllCodeActions(context) {
|
||||
const { sourceFile } = context;
|
||||
const seenClasses = createMap<true>(); // Ensure we only do this once per class.
|
||||
const seenClasses = new Map<string, true>(); // Ensure we only do this once per class.
|
||||
return codeFixAll(context, errorCodes, (changes, diag) => {
|
||||
const nodes = getNodes(diag.file, diag.start);
|
||||
if (!nodes) return;
|
||||
|
||||
@@ -52,10 +52,5 @@ namespace ts.codefix {
|
||||
return [Diagnostics.Convert_function_declaration_0_to_arrow_function, name!.text];
|
||||
}
|
||||
}
|
||||
// No outer 'this', add a @class tag if in a JS constructor function
|
||||
else if (isSourceFileJS(sourceFile) && isPropertyAccessExpression(token.parent) && isAssignmentExpression(token.parent.parent)) {
|
||||
addJSDocTags(changes, sourceFile, fn, [factory.createJSDocClassTag(/*tagName*/ undefined)]);
|
||||
return Diagnostics.Add_class_tag;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -164,7 +164,7 @@ namespace ts.codefix {
|
||||
const program = context.program;
|
||||
const checker = program.getTypeChecker();
|
||||
const scriptTarget = getEmitScriptTarget(program.getCompilerOptions());
|
||||
const flags = NodeBuilderFlags.NoTruncation | NodeBuilderFlags.SuppressAnyReturnType | (quotePreference === QuotePreference.Single ? NodeBuilderFlags.UseSingleQuotesForStringLiteralType : 0);
|
||||
const flags = NodeBuilderFlags.NoTruncation | NodeBuilderFlags.NoUndefinedOptionalParameterType | NodeBuilderFlags.SuppressAnyReturnType | (quotePreference === QuotePreference.Single ? NodeBuilderFlags.UseSingleQuotesForStringLiteralType : 0);
|
||||
const signatureDeclaration = <MethodDeclaration>checker.signatureToSignatureDeclaration(signature, SyntaxKind.MethodDeclaration, enclosingDeclaration, flags, getNoopSymbolTrackerWithResolver(context));
|
||||
if (!signatureDeclaration) {
|
||||
return undefined;
|
||||
|
||||
@@ -47,8 +47,8 @@ namespace ts.codefix {
|
||||
const addToNamespace: FixUseNamespaceImport[] = [];
|
||||
const importType: FixUseImportType[] = [];
|
||||
// Keys are import clause node IDs.
|
||||
const addToExisting = createMap<{ readonly importClauseOrBindingPattern: ImportClause | ObjectBindingPattern, defaultImport: string | undefined; readonly namedImports: string[], canUseTypeOnlyImport: boolean }>();
|
||||
const newImports = createMap<Mutable<ImportsCollection & { useRequire: boolean }>>();
|
||||
const addToExisting = new Map<string, { readonly importClauseOrBindingPattern: ImportClause | ObjectBindingPattern, defaultImport: string | undefined; readonly namedImports: string[], canUseTypeOnlyImport: boolean }>();
|
||||
const newImports = new Map<string, Mutable<ImportsCollection & { useRequire: boolean }>>();
|
||||
return { addImportFromDiagnostic, addImportFromExportedSymbol, writeFixes };
|
||||
|
||||
function addImportFromDiagnostic(diagnostic: DiagnosticWithLocation, context: CodeFixContextBase) {
|
||||
@@ -138,7 +138,7 @@ namespace ts.codefix {
|
||||
doAddExistingFix(changeTracker, sourceFile, importClauseOrBindingPattern, defaultImport, namedImports, canUseTypeOnlyImport);
|
||||
});
|
||||
|
||||
let newDeclarations: Statement | readonly Statement[] | undefined;
|
||||
let newDeclarations: AnyImportOrRequireStatement | readonly AnyImportOrRequireStatement[] | undefined;
|
||||
newImports.forEach(({ useRequire, ...imports }, moduleSpecifier) => {
|
||||
const getDeclarations = useRequire ? getNewRequires : getNewImports;
|
||||
newDeclarations = combine(newDeclarations, getDeclarations(moduleSpecifier, quotePreference, imports));
|
||||
@@ -671,15 +671,35 @@ namespace ts.codefix {
|
||||
}
|
||||
|
||||
if (namedImports.length) {
|
||||
const specifiers = namedImports.map(name => factory.createImportSpecifier(/*propertyName*/ undefined, factory.createIdentifier(name)));
|
||||
if (clause.namedBindings && cast(clause.namedBindings, isNamedImports).elements.length) {
|
||||
for (const spec of specifiers) {
|
||||
changes.insertNodeInListAfter(sourceFile, last(cast(clause.namedBindings, isNamedImports).elements), spec);
|
||||
const existingSpecifiers = clause.namedBindings && cast(clause.namedBindings, isNamedImports).elements;
|
||||
const newSpecifiers = stableSort(
|
||||
namedImports.map(name => factory.createImportSpecifier(/*propertyName*/ undefined, factory.createIdentifier(name))),
|
||||
OrganizeImports.compareImportOrExportSpecifiers);
|
||||
|
||||
if (existingSpecifiers?.length && OrganizeImports.importSpecifiersAreSorted(existingSpecifiers)) {
|
||||
for (const spec of newSpecifiers) {
|
||||
const insertionIndex = OrganizeImports.getImportSpecifierInsertionIndex(existingSpecifiers, spec);
|
||||
const prevSpecifier = (clause.namedBindings as NamedImports).elements[insertionIndex - 1];
|
||||
if (prevSpecifier) {
|
||||
changes.insertNodeInListAfter(sourceFile, prevSpecifier, spec);
|
||||
}
|
||||
else {
|
||||
changes.insertNodeBefore(
|
||||
sourceFile,
|
||||
existingSpecifiers[0],
|
||||
spec,
|
||||
!positionsAreOnSameLine(existingSpecifiers[0].getStart(), clause.parent.getStart(), sourceFile));
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (existingSpecifiers?.length) {
|
||||
for (const spec of newSpecifiers) {
|
||||
changes.insertNodeAtEndOfList(sourceFile, existingSpecifiers, spec);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (specifiers.length) {
|
||||
const namedImports = factory.createNamedImports(specifiers);
|
||||
if (newSpecifiers.length) {
|
||||
const namedImports = factory.createNamedImports(newSpecifiers);
|
||||
if (clause.namedBindings) {
|
||||
changes.replaceNode(sourceFile, clause.namedBindings, namedImports);
|
||||
}
|
||||
@@ -727,9 +747,9 @@ namespace ts.codefix {
|
||||
readonly name: string;
|
||||
};
|
||||
}
|
||||
function getNewImports(moduleSpecifier: string, quotePreference: QuotePreference, imports: ImportsCollection): Statement | readonly Statement[] {
|
||||
function getNewImports(moduleSpecifier: string, quotePreference: QuotePreference, imports: ImportsCollection): AnyImportSyntax | readonly AnyImportSyntax[] {
|
||||
const quotedModuleSpecifier = makeStringLiteral(moduleSpecifier, quotePreference);
|
||||
let statements: Statement | readonly Statement[] | undefined;
|
||||
let statements: AnyImportSyntax | readonly AnyImportSyntax[] | undefined;
|
||||
if (imports.defaultImport !== undefined || imports.namedImports?.length) {
|
||||
statements = combine(statements, makeImport(
|
||||
imports.defaultImport === undefined ? undefined : factory.createIdentifier(imports.defaultImport),
|
||||
@@ -756,9 +776,9 @@ namespace ts.codefix {
|
||||
return Debug.checkDefined(statements);
|
||||
}
|
||||
|
||||
function getNewRequires(moduleSpecifier: string, quotePreference: QuotePreference, imports: ImportsCollection): Statement | readonly Statement[] {
|
||||
function getNewRequires(moduleSpecifier: string, quotePreference: QuotePreference, imports: ImportsCollection): RequireVariableStatement | readonly RequireVariableStatement[] {
|
||||
const quotedModuleSpecifier = makeStringLiteral(moduleSpecifier, quotePreference);
|
||||
let statements: Statement | readonly Statement[] | undefined;
|
||||
let statements: RequireVariableStatement | readonly RequireVariableStatement[] | undefined;
|
||||
// const { default: foo, bar, etc } = require('./mod');
|
||||
if (imports.defaultImport || imports.namedImports?.length) {
|
||||
const bindingElements = imports.namedImports?.map(name => factory.createBindingElement(/*dotDotDotToken*/ undefined, /*propertyName*/ undefined, name)) || [];
|
||||
@@ -776,7 +796,7 @@ namespace ts.codefix {
|
||||
return Debug.checkDefined(statements);
|
||||
}
|
||||
|
||||
function createConstEqualsRequireDeclaration(name: string | ObjectBindingPattern, quotedModuleSpecifier: StringLiteral): VariableStatement {
|
||||
function createConstEqualsRequireDeclaration(name: string | ObjectBindingPattern, quotedModuleSpecifier: StringLiteral): RequireVariableStatement {
|
||||
return factory.createVariableStatement(
|
||||
/*modifiers*/ undefined,
|
||||
factory.createVariableDeclarationList([
|
||||
@@ -785,7 +805,7 @@ namespace ts.codefix {
|
||||
/*exclamationToken*/ undefined,
|
||||
/*type*/ undefined,
|
||||
factory.createCallExpression(factory.createIdentifier("require"), /*typeArguments*/ undefined, [quotedModuleSpecifier]))],
|
||||
NodeFlags.Const));
|
||||
NodeFlags.Const)) as RequireVariableStatement;
|
||||
}
|
||||
|
||||
function symbolHasMeaning({ declarations }: Symbol, meaning: SemanticMeaning): boolean {
|
||||
|
||||
@@ -500,7 +500,7 @@ namespace ts.codefix {
|
||||
}
|
||||
|
||||
function combineUsages(usages: Usage[]): Usage {
|
||||
const combinedProperties = createUnderscoreEscapedMap<Usage[]>();
|
||||
const combinedProperties = new Map<__String, Usage[]>();
|
||||
for (const u of usages) {
|
||||
if (u.properties) {
|
||||
u.properties.forEach((p, name) => {
|
||||
@@ -511,7 +511,7 @@ namespace ts.codefix {
|
||||
});
|
||||
}
|
||||
}
|
||||
const properties = createUnderscoreEscapedMap<Usage>();
|
||||
const properties = new Map<__String, Usage>();
|
||||
combinedProperties.forEach((ps, name) => {
|
||||
properties.set(name, combineUsages(ps));
|
||||
});
|
||||
@@ -820,7 +820,7 @@ namespace ts.codefix {
|
||||
function inferTypeFromPropertyAccessExpression(parent: PropertyAccessExpression, usage: Usage): void {
|
||||
const name = escapeLeadingUnderscores(parent.name.text);
|
||||
if (!usage.properties) {
|
||||
usage.properties = createUnderscoreEscapedMap<Usage>();
|
||||
usage.properties = new Map();
|
||||
}
|
||||
const propertyUsage = usage.properties.get(name) || createEmptyUsage();
|
||||
calculateUsageOfNode(parent, propertyUsage);
|
||||
@@ -974,7 +974,7 @@ namespace ts.codefix {
|
||||
}
|
||||
|
||||
function inferStructuralType(usage: Usage) {
|
||||
const members = createUnderscoreEscapedMap<Symbol>();
|
||||
const members = new Map<__String, Symbol>();
|
||||
if (usage.properties) {
|
||||
usage.properties.forEach((u, name) => {
|
||||
const symbol = checker.createSymbol(SymbolFlags.Property, name);
|
||||
|
||||
+21
-19
@@ -293,7 +293,7 @@ namespace ts.Completions {
|
||||
}
|
||||
|
||||
if (keywordFilters !== KeywordCompletionFilters.None) {
|
||||
const entryNames = arrayToSet(entries, e => e.name);
|
||||
const entryNames = new Set(entries.map(e => e.name));
|
||||
for (const keywordEntry of getKeywordCompletions(keywordFilters, !insideJsDocTagTypeExpression && isSourceFileJS(sourceFile))) {
|
||||
if (!entryNames.has(keywordEntry.name)) {
|
||||
entries.push(keywordEntry);
|
||||
@@ -491,7 +491,7 @@ namespace ts.Completions {
|
||||
// Value is set to false for global variables or completions from external module exports, because we can have multiple of those;
|
||||
// true otherwise. Based on the order we add things we will always see locals first, then globals, then module exports.
|
||||
// So adding a completion for a local will prevent us from adding completions for external module exports sharing the same name.
|
||||
const uniques = createMap<boolean>();
|
||||
const uniques = new Map<string, boolean>();
|
||||
for (const symbol of symbols) {
|
||||
const origin = symbolToOriginInfoMap ? symbolToOriginInfoMap[getSymbolId(symbol)] : undefined;
|
||||
const info = getCompletionEntryDisplayNameForSymbol(symbol, target, origin, kind, !!jsxIdentifierExpected);
|
||||
@@ -549,7 +549,7 @@ namespace ts.Completions {
|
||||
|
||||
function getLabelStatementCompletions(node: Node): CompletionEntry[] {
|
||||
const entries: CompletionEntry[] = [];
|
||||
const uniques = createMap<true>();
|
||||
const uniques = new Map<string, true>();
|
||||
let current = node;
|
||||
|
||||
while (current) {
|
||||
@@ -1537,7 +1537,7 @@ namespace ts.Completions {
|
||||
}
|
||||
|
||||
/** True if symbol is a type or a module containing at least one type. */
|
||||
function symbolCanBeReferencedAtTypeLocation(symbol: Symbol, seenModules = createMap<true>()): boolean {
|
||||
function symbolCanBeReferencedAtTypeLocation(symbol: Symbol, seenModules = new Map<string, true>()): boolean {
|
||||
const sym = skipAlias(symbol.exportSymbol || symbol, typeChecker);
|
||||
return !!(sym.flags & SymbolFlags.Type) ||
|
||||
!!(sym.flags & SymbolFlags.Module) &&
|
||||
@@ -1605,16 +1605,16 @@ namespace ts.Completions {
|
||||
|
||||
const startTime = timestamp();
|
||||
log(`getSymbolsFromOtherSourceFileExports: Recomputing list${detailsEntryId ? " for details entry" : ""}`);
|
||||
const seenResolvedModules = createMap<true>();
|
||||
const seenExports = createMap<true>();
|
||||
const seenResolvedModules = new Map<string, true>();
|
||||
const seenExports = new Map<string, true>();
|
||||
/** Bucket B */
|
||||
const aliasesToAlreadyIncludedSymbols = createMap<true>();
|
||||
const aliasesToAlreadyIncludedSymbols = new Map<string, true>();
|
||||
/** Bucket C */
|
||||
const aliasesToReturnIfOriginalsAreMissing = createMap<{ alias: Symbol, moduleSymbol: Symbol, isFromPackageJson: boolean }>();
|
||||
const aliasesToReturnIfOriginalsAreMissing = new Map<string, { alias: Symbol, moduleSymbol: Symbol, isFromPackageJson: boolean }>();
|
||||
/** Bucket A */
|
||||
const results: AutoImportSuggestion[] = [];
|
||||
/** Ids present in `results` for faster lookup */
|
||||
const resultSymbolIds = createMap<true>();
|
||||
const resultSymbolIds = new Map<string, true>();
|
||||
|
||||
codefix.forEachExternalModuleToImportFrom(program, host, sourceFile, !detailsEntryId, /*useAutoImportProvider*/ true, (moduleSymbol, _, program, isFromPackageJson) => {
|
||||
// Perf -- ignore other modules if this is a request for details
|
||||
@@ -1940,8 +1940,8 @@ namespace ts.Completions {
|
||||
completionKind = CompletionKind.MemberLike;
|
||||
isNewIdentifierLocation = false;
|
||||
const exports = typeChecker.getExportsAndPropertiesOfModule(moduleSpecifierSymbol);
|
||||
const existing = arrayToSet<ImportOrExportSpecifier>(namedImportsOrExports.elements, n => isCurrentlyEditingNode(n) ? undefined : (n.propertyName || n.name).escapedText);
|
||||
symbols = exports.filter(e => e.escapedName !== InternalSymbolName.Default && !existing.get(e.escapedName));
|
||||
const existing = new Set((namedImportsOrExports.elements as NodeArray<ImportOrExportSpecifier>).filter(n => !isCurrentlyEditingNode(n)).map(n => (n.propertyName || n.name).escapedText));
|
||||
symbols = exports.filter(e => e.escapedName !== InternalSymbolName.Default && !existing.has(e.escapedName));
|
||||
return GlobalsSearch.Success;
|
||||
}
|
||||
|
||||
@@ -2312,7 +2312,7 @@ namespace ts.Completions {
|
||||
}
|
||||
|
||||
const membersDeclaredBySpreadAssignment = new Set<string>();
|
||||
const existingMemberNames = createUnderscoreEscapedMap<boolean>();
|
||||
const existingMemberNames = new Set<__String>();
|
||||
for (const m of existingMembers) {
|
||||
// Ignore omitted expressions for missing members
|
||||
if (m.kind !== SyntaxKind.PropertyAssignment &&
|
||||
@@ -2349,10 +2349,12 @@ namespace ts.Completions {
|
||||
existingName = name && isPropertyNameLiteral(name) ? getEscapedTextOfIdentifierOrLiteral(name) : undefined;
|
||||
}
|
||||
|
||||
existingMemberNames.set(existingName!, true); // TODO: GH#18217
|
||||
if (existingName !== undefined) {
|
||||
existingMemberNames.add(existingName);
|
||||
}
|
||||
}
|
||||
|
||||
const filteredSymbols = contextualMemberSymbols.filter(m => !existingMemberNames.get(m.escapedName));
|
||||
const filteredSymbols = contextualMemberSymbols.filter(m => !existingMemberNames.has(m.escapedName));
|
||||
setSortTextToMemberDeclaredBySpreadAssignment(membersDeclaredBySpreadAssignment, filteredSymbols);
|
||||
|
||||
return filteredSymbols;
|
||||
@@ -2397,7 +2399,7 @@ namespace ts.Completions {
|
||||
* @returns Symbols to be suggested in an class element depending on existing memebers and symbol flags
|
||||
*/
|
||||
function filterClassMembersList(baseSymbols: readonly Symbol[], existingMembers: readonly ClassElement[], currentClassElementModifierFlags: ModifierFlags): Symbol[] {
|
||||
const existingMemberNames = createUnderscoreEscapedMap<true>();
|
||||
const existingMemberNames = new Set<__String>();
|
||||
for (const m of existingMembers) {
|
||||
// Ignore omitted expressions for missing members
|
||||
if (m.kind !== SyntaxKind.PropertyDeclaration &&
|
||||
@@ -2424,7 +2426,7 @@ namespace ts.Completions {
|
||||
|
||||
const existingName = getPropertyNameForPropertyNameNode(m.name!);
|
||||
if (existingName) {
|
||||
existingMemberNames.set(existingName, true);
|
||||
existingMemberNames.add(existingName);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2442,7 +2444,7 @@ namespace ts.Completions {
|
||||
* do not occur at the current position and have not otherwise been typed.
|
||||
*/
|
||||
function filterJsxAttributes(symbols: Symbol[], attributes: NodeArray<JsxAttribute | JsxSpreadAttribute>): Symbol[] {
|
||||
const seenNames = createUnderscoreEscapedMap<boolean>();
|
||||
const seenNames = new Set<__String>();
|
||||
const membersDeclaredBySpreadAssignment = new Set<string>();
|
||||
for (const attr of attributes) {
|
||||
// If this is the current item we are editing right now, do not filter it out
|
||||
@@ -2451,13 +2453,13 @@ namespace ts.Completions {
|
||||
}
|
||||
|
||||
if (attr.kind === SyntaxKind.JsxAttribute) {
|
||||
seenNames.set(attr.name.escapedText, true);
|
||||
seenNames.add(attr.name.escapedText);
|
||||
}
|
||||
else if (isJsxSpreadAttribute(attr)) {
|
||||
setMembersDeclaredBySpreadAssignment(attr, membersDeclaredBySpreadAssignment);
|
||||
}
|
||||
}
|
||||
const filteredSymbols = symbols.filter(a => !seenNames.get(a.escapedName));
|
||||
const filteredSymbols = symbols.filter(a => !seenNames.has(a.escapedName));
|
||||
|
||||
setSortTextToMemberDeclaredBySpreadAssignment(membersDeclaredBySpreadAssignment, filteredSymbols);
|
||||
|
||||
|
||||
@@ -170,7 +170,7 @@ namespace ts {
|
||||
acquiring: boolean,
|
||||
scriptKind?: ScriptKind): SourceFile {
|
||||
|
||||
const bucket = getOrUpdate<ESMap<Path, DocumentRegistryEntry>>(buckets, key, createMap);
|
||||
const bucket = getOrUpdate(buckets, key, () => new Map<Path, DocumentRegistryEntry>());
|
||||
let entry = bucket.get(path);
|
||||
const scriptTarget = scriptKind === ScriptKind.JSON ? ScriptTarget.JSON : compilationSettings.target || ScriptTarget.ES5;
|
||||
if (!entry && externalCache) {
|
||||
|
||||
@@ -132,6 +132,7 @@ namespace ts.FindAllReferences {
|
||||
return node.parent.parent;
|
||||
|
||||
case SyntaxKind.ImportClause:
|
||||
case SyntaxKind.NamespaceExport:
|
||||
return node.parent;
|
||||
|
||||
case SyntaxKind.BinaryExpression:
|
||||
@@ -229,7 +230,7 @@ namespace ts.FindAllReferences {
|
||||
}
|
||||
else {
|
||||
const queue = entries && [...entries];
|
||||
const seenNodes = createMap<true>();
|
||||
const seenNodes = new Map<string, true>();
|
||||
while (queue && queue.length) {
|
||||
const entry = queue.shift() as NodeEntry;
|
||||
if (!addToSeen(seenNodes, getNodeId(entry.node))) {
|
||||
@@ -402,7 +403,7 @@ namespace ts.FindAllReferences {
|
||||
const parent = node.parent;
|
||||
const name = originalNode.text;
|
||||
const isShorthandAssignment = isShorthandPropertyAssignment(parent);
|
||||
if (isShorthandAssignment || isObjectBindingElementWithoutPropertyName(parent) && parent.name === node) {
|
||||
if (isShorthandAssignment || (isObjectBindingElementWithoutPropertyName(parent) && parent.name === node && parent.dotDotDotToken === undefined)) {
|
||||
const prefixColon: PrefixAndSuffix = { prefixText: name + ": " };
|
||||
const suffixColon: PrefixAndSuffix = { suffixText: ": " + name };
|
||||
if (kind === EntryKind.SearchedLocalFoundProperty) {
|
||||
@@ -946,7 +947,7 @@ namespace ts.FindAllReferences {
|
||||
*/
|
||||
class State {
|
||||
/** Cache for `explicitlyinheritsFrom`. */
|
||||
readonly inheritsFromCache = createMap<boolean>();
|
||||
readonly inheritsFromCache = new Map<string, boolean>();
|
||||
|
||||
/**
|
||||
* Type nodes can contain multiple references to the same type. For example:
|
||||
@@ -1906,13 +1907,28 @@ namespace ts.FindAllReferences {
|
||||
function populateSearchSymbolSet(symbol: Symbol, location: Node, checker: TypeChecker, isForRename: boolean, providePrefixAndSuffixText: boolean, implementations: boolean): Symbol[] {
|
||||
const result: Symbol[] = [];
|
||||
forEachRelatedSymbol<void>(symbol, location, checker, isForRename, !(isForRename && providePrefixAndSuffixText),
|
||||
(sym, root, base) => { result.push(base || root || sym); },
|
||||
/*allowBaseTypes*/ () => !implementations);
|
||||
(sym, root, base) => {
|
||||
// static method/property and instance method/property might have the same name. Only include static or only include instance.
|
||||
if (base) {
|
||||
if (isStatic(symbol) !== isStatic(base)) {
|
||||
base = undefined;
|
||||
}
|
||||
}
|
||||
result.push(base || root || sym);
|
||||
},
|
||||
// when try to find implementation, implementations is true, and not allowed to find base class
|
||||
/*allowBaseTypes*/() => !implementations);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param allowBaseTypes return true means it would try to find in base class or interface.
|
||||
*/
|
||||
function forEachRelatedSymbol<T>(
|
||||
symbol: Symbol, location: Node, checker: TypeChecker, isForRenamePopulateSearchSymbolSet: boolean, onlyIncludeBindingElementAtReferenceLocation: boolean,
|
||||
/**
|
||||
* @param baseSymbol This symbol means one property/mehtod from base class or interface when it is not null or undefined,
|
||||
*/
|
||||
cbSymbol: (symbol: Symbol, rootSymbol?: Symbol, baseSymbol?: Symbol, kind?: NodeEntryKind) => T | undefined,
|
||||
allowBaseTypes: (rootSymbol: Symbol) => boolean,
|
||||
): T | undefined {
|
||||
@@ -2031,16 +2047,33 @@ namespace ts.FindAllReferences {
|
||||
readonly symbol: Symbol;
|
||||
readonly kind: NodeEntryKind | undefined;
|
||||
}
|
||||
|
||||
function isStatic(symbol: Symbol): boolean {
|
||||
if (!symbol.valueDeclaration) { return false; }
|
||||
const modifierFlags = getEffectiveModifierFlags(symbol.valueDeclaration);
|
||||
return !!(modifierFlags & ModifierFlags.Static);
|
||||
}
|
||||
|
||||
function getRelatedSymbol(search: Search, referenceSymbol: Symbol, referenceLocation: Node, state: State): RelatedSymbol | undefined {
|
||||
const { checker } = state;
|
||||
return forEachRelatedSymbol(referenceSymbol, referenceLocation, checker, /*isForRenamePopulateSearchSymbolSet*/ false,
|
||||
/*onlyIncludeBindingElementAtReferenceLocation*/ state.options.use !== FindReferencesUse.Rename || !!state.options.providePrefixAndSuffixTextForRename,
|
||||
(sym, rootSymbol, baseSymbol, kind): RelatedSymbol | undefined => search.includes(baseSymbol || rootSymbol || sym)
|
||||
// For a base type, use the symbol for the derived type. For a synthetic (e.g. union) property, use the union symbol.
|
||||
? { symbol: rootSymbol && !(getCheckFlags(sym) & CheckFlags.Synthetic) ? rootSymbol : sym, kind }
|
||||
: undefined,
|
||||
(sym, rootSymbol, baseSymbol, kind): RelatedSymbol | undefined => {
|
||||
// check whether the symbol used to search itself is just the searched one.
|
||||
if (baseSymbol) {
|
||||
// static method/property and instance method/property might have the same name. Only check static or only check instance.
|
||||
if (isStatic(referenceSymbol) !== isStatic(baseSymbol)) {
|
||||
baseSymbol = undefined;
|
||||
}
|
||||
}
|
||||
return search.includes(baseSymbol || rootSymbol || sym)
|
||||
// For a base type, use the symbol for the derived type. For a synthetic (e.g. union) property, use the union symbol.
|
||||
? { symbol: rootSymbol && !(getCheckFlags(sym) & CheckFlags.Synthetic) ? rootSymbol : sym, kind }
|
||||
: undefined;
|
||||
},
|
||||
/*allowBaseTypes*/ rootSymbol =>
|
||||
!(search.parents && !search.parents.some(parent => explicitlyInheritsFrom(rootSymbol.parent!, parent, state.inheritsFromCache, checker))));
|
||||
!(search.parents && !search.parents.some(parent => explicitlyInheritsFrom(rootSymbol.parent!, parent, state.inheritsFromCache, checker)))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -52,7 +52,7 @@ namespace ts.formatting {
|
||||
|
||||
rule("NotSpaceBeforeColon", anyToken, SyntaxKind.ColonToken, [isNonJsxSameLineTokenContext, isNotBinaryOpContext, isNotTypeAnnotationContext], RuleAction.DeleteSpace),
|
||||
rule("SpaceAfterColon", SyntaxKind.ColonToken, anyToken, [isNonJsxSameLineTokenContext, isNotBinaryOpContext], RuleAction.InsertSpace),
|
||||
rule("NoSpaceBeforeQuestionMark", anyToken, SyntaxKind.QuestionToken, [isNonJsxSameLineTokenContext, isNotBinaryOpContext], RuleAction.DeleteSpace),
|
||||
rule("NoSpaceBeforeQuestionMark", anyToken, SyntaxKind.QuestionToken, [isNonJsxSameLineTokenContext, isNotBinaryOpContext, isNotTypeAnnotationContext], RuleAction.DeleteSpace),
|
||||
// insert space after '?' only when it is used in conditional operator
|
||||
rule("SpaceAfterQuestionMarkInConditionalOperator", SyntaxKind.QuestionToken, anyToken, [isNonJsxSameLineTokenContext, isConditionalOperatorContext], RuleAction.InsertSpace),
|
||||
|
||||
@@ -315,8 +315,9 @@ namespace ts.formatting {
|
||||
rule("SpaceAfterTypeAssertion", SyntaxKind.GreaterThanToken, anyToken, [isOptionEnabled("insertSpaceAfterTypeAssertion"), isNonJsxSameLineTokenContext, isTypeAssertionContext], RuleAction.InsertSpace),
|
||||
rule("NoSpaceAfterTypeAssertion", SyntaxKind.GreaterThanToken, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterTypeAssertion"), isNonJsxSameLineTokenContext, isTypeAssertionContext], RuleAction.DeleteSpace),
|
||||
|
||||
rule("SpaceBeforeTypeAnnotation", anyToken, SyntaxKind.ColonToken, [isOptionEnabled("insertSpaceBeforeTypeAnnotation"), isNonJsxSameLineTokenContext, isTypeAnnotationContext], RuleAction.InsertSpace),
|
||||
rule("NoSpaceBeforeTypeAnnotation", anyToken, SyntaxKind.ColonToken, [isOptionDisabledOrUndefined("insertSpaceBeforeTypeAnnotation"), isNonJsxSameLineTokenContext, isTypeAnnotationContext], RuleAction.DeleteSpace),
|
||||
rule("SpaceBeforeTypeAnnotation", anyToken, [SyntaxKind.QuestionToken, SyntaxKind.ColonToken], [isOptionEnabled("insertSpaceBeforeTypeAnnotation"), isNonJsxSameLineTokenContext, isTypeAnnotationContext], RuleAction.InsertSpace),
|
||||
rule("NoSpaceBeforeTypeAnnotation", anyToken, [SyntaxKind.QuestionToken, SyntaxKind.ColonToken], [isOptionDisabledOrUndefined("insertSpaceBeforeTypeAnnotation"), isNonJsxSameLineTokenContext, isTypeAnnotationContext], RuleAction.DeleteSpace),
|
||||
|
||||
rule("NoOptionalSemicolon", SyntaxKind.SemicolonToken, anyTokenIncludingEOF, [optionEquals("semicolons", SemicolonPreference.Remove), isSemicolonDeletionContext], RuleAction.DeleteToken),
|
||||
rule("OptionalSemicolon", anyToken, anyTokenIncludingEOF, [optionEquals("semicolons", SemicolonPreference.Insert), isSemicolonInsertionContext], RuleAction.InsertTrailingSemicolon),
|
||||
];
|
||||
|
||||
@@ -122,6 +122,10 @@ namespace ts.FindAllReferences {
|
||||
// This is `export * from "foo"`, so imports of this module may import the export too.
|
||||
handleDirectImports(getContainingModuleSymbol(direct, checker));
|
||||
}
|
||||
else if (direct.exportClause.kind === SyntaxKind.NamespaceExport) {
|
||||
// `export * as foo from "foo"` add to indirect uses
|
||||
addIndirectUsers(getSourceFileLikeForImportDeclaration(direct));
|
||||
}
|
||||
else {
|
||||
// This is `export { foo } from "foo"` and creates an alias symbol, so recursive search will get handle re-exports.
|
||||
directImports.push(direct);
|
||||
@@ -369,7 +373,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): ESMap<string, ImporterOrCallExpression[]> {
|
||||
const map = createMap<ImporterOrCallExpression[]>();
|
||||
const map = new Map<string, ImporterOrCallExpression[]>();
|
||||
|
||||
for (const sourceFile of sourceFiles) {
|
||||
if (cancellationToken) cancellationToken.throwIfCancellationRequested();
|
||||
@@ -477,6 +481,9 @@ namespace ts.FindAllReferences {
|
||||
return exportInfo(symbol, getExportKindForDeclaration(exportNode));
|
||||
}
|
||||
}
|
||||
else if (isNamespaceExport(parent)) {
|
||||
return exportInfo(symbol, ExportKind.Named);
|
||||
}
|
||||
// If we are in `export = a;` or `export default a;`, `parent` is the export assignment.
|
||||
else if (isExportAssignment(parent)) {
|
||||
return getExportAssignmentExport(parent);
|
||||
|
||||
@@ -128,7 +128,7 @@ namespace ts.NavigationBar {
|
||||
|
||||
function addTrackedEs5Class(name: string) {
|
||||
if (!trackedEs5Classes) {
|
||||
trackedEs5Classes = createMap();
|
||||
trackedEs5Classes = new Map();
|
||||
}
|
||||
trackedEs5Classes.set(name, true);
|
||||
}
|
||||
@@ -443,7 +443,7 @@ namespace ts.NavigationBar {
|
||||
|
||||
/** Merge declarations of the same kind. */
|
||||
function mergeChildren(children: NavigationBarNode[], node: NavigationBarNode): void {
|
||||
const nameToItems = createMap<NavigationBarNode | NavigationBarNode[]>();
|
||||
const nameToItems = new Map<string, NavigationBarNode | NavigationBarNode[]>();
|
||||
filterMutate(children, (child, index) => {
|
||||
const declName = child.name || getNameOfDeclaration(<Declaration>child.node);
|
||||
const name = declName && nodeText(declName);
|
||||
|
||||
@@ -17,7 +17,9 @@ namespace ts.OrganizeImports {
|
||||
|
||||
const changeTracker = textChanges.ChangeTracker.fromContext({ host, formatContext, preferences });
|
||||
|
||||
const coalesceAndOrganizeImports = (importGroup: readonly ImportDeclaration[]) => coalesceImports(removeUnusedImports(importGroup, sourceFile, program));
|
||||
const coalesceAndOrganizeImports = (importGroup: readonly ImportDeclaration[]) => stableSort(
|
||||
coalesceImports(removeUnusedImports(importGroup, sourceFile, program)),
|
||||
(s1, s2) => compareImportsOrRequireStatements(s1, s2));
|
||||
|
||||
// All of the old ImportDeclarations in the file, in syntactic order.
|
||||
const topLevelImportDecls = sourceFile.statements.filter(isImportDeclaration);
|
||||
@@ -55,7 +57,7 @@ namespace ts.OrganizeImports {
|
||||
suppressLeadingTrivia(oldImportDecls[0]);
|
||||
|
||||
const oldImportGroups = group(oldImportDecls, importDecl => getExternalModuleName(importDecl.moduleSpecifier!)!);
|
||||
const sortedImportGroups = stableSort(oldImportGroups, (group1, group2) => compareModuleSpecifiers(group1[0].moduleSpecifier!, group2[0].moduleSpecifier!));
|
||||
const sortedImportGroups = stableSort(oldImportGroups, (group1, group2) => compareModuleSpecifiers(group1[0].moduleSpecifier, group2[0].moduleSpecifier));
|
||||
const newImportDecls = flatMap(sortedImportGroups, importGroup =>
|
||||
getExternalModuleName(importGroup[0].moduleSpecifier!)
|
||||
? coalesce(importGroup)
|
||||
@@ -395,15 +397,18 @@ namespace ts.OrganizeImports {
|
||||
}
|
||||
|
||||
function sortSpecifiers<T extends ImportOrExportSpecifier>(specifiers: readonly T[]) {
|
||||
return stableSort(specifiers, (s1, s2) =>
|
||||
compareIdentifiers(s1.propertyName || s1.name, s2.propertyName || s2.name) ||
|
||||
compareIdentifiers(s1.name, s2.name));
|
||||
return stableSort(specifiers, compareImportOrExportSpecifiers);
|
||||
}
|
||||
|
||||
export function compareImportOrExportSpecifiers<T extends ImportOrExportSpecifier>(s1: T, s2: T) {
|
||||
return compareIdentifiers(s1.propertyName || s1.name, s2.propertyName || s2.name)
|
||||
|| compareIdentifiers(s1.name, s2.name);
|
||||
}
|
||||
|
||||
/* internal */ // Exported for testing
|
||||
export function compareModuleSpecifiers(m1: Expression, m2: Expression) {
|
||||
const name1 = getExternalModuleName(m1);
|
||||
const name2 = getExternalModuleName(m2);
|
||||
export function compareModuleSpecifiers(m1: Expression | undefined, m2: Expression | undefined) {
|
||||
const name1 = m1 === undefined ? undefined : getExternalModuleName(m1);
|
||||
const name2 = m2 === undefined ? undefined : getExternalModuleName(m2);
|
||||
return compareBooleans(name1 === undefined, name2 === undefined) ||
|
||||
compareBooleans(isExternalModuleNameRelative(name1!), isExternalModuleNameRelative(name2!)) ||
|
||||
compareStringsCaseInsensitive(name1!, name2!);
|
||||
@@ -412,4 +417,63 @@ namespace ts.OrganizeImports {
|
||||
function compareIdentifiers(s1: Identifier, s2: Identifier) {
|
||||
return compareStringsCaseInsensitive(s1.text, s2.text);
|
||||
}
|
||||
|
||||
function getModuleSpecifierExpression(declaration: AnyImportOrRequireStatement): Expression | undefined {
|
||||
switch (declaration.kind) {
|
||||
case SyntaxKind.ImportEqualsDeclaration:
|
||||
return tryCast(declaration.moduleReference, isExternalModuleReference)?.expression;
|
||||
case SyntaxKind.ImportDeclaration:
|
||||
return declaration.moduleSpecifier;
|
||||
case SyntaxKind.VariableStatement:
|
||||
return declaration.declarationList.declarations[0].initializer.arguments[0];
|
||||
}
|
||||
}
|
||||
|
||||
export function importsAreSorted(imports: readonly AnyImportOrRequireStatement[]): imports is SortedReadonlyArray<AnyImportOrRequireStatement> {
|
||||
return arrayIsSorted(imports, compareImportsOrRequireStatements);
|
||||
}
|
||||
|
||||
export function importSpecifiersAreSorted(imports: readonly ImportSpecifier[]): imports is SortedReadonlyArray<ImportSpecifier> {
|
||||
return arrayIsSorted(imports, compareImportOrExportSpecifiers);
|
||||
}
|
||||
|
||||
export function getImportDeclarationInsertionIndex(sortedImports: SortedReadonlyArray<AnyImportOrRequireStatement>, newImport: AnyImportOrRequireStatement) {
|
||||
const index = binarySearch(sortedImports, newImport, identity, compareImportsOrRequireStatements);
|
||||
return index < 0 ? ~index : index;
|
||||
}
|
||||
|
||||
export function getImportSpecifierInsertionIndex(sortedImports: SortedReadonlyArray<ImportSpecifier>, newImport: ImportSpecifier) {
|
||||
const index = binarySearch(sortedImports, newImport, identity, compareImportOrExportSpecifiers);
|
||||
return index < 0 ? ~index : index;
|
||||
}
|
||||
|
||||
export function compareImportsOrRequireStatements(s1: AnyImportOrRequireStatement, s2: AnyImportOrRequireStatement) {
|
||||
return compareModuleSpecifiers(getModuleSpecifierExpression(s1), getModuleSpecifierExpression(s2)) || compareImportKind(s1, s2);
|
||||
}
|
||||
|
||||
function compareImportKind(s1: AnyImportOrRequireStatement, s2: AnyImportOrRequireStatement) {
|
||||
return compareValues(getImportKindOrder(s1), getImportKindOrder(s2));
|
||||
}
|
||||
|
||||
// 1. Side-effect imports
|
||||
// 2. Type-only imports
|
||||
// 3. Namespace imports
|
||||
// 4. Default imports
|
||||
// 5. Named imports
|
||||
// 6. ImportEqualsDeclarations
|
||||
// 7. Require variable statements
|
||||
function getImportKindOrder(s1: AnyImportOrRequireStatement) {
|
||||
switch (s1.kind) {
|
||||
case SyntaxKind.ImportDeclaration:
|
||||
if (!s1.importClause) return 0;
|
||||
if (s1.importClause.isTypeOnly) return 1;
|
||||
if (s1.importClause.namedBindings?.kind === SyntaxKind.NamespaceImport) return 2;
|
||||
if (s1.importClause.name) return 3;
|
||||
return 4;
|
||||
case SyntaxKind.ImportEqualsDeclaration:
|
||||
return 5;
|
||||
case SyntaxKind.VariableStatement:
|
||||
return 6;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@ namespace ts {
|
||||
// we see the name of a module that is used everywhere, or the name of an overload). As
|
||||
// such, we cache the information we compute about the candidate for the life of this
|
||||
// pattern matcher so we don't have to compute it multiple times.
|
||||
const stringToWordSpans = createMap<TextSpan[]>();
|
||||
const stringToWordSpans = new Map<string, TextSpan[]>();
|
||||
|
||||
const dotSeparatedSegments = pattern.trim().split(".").map(p => createSegment(p.trim()));
|
||||
// A segment is considered invalid if we couldn't find any words in it.
|
||||
|
||||
@@ -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: ESMap<string, Refactor> = createMap<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) {
|
||||
|
||||
@@ -74,7 +74,7 @@ namespace ts.refactor {
|
||||
let usedAsNamespaceOrDefault = false;
|
||||
|
||||
const nodesToReplace: PropertyAccessExpression[] = [];
|
||||
const conflictingNames = createMap<true>();
|
||||
const conflictingNames = new Map<string, true>();
|
||||
|
||||
FindAllReferences.Core.eachSymbolReferenceInFile(toConvert.name, checker, sourceFile, id => {
|
||||
if (!isPropertyAccessExpression(id.parent)) {
|
||||
@@ -92,7 +92,7 @@ namespace ts.refactor {
|
||||
});
|
||||
|
||||
// We may need to change `mod.x` to `_x` to avoid a name conflict.
|
||||
const exportNameToImportName = createMap<string>();
|
||||
const exportNameToImportName = new Map<string, string>();
|
||||
|
||||
for (const propertyAccess of nodesToReplace) {
|
||||
const exportName = propertyAccess.name.text;
|
||||
|
||||
@@ -43,11 +43,11 @@ namespace ts.refactor.extractSymbol {
|
||||
}
|
||||
|
||||
const functionActions: RefactorActionInfo[] = [];
|
||||
const usedFunctionNames: ESMap<string, boolean> = createMap();
|
||||
const usedFunctionNames = new Map<string, boolean>();
|
||||
let innermostErrorFunctionAction: RefactorActionInfo | undefined;
|
||||
|
||||
const constantActions: RefactorActionInfo[] = [];
|
||||
const usedConstantNames: ESMap<string, boolean> = createMap();
|
||||
const usedConstantNames = new Map<string, boolean>();
|
||||
let innermostErrorConstantAction: RefactorActionInfo | undefined;
|
||||
|
||||
let i = 0;
|
||||
@@ -1546,13 +1546,13 @@ namespace ts.refactor.extractSymbol {
|
||||
checker: TypeChecker,
|
||||
cancellationToken: CancellationToken): ReadsAndWrites {
|
||||
|
||||
const allTypeParameterUsages = createMap<TypeParameter>(); // Key is type ID
|
||||
const allTypeParameterUsages = new Map<string, TypeParameter>(); // Key is type ID
|
||||
const usagesPerScope: ScopeUsages[] = [];
|
||||
const substitutionsPerScope: ESMap<string, Node>[] = [];
|
||||
const functionErrorsPerScope: Diagnostic[][] = [];
|
||||
const constantErrorsPerScope: Diagnostic[][] = [];
|
||||
const visibleDeclarationsInExtractedRange: NamedDeclaration[] = [];
|
||||
const exposedVariableSymbolSet = createMap<true>(); // Key is symbol ID
|
||||
const exposedVariableSymbolSet = new Map<string, true>(); // Key is symbol ID
|
||||
const exposedVariableDeclarations: VariableDeclaration[] = [];
|
||||
let firstExposedNonVariableDeclaration: NamedDeclaration | undefined;
|
||||
|
||||
@@ -1575,8 +1575,8 @@ namespace ts.refactor.extractSymbol {
|
||||
|
||||
// initialize results
|
||||
for (const scope of scopes) {
|
||||
usagesPerScope.push({ usages: createMap<UsageEntry>(), typeParameterUsages: createMap<TypeParameter>(), substitutions: createMap<Expression>() });
|
||||
substitutionsPerScope.push(createMap<Expression>());
|
||||
usagesPerScope.push({ usages: new Map<string, UsageEntry>(), typeParameterUsages: new Map<string, TypeParameter>(), substitutions: new Map<string, Expression>() });
|
||||
substitutionsPerScope.push(new Map<string, Expression>());
|
||||
|
||||
functionErrorsPerScope.push(
|
||||
isFunctionLikeDeclaration(scope) && scope.kind !== SyntaxKind.FunctionDeclaration
|
||||
@@ -1597,7 +1597,7 @@ namespace ts.refactor.extractSymbol {
|
||||
constantErrorsPerScope.push(constantErrors);
|
||||
}
|
||||
|
||||
const seenUsages = createMap<Usage>();
|
||||
const seenUsages = new Map<string, Usage>();
|
||||
const target = isReadonlyArray(targetRange.range) ? factory.createBlock(targetRange.range) : targetRange.range;
|
||||
|
||||
const unmodifiedNode = isReadonlyArray(targetRange.range) ? first(targetRange.range) : targetRange.range;
|
||||
@@ -1614,7 +1614,7 @@ namespace ts.refactor.extractSymbol {
|
||||
}
|
||||
|
||||
if (allTypeParameterUsages.size > 0) {
|
||||
const seenTypeParameterUsages = createMap<TypeParameter>(); // Key is type ID
|
||||
const seenTypeParameterUsages = new Map<string, TypeParameter>(); // Key is type ID
|
||||
|
||||
let i = 0;
|
||||
for (let curr: Node = unmodifiedNode; curr !== undefined && i < scopes.length; curr = curr.parent) {
|
||||
|
||||
@@ -105,7 +105,7 @@ namespace ts.refactor {
|
||||
if (!node) return undefined;
|
||||
if (isIntersectionTypeNode(node)) {
|
||||
const result: TypeElement[] = [];
|
||||
const seen = createMap<true>();
|
||||
const seen = new Map<string, true>();
|
||||
for (const type of node.types) {
|
||||
const flattenedTypeMembers = flattenTypeLiteralNodeReference(checker, type);
|
||||
if (!flattenedTypeMembers || !flattenedTypeMembers.every(type => type.name && addToSeen(seen, getNameFromPropertyName(type.name) as string))) {
|
||||
|
||||
@@ -269,7 +269,7 @@ namespace ts.refactor {
|
||||
| ImportEqualsDeclaration
|
||||
| VariableStatement;
|
||||
|
||||
function createOldFileImportsFromNewFile(newFileNeedExport: ReadonlySymbolSet, newFileNameWithExtension: string, useEs6Imports: boolean, quotePreference: QuotePreference): Statement | undefined {
|
||||
function createOldFileImportsFromNewFile(newFileNeedExport: ReadonlySymbolSet, newFileNameWithExtension: string, useEs6Imports: boolean, quotePreference: QuotePreference): AnyImportOrRequireStatement | undefined {
|
||||
let defaultImport: Identifier | undefined;
|
||||
const imports: string[] = [];
|
||||
newFileNeedExport.forEach(symbol => {
|
||||
@@ -283,7 +283,7 @@ namespace ts.refactor {
|
||||
return makeImportOrRequire(defaultImport, imports, newFileNameWithExtension, useEs6Imports, quotePreference);
|
||||
}
|
||||
|
||||
function makeImportOrRequire(defaultImport: Identifier | undefined, imports: readonly string[], path: string, useEs6Imports: boolean, quotePreference: QuotePreference): Statement | undefined {
|
||||
function makeImportOrRequire(defaultImport: Identifier | undefined, imports: readonly string[], path: string, useEs6Imports: boolean, quotePreference: QuotePreference): AnyImportOrRequireStatement | undefined {
|
||||
path = ensurePathIsNonModuleName(path);
|
||||
if (useEs6Imports) {
|
||||
const specifiers = imports.map(i => factory.createImportSpecifier(/*propertyName*/ undefined, factory.createIdentifier(i)));
|
||||
@@ -293,7 +293,7 @@ namespace ts.refactor {
|
||||
Debug.assert(!defaultImport, "No default import should exist"); // If there's a default export, it should have been an es6 module.
|
||||
const bindingElements = imports.map(i => factory.createBindingElement(/*dotDotDotToken*/ undefined, /*propertyName*/ undefined, i));
|
||||
return bindingElements.length
|
||||
? makeVariableStatement(factory.createObjectBindingPattern(bindingElements), /*type*/ undefined, createRequireCall(factory.createStringLiteral(path)))
|
||||
? makeVariableStatement(factory.createObjectBindingPattern(bindingElements), /*type*/ undefined, createRequireCall(factory.createStringLiteral(path))) as RequireVariableStatement
|
||||
: undefined;
|
||||
}
|
||||
}
|
||||
@@ -610,7 +610,7 @@ namespace ts.refactor {
|
||||
forEachEntry<T>(cb: (symbol: Symbol) => T | undefined): T | undefined;
|
||||
}
|
||||
class SymbolSet implements ReadonlySymbolSet {
|
||||
private map = createMap<Symbol>();
|
||||
private map = new Map<string, Symbol>();
|
||||
add(symbol: Symbol): void {
|
||||
this.map.set(String(getSymbolId(symbol)), symbol);
|
||||
}
|
||||
|
||||
@@ -1408,7 +1408,7 @@ namespace ts {
|
||||
//
|
||||
// Each LS has a reference to file 'foo.ts' at version 1. LS2 then updates
|
||||
// it's version of 'foo.ts' to version 2. This will cause LS2 and the
|
||||
// DocumentRegistry to have version 2 of the document. HOwever, LS1 will
|
||||
// DocumentRegistry to have version 2 of the document. However, LS1 will
|
||||
// have version 1. And *importantly* this source file will be *corrupt*.
|
||||
// The act of creating version 2 of the file irrevocably damages the version
|
||||
// 1 file.
|
||||
@@ -1451,7 +1451,7 @@ namespace ts {
|
||||
|
||||
function dispose(): void {
|
||||
if (program) {
|
||||
// Use paths to ensure we are using correct key and paths as document registry could bre created with different current directory than host
|
||||
// Use paths to ensure we are using correct key and paths as document registry could be created with different current directory than host
|
||||
const key = documentRegistry.getKeyForCompilationSettings(program.getCompilerOptions());
|
||||
forEach(program.getSourceFiles(), f =>
|
||||
documentRegistry.releaseDocumentWithKey(f.resolvedPath, key));
|
||||
@@ -1831,12 +1831,12 @@ namespace ts {
|
||||
return OutliningElementsCollector.collectElements(sourceFile, cancellationToken);
|
||||
}
|
||||
|
||||
const braceMatching = createMapFromTemplate({
|
||||
const braceMatching = new Map(getEntries({
|
||||
[SyntaxKind.OpenBraceToken]: SyntaxKind.CloseBraceToken,
|
||||
[SyntaxKind.OpenParenToken]: SyntaxKind.CloseParenToken,
|
||||
[SyntaxKind.OpenBracketToken]: SyntaxKind.CloseBracketToken,
|
||||
[SyntaxKind.GreaterThanToken]: SyntaxKind.LessThanToken,
|
||||
});
|
||||
}));
|
||||
braceMatching.forEach((value, key) => braceMatching.set(value.toString(), Number(key) as SyntaxKind));
|
||||
|
||||
function getBraceMatchingAtPosition(fileName: string, position: number): TextSpan[] {
|
||||
@@ -2299,7 +2299,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function initializeNameTable(sourceFile: SourceFile): void {
|
||||
const nameTable = sourceFile.nameTable = createUnderscoreEscapedMap<number>();
|
||||
const nameTable = sourceFile.nameTable = new Map();
|
||||
sourceFile.forEachChild(function walk(node) {
|
||||
if (isIdentifier(node) && !isTagName(node) && node.escapedText || isStringOrNumericLiteralLike(node) && literalIsName(node)) {
|
||||
const text = getEscapedTextOfIdentifierOrLiteral(node);
|
||||
|
||||
@@ -23,8 +23,8 @@ namespace ts {
|
||||
export function getSourceMapper(host: SourceMapperHost): SourceMapper {
|
||||
const getCanonicalFileName = createGetCanonicalFileName(host.useCaseSensitiveFileNames());
|
||||
const currentDirectory = host.getCurrentDirectory();
|
||||
const sourceFileLike = createMap<SourceFileLike | false>();
|
||||
const documentPositionMappers = createMap<DocumentPositionMapper>();
|
||||
const sourceFileLike = new Map<string, SourceFileLike | false>();
|
||||
const documentPositionMappers = new Map<string, DocumentPositionMapper>();
|
||||
return { tryGetSourcePosition, tryGetGeneratedPosition, toLineColumnOffset, clearCache };
|
||||
|
||||
function toPath(fileName: string) {
|
||||
|
||||
@@ -207,7 +207,7 @@ namespace ts.Completions.StringCompletions {
|
||||
function getStringLiteralCompletionsFromSignature(argumentInfo: SignatureHelp.ArgumentInfoForCompletions, checker: TypeChecker): StringLiteralCompletionsFromTypes {
|
||||
let isNewIdentifier = false;
|
||||
|
||||
const uniques = createMap<true>();
|
||||
const uniques = new Map<string, true>();
|
||||
const candidates: Signature[] = [];
|
||||
checker.getResolvedSignature(argumentInfo.invocation, candidates, argumentInfo.argumentCount);
|
||||
const types = flatMap(candidates, candidate => {
|
||||
@@ -228,7 +228,7 @@ namespace ts.Completions.StringCompletions {
|
||||
};
|
||||
}
|
||||
|
||||
function getStringLiteralTypes(type: Type | undefined, uniques = createMap<true>()): readonly StringLiteralType[] {
|
||||
function getStringLiteralTypes(type: Type | undefined, uniques = new Map<string, true>()): readonly StringLiteralType[] {
|
||||
if (!type) return emptyArray;
|
||||
type = skipConstraint(type);
|
||||
return type.isUnion() ? flatMap(type.types, t => getStringLiteralTypes(t, uniques)) :
|
||||
@@ -363,7 +363,7 @@ namespace ts.Completions.StringCompletions {
|
||||
*
|
||||
* both foo.ts and foo.tsx become foo
|
||||
*/
|
||||
const foundFiles = createMap<Extension | undefined>(); // maps file to its extension
|
||||
const foundFiles = new Map<string, Extension | undefined>(); // maps file to its extension
|
||||
for (let filePath of files) {
|
||||
filePath = normalizePath(filePath);
|
||||
if (exclude && comparePaths(filePath, exclude, scriptPath, ignoreCase) === Comparison.EqualTo) {
|
||||
@@ -595,7 +595,7 @@ namespace ts.Completions.StringCompletions {
|
||||
|
||||
function getCompletionEntriesFromTypings(host: LanguageServiceHost, options: CompilerOptions, scriptPath: string, fragmentDirectory: string | undefined, extensionOptions: ExtensionOptions, result: NameAndKind[] = []): readonly NameAndKind[] {
|
||||
// Check for typings specified in compiler options
|
||||
const seen = createMap<true>();
|
||||
const seen = new Map<string, true>();
|
||||
|
||||
const typeRoots = tryAndIgnoreErrors(() => getEffectiveTypeRoots(options, host)) || emptyArray;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* @internal */
|
||||
namespace ts {
|
||||
const visitedNestedConvertibleFunctions = createMap<true>();
|
||||
const visitedNestedConvertibleFunctions = new Map<string, true>();
|
||||
|
||||
export function computeSuggestionDiagnostics(sourceFile: SourceFile, program: Program, cancellationToken: CancellationToken): DiagnosticWithLocation[] {
|
||||
program.getSemanticDiagnostics(sourceFile, cancellationToken);
|
||||
|
||||
@@ -250,7 +250,7 @@ namespace ts.textChanges {
|
||||
export class ChangeTracker {
|
||||
private readonly changes: Change[] = [];
|
||||
private readonly newFiles: { readonly oldFile: SourceFile | undefined, readonly fileName: string, readonly statements: readonly Statement[] }[] = [];
|
||||
private readonly classesWithNodesInsertedAtStart = createMap<{ readonly node: ClassDeclaration | InterfaceDeclaration | ObjectLiteralExpression, readonly sourceFile: SourceFile }>(); // Set<ClassDeclaration> implemented as Map<node id, ClassDeclaration>
|
||||
private readonly classesWithNodesInsertedAtStart = new Map<string, { readonly node: ClassDeclaration | InterfaceDeclaration | ObjectLiteralExpression, readonly sourceFile: SourceFile }>(); // Set<ClassDeclaration> implemented as Map<node id, ClassDeclaration>
|
||||
private readonly deletedNodes: { readonly sourceFile: SourceFile, readonly node: Node | NodeArray<TypeParameterDeclaration> }[] = [];
|
||||
|
||||
public static fromContext(context: TextChangesContext): ChangeTracker {
|
||||
@@ -472,9 +472,9 @@ namespace ts.textChanges {
|
||||
this.insertNodesAt(sourceFile, start, typeParameters, { prefix: "<", suffix: ">" });
|
||||
}
|
||||
|
||||
private getOptionsForInsertNodeBefore(before: Node, inserted: Node, doubleNewlines: boolean): InsertNodeOptions {
|
||||
private getOptionsForInsertNodeBefore(before: Node, inserted: Node, blankLineBetween: boolean): InsertNodeOptions {
|
||||
if (isStatement(before) || isClassElement(before)) {
|
||||
return { suffix: doubleNewlines ? this.newLineCharacter + this.newLineCharacter : this.newLineCharacter };
|
||||
return { suffix: blankLineBetween ? this.newLineCharacter + this.newLineCharacter : this.newLineCharacter };
|
||||
}
|
||||
else if (isVariableDeclaration(before)) { // insert `x = 1, ` into `const x = 1, y = 2;
|
||||
return { suffix: ", " };
|
||||
@@ -485,6 +485,9 @@ namespace ts.textChanges {
|
||||
else if (isStringLiteral(before) && isImportDeclaration(before.parent) || isNamedImports(before)) {
|
||||
return { suffix: ", " };
|
||||
}
|
||||
else if (isImportSpecifier(before)) {
|
||||
return { suffix: "," + (blankLineBetween ? this.newLineCharacter : " ") };
|
||||
}
|
||||
return Debug.failBadSyntaxKind(before); // We haven't handled this kind of node yet -- add it
|
||||
}
|
||||
|
||||
@@ -824,7 +827,7 @@ namespace ts.textChanges {
|
||||
}
|
||||
|
||||
private finishDeleteDeclarations(): void {
|
||||
const deletedNodesInLists = new NodeSet(); // Stores nodes in lists that we already deleted. Used to avoid deleting `, ` twice in `a, b`.
|
||||
const deletedNodesInLists = new Set<Node>(); // Stores nodes in lists that we already deleted. Used to avoid deleting `, ` twice in `a, b`.
|
||||
for (const { sourceFile, node } of this.deletedNodes) {
|
||||
if (!this.deletedNodes.some(d => d.sourceFile === sourceFile && rangeContainsRangeExclusive(d.node, node))) {
|
||||
if (isArray(node)) {
|
||||
@@ -1275,7 +1278,7 @@ namespace ts.textChanges {
|
||||
}
|
||||
|
||||
namespace deleteDeclaration {
|
||||
export function deleteDeclaration(changes: ChangeTracker, deletedNodesInLists: NodeSet<Node>, sourceFile: SourceFile, node: Node): void {
|
||||
export function deleteDeclaration(changes: ChangeTracker, deletedNodesInLists: Set<Node>, sourceFile: SourceFile, node: Node): void {
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.Parameter: {
|
||||
const oldFunction = node.parent;
|
||||
@@ -1397,7 +1400,7 @@ namespace ts.textChanges {
|
||||
}
|
||||
}
|
||||
|
||||
function deleteVariableDeclaration(changes: ChangeTracker, deletedNodesInLists: NodeSet<Node>, sourceFile: SourceFile, node: VariableDeclaration): void {
|
||||
function deleteVariableDeclaration(changes: ChangeTracker, deletedNodesInLists: Set<Node>, sourceFile: SourceFile, node: VariableDeclaration): void {
|
||||
const { parent } = node;
|
||||
|
||||
if (parent.kind === SyntaxKind.CatchClause) {
|
||||
@@ -1440,7 +1443,7 @@ namespace ts.textChanges {
|
||||
changes.deleteRange(sourceFile, { pos: startPosition, end: endPosition });
|
||||
}
|
||||
|
||||
function deleteNodeInList(changes: ChangeTracker, deletedNodesInLists: NodeSet<Node>, sourceFile: SourceFile, node: Node): void {
|
||||
function deleteNodeInList(changes: ChangeTracker, deletedNodesInLists: Set<Node>, sourceFile: SourceFile, node: Node): void {
|
||||
const containingList = Debug.checkDefined(formatting.SmartIndenter.getContainingList(node, sourceFile));
|
||||
const index = indexOfNode(containingList, node);
|
||||
Debug.assert(index !== -1);
|
||||
|
||||
@@ -54,7 +54,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
if (transpileOptions.renamedDependencies) {
|
||||
sourceFile.renamedDependencies = createMapFromTemplate(transpileOptions.renamedDependencies);
|
||||
sourceFile.renamedDependencies = new Map(getEntries(transpileOptions.renamedDependencies));
|
||||
}
|
||||
|
||||
const newLine = getNewLineCharacter(options);
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user