Merge remote-tracking branch 'upstream/master' into AddToggleCommentFeature
This commit is contained in:
commit
635ee24a3c
2
.github/workflows/ci.yml
vendored
2
.github/workflows/ci.yml
vendored
|
@ -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 }}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -134,7 +134,7 @@ namespace ts {
|
|||
EmptyObjectFacts = All,
|
||||
}
|
||||
|
||||
const typeofEQFacts: ReadonlyESMap<string, TypeFacts> = createMapFromTemplate({
|
||||
const typeofEQFacts: ReadonlyESMap<string, TypeFacts> = new Map(getEntries({
|
||||
string: TypeFacts.TypeofEQString,
|
||||
number: TypeFacts.TypeofEQNumber,
|
||||
bigint: TypeFacts.TypeofEQBigInt,
|
||||
|
@ -143,9 +143,9 @@ namespace ts {
|
|||
undefined: TypeFacts.EQUndefined,
|
||||
object: TypeFacts.TypeofEQObject,
|
||||
function: TypeFacts.TypeofEQFunction
|
||||
});
|
||||
}));
|
||||
|
||||
const typeofNEFacts: ReadonlyESMap<string, TypeFacts> = createMapFromTemplate({
|
||||
const typeofNEFacts: ReadonlyESMap<string, TypeFacts> = new Map(getEntries({
|
||||
string: TypeFacts.TypeofNEString,
|
||||
number: TypeFacts.TypeofNENumber,
|
||||
bigint: TypeFacts.TypeofNEBigInt,
|
||||
|
@ -154,7 +154,7 @@ namespace ts {
|
|||
undefined: TypeFacts.NEUndefined,
|
||||
object: TypeFacts.TypeofNEObject,
|
||||
function: TypeFacts.TypeofNEFunction
|
||||
});
|
||||
}));
|
||||
|
||||
type TypeSystemEntity = Node | Symbol | Type | Signature;
|
||||
|
||||
|
@ -261,7 +261,7 @@ namespace ts {
|
|||
return node.id;
|
||||
}
|
||||
|
||||
export function getSymbolId(symbol: Symbol): number {
|
||||
export function getSymbolId(symbol: Symbol): SymbolId {
|
||||
if (!symbol.id) {
|
||||
symbol.id = nextSymbolId;
|
||||
nextSymbolId++;
|
||||
|
@ -685,14 +685,14 @@ namespace ts {
|
|||
return res;
|
||||
}
|
||||
|
||||
const tupleTypes = createMap<GenericType>();
|
||||
const unionTypes = createMap<UnionType>();
|
||||
const intersectionTypes = createMap<Type>();
|
||||
const literalTypes = createMap<LiteralType>();
|
||||
const indexedAccessTypes = createMap<IndexedAccessType>();
|
||||
const substitutionTypes = createMap<SubstitutionType>();
|
||||
const tupleTypes = new Map<string, GenericType>();
|
||||
const unionTypes = new Map<string, UnionType>();
|
||||
const intersectionTypes = new Map<string, Type>();
|
||||
const literalTypes = new Map<string, LiteralType>();
|
||||
const indexedAccessTypes = new Map<string, IndexedAccessType>();
|
||||
const substitutionTypes = new Map<string, SubstitutionType>();
|
||||
const evolvingArrayTypes: EvolvingArrayType[] = [];
|
||||
const undefinedProperties = createMap<Symbol>() as UnderscoreEscapedMap<Symbol>;
|
||||
const undefinedProperties: SymbolTable = new Map();
|
||||
|
||||
const unknownSymbol = createSymbol(SymbolFlags.Property, "unknown" as __String);
|
||||
const resolvingSymbol = createSymbol(0, InternalSymbolName.Resolving);
|
||||
|
@ -753,7 +753,7 @@ namespace ts {
|
|||
const emptyTypeLiteralType = createAnonymousType(emptyTypeLiteralSymbol, emptySymbols, emptyArray, emptyArray, undefined, undefined);
|
||||
|
||||
const emptyGenericType = <GenericType><ObjectType>createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined);
|
||||
emptyGenericType.instantiations = createMap<TypeReference>();
|
||||
emptyGenericType.instantiations = new Map<string, TypeReference>();
|
||||
|
||||
const anyFunctionType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined);
|
||||
// The anyFunctionType contains the anyFunctionType by definition. The flag is further propagated
|
||||
|
@ -778,7 +778,7 @@ namespace ts {
|
|||
|
||||
const enumNumberIndexInfo = createIndexInfo(stringType, /*isReadonly*/ true);
|
||||
|
||||
const iterationTypesCache = createMap<IterationTypes>(); // cache for common IterationTypes instances
|
||||
const iterationTypesCache = new Map<string, IterationTypes>(); // cache for common IterationTypes instances
|
||||
const noIterationTypes: IterationTypes = {
|
||||
get yieldType(): Type { return Debug.fail("Not supported"); },
|
||||
get returnType(): Type { return Debug.fail("Not supported"); },
|
||||
|
@ -830,7 +830,7 @@ namespace ts {
|
|||
}
|
||||
/** Key is "/path/to/a.ts|/path/to/b.ts". */
|
||||
let amalgamatedDuplicates: ESMap<string, DuplicateInfoForFiles> | undefined;
|
||||
const reverseMappedCache = createMap<Type | undefined>();
|
||||
const reverseMappedCache = new Map<string, Type | undefined>();
|
||||
let inInferTypeForHomomorphicMappedType = false;
|
||||
let ambientModulesCache: Symbol[] | undefined;
|
||||
/**
|
||||
|
@ -883,7 +883,7 @@ namespace ts {
|
|||
let deferredGlobalOmitSymbol: Symbol;
|
||||
let deferredGlobalBigIntType: ObjectType;
|
||||
|
||||
const allPotentiallyUnusedIdentifiers = createMap<PotentiallyUnusedIdentifier[]>(); // key is file name
|
||||
const allPotentiallyUnusedIdentifiers = new Map<Path, PotentiallyUnusedIdentifier[]>(); // key is file name
|
||||
|
||||
let flowLoopStart = 0;
|
||||
let flowLoopCount = 0;
|
||||
|
@ -923,26 +923,26 @@ namespace ts {
|
|||
const diagnostics = createDiagnosticCollection();
|
||||
const suggestionDiagnostics = createDiagnosticCollection();
|
||||
|
||||
const typeofTypesByName: ReadonlyESMap<string, Type> = createMapFromTemplate<Type>({
|
||||
const typeofTypesByName: ReadonlyESMap<string, Type> = new Map(getEntries({
|
||||
string: stringType,
|
||||
number: numberType,
|
||||
bigint: bigintType,
|
||||
boolean: booleanType,
|
||||
symbol: esSymbolType,
|
||||
undefined: undefinedType
|
||||
});
|
||||
}));
|
||||
const typeofType = createTypeofType();
|
||||
|
||||
let _jsxNamespace: __String;
|
||||
let _jsxFactoryEntity: EntityName | undefined;
|
||||
let outofbandVarianceMarkerHandler: ((onlyUnreliable: boolean) => void) | undefined;
|
||||
|
||||
const subtypeRelation = createMap<RelationComparisonResult>();
|
||||
const strictSubtypeRelation = createMap<RelationComparisonResult>();
|
||||
const assignableRelation = createMap<RelationComparisonResult>();
|
||||
const comparableRelation = createMap<RelationComparisonResult>();
|
||||
const identityRelation = createMap<RelationComparisonResult>();
|
||||
const enumRelation = createMap<RelationComparisonResult>();
|
||||
const subtypeRelation = new Map<string, RelationComparisonResult>();
|
||||
const strictSubtypeRelation = new Map<string, RelationComparisonResult>();
|
||||
const assignableRelation = new Map<string, RelationComparisonResult>();
|
||||
const comparableRelation = new Map<string, RelationComparisonResult>();
|
||||
const identityRelation = new Map<string, RelationComparisonResult>();
|
||||
const enumRelation = new Map<string, RelationComparisonResult>();
|
||||
|
||||
const builtinGlobals = createSymbolTable();
|
||||
builtinGlobals.set(undefinedSymbol.escapedName, undefinedSymbol);
|
||||
|
@ -1111,8 +1111,8 @@ namespace ts {
|
|||
result.parent = symbol.parent;
|
||||
if (symbol.valueDeclaration) result.valueDeclaration = symbol.valueDeclaration;
|
||||
if (symbol.constEnumOnlyModule) result.constEnumOnlyModule = true;
|
||||
if (symbol.members) result.members = cloneMap(symbol.members);
|
||||
if (symbol.exports) result.exports = cloneMap(symbol.exports);
|
||||
if (symbol.members) result.members = new Map(symbol.members);
|
||||
if (symbol.exports) result.exports = new Map(symbol.exports);
|
||||
recordMergedSymbol(result, symbol);
|
||||
return result;
|
||||
}
|
||||
|
@ -1182,10 +1182,10 @@ namespace ts {
|
|||
if (sourceSymbolFile && targetSymbolFile && amalgamatedDuplicates && !isEitherEnum && sourceSymbolFile !== targetSymbolFile) {
|
||||
const firstFile = comparePaths(sourceSymbolFile.path, targetSymbolFile.path) === Comparison.LessThan ? sourceSymbolFile : targetSymbolFile;
|
||||
const secondFile = firstFile === sourceSymbolFile ? targetSymbolFile : sourceSymbolFile;
|
||||
const filesDuplicates = getOrUpdate<DuplicateInfoForFiles>(amalgamatedDuplicates, `${firstFile.path}|${secondFile.path}`, () =>
|
||||
({ firstFile, secondFile, conflictingSymbols: createMap() }));
|
||||
const conflictingSymbolInfo = getOrUpdate<DuplicateInfoForSymbol>(filesDuplicates.conflictingSymbols, symbolName, () =>
|
||||
({ isBlockScoped: isEitherBlockScoped, firstFileLocations: [], secondFileLocations: [] }));
|
||||
const filesDuplicates = getOrUpdate(amalgamatedDuplicates, `${firstFile.path}|${secondFile.path}`, () =>
|
||||
({ firstFile, secondFile, conflictingSymbols: new Map() } as DuplicateInfoForFiles));
|
||||
const conflictingSymbolInfo = getOrUpdate(filesDuplicates.conflictingSymbols, symbolName, () =>
|
||||
({ isBlockScoped: isEitherBlockScoped, firstFileLocations: [], secondFileLocations: [] } as DuplicateInfoForSymbol));
|
||||
addDuplicateLocations(conflictingSymbolInfo.firstFileLocations, source);
|
||||
addDuplicateLocations(conflictingSymbolInfo.secondFileLocations, target);
|
||||
}
|
||||
|
@ -1224,8 +1224,8 @@ namespace ts {
|
|||
}
|
||||
|
||||
function combineSymbolTables(first: SymbolTable | undefined, second: SymbolTable | undefined): SymbolTable | undefined {
|
||||
if (!hasEntries(first)) return second;
|
||||
if (!hasEntries(second)) return first;
|
||||
if (!first?.size) return second;
|
||||
if (!second?.size) return first;
|
||||
const combined = createSymbolTable();
|
||||
mergeSymbolTable(combined, first);
|
||||
mergeSymbolTable(combined, second);
|
||||
|
@ -1273,7 +1273,7 @@ namespace ts {
|
|||
if (some(patternAmbientModules, module => mainModule === module.symbol)) {
|
||||
const merged = mergeSymbol(moduleAugmentation.symbol, mainModule, /*unidirectional*/ true);
|
||||
if (!patternAmbientModuleAugmentations) {
|
||||
patternAmbientModuleAugmentations = createMap();
|
||||
patternAmbientModuleAugmentations = new Map();
|
||||
}
|
||||
// moduleName will be a StringLiteral since this is not `declare global`.
|
||||
patternAmbientModuleAugmentations.set((moduleName as StringLiteral).text, merged);
|
||||
|
@ -2573,8 +2573,8 @@ namespace ts {
|
|||
result.declarations = deduplicate(concatenate(valueSymbol.declarations, typeSymbol.declarations), equateValues);
|
||||
result.parent = valueSymbol.parent || typeSymbol.parent;
|
||||
if (valueSymbol.valueDeclaration) result.valueDeclaration = valueSymbol.valueDeclaration;
|
||||
if (typeSymbol.members) result.members = cloneMap(typeSymbol.members);
|
||||
if (valueSymbol.exports) result.exports = cloneMap(valueSymbol.exports);
|
||||
if (typeSymbol.members) result.members = new Map(typeSymbol.members);
|
||||
if (valueSymbol.exports) result.exports = new Map(valueSymbol.exports);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -3300,8 +3300,8 @@ namespace ts {
|
|||
result.originatingImport = referenceParent;
|
||||
if (symbol.valueDeclaration) result.valueDeclaration = symbol.valueDeclaration;
|
||||
if (symbol.constEnumOnlyModule) result.constEnumOnlyModule = true;
|
||||
if (symbol.members) result.members = cloneMap(symbol.members);
|
||||
if (symbol.exports) result.exports = cloneMap(symbol.exports);
|
||||
if (symbol.members) result.members = new Map(symbol.members);
|
||||
if (symbol.exports) result.exports = new Map(symbol.exports);
|
||||
const resolvedModuleType = resolveStructuredTypeMembers(moduleType as StructuredType); // Should already be resolved from the signature checks above
|
||||
result.type = createAnonymousType(result, resolvedModuleType.members, emptyArray, emptyArray, resolvedModuleType.stringIndexInfo, resolvedModuleType.numberIndexInfo);
|
||||
return result;
|
||||
|
@ -3417,12 +3417,12 @@ namespace ts {
|
|||
if (!(symbol && symbol.exports && pushIfUnique(visitedSymbols, symbol))) {
|
||||
return;
|
||||
}
|
||||
const symbols = cloneMap(symbol.exports);
|
||||
const symbols = new Map(symbol.exports);
|
||||
// All export * declarations are collected in an __export symbol by the binder
|
||||
const exportStars = symbol.exports.get(InternalSymbolName.ExportStar);
|
||||
if (exportStars) {
|
||||
const nestedSymbols = createSymbolTable();
|
||||
const lookupTable = createMap<ExportCollisionTracker>() as ExportCollisionTrackerTable;
|
||||
const lookupTable: ExportCollisionTrackerTable = new Map();
|
||||
for (const node of exportStars.declarations) {
|
||||
const resolvedModule = resolveExternalModuleName(node, (node as ExportDeclaration).moduleSpecifier!);
|
||||
const exportedSymbols = visit(resolvedModule);
|
||||
|
@ -3472,7 +3472,7 @@ namespace ts {
|
|||
|
||||
function getAlternativeContainingModules(symbol: Symbol, enclosingDeclaration: Node): Symbol[] {
|
||||
const containingFile = getSourceFileOfNode(enclosingDeclaration);
|
||||
const id = "" + getNodeId(containingFile);
|
||||
const id = getNodeId(containingFile);
|
||||
const links = getSymbolLinks(symbol);
|
||||
let results: Symbol[] | undefined;
|
||||
if (links.extendedContainersByFile && (results = links.extendedContainersByFile.get(id))) {
|
||||
|
@ -3489,7 +3489,7 @@ namespace ts {
|
|||
results = append(results, resolvedModule);
|
||||
}
|
||||
if (length(results)) {
|
||||
(links.extendedContainersByFile || (links.extendedContainersByFile = createMap())).set(id, results!);
|
||||
(links.extendedContainersByFile || (links.extendedContainersByFile = new Map())).set(id, results!);
|
||||
return results!;
|
||||
}
|
||||
}
|
||||
|
@ -3753,12 +3753,12 @@ namespace ts {
|
|||
return rightMeaning === SymbolFlags.Value ? SymbolFlags.Value : SymbolFlags.Namespace;
|
||||
}
|
||||
|
||||
function getAccessibleSymbolChain(symbol: Symbol | undefined, enclosingDeclaration: Node | undefined, meaning: SymbolFlags, useOnlyExternalAliasing: boolean, visitedSymbolTablesMap: ESMap<string, SymbolTable[]> = createMap()): Symbol[] | undefined {
|
||||
function getAccessibleSymbolChain(symbol: Symbol | undefined, enclosingDeclaration: Node | undefined, meaning: SymbolFlags, useOnlyExternalAliasing: boolean, visitedSymbolTablesMap: ESMap<SymbolId, SymbolTable[]> = new Map()): Symbol[] | undefined {
|
||||
if (!(symbol && !isPropertyOrMethodDeclarationSymbol(symbol))) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const id = "" + getSymbolId(symbol);
|
||||
const id = getSymbolId(symbol);
|
||||
let visitedSymbolTables = visitedSymbolTablesMap.get(id);
|
||||
if (!visitedSymbolTables) {
|
||||
visitedSymbolTablesMap.set(id, visitedSymbolTables = []);
|
||||
|
@ -4551,7 +4551,7 @@ namespace ts {
|
|||
context.visitedTypes = new Set();
|
||||
}
|
||||
if (id && !context.symbolDepth) {
|
||||
context.symbolDepth = createMap<number>();
|
||||
context.symbolDepth = new Map();
|
||||
}
|
||||
|
||||
let depth: number | undefined;
|
||||
|
@ -5336,7 +5336,7 @@ namespace ts {
|
|||
moduleResolverHost,
|
||||
{ importModuleSpecifierPreference: isBundle ? "non-relative" : "relative" },
|
||||
));
|
||||
links.specifierCache = links.specifierCache || createMap();
|
||||
links.specifierCache ??= new Map();
|
||||
links.specifierCache.set(contextFile.path, specifier);
|
||||
}
|
||||
return specifier;
|
||||
|
@ -5458,7 +5458,7 @@ namespace ts {
|
|||
|
||||
function typeParameterToName(type: TypeParameter, context: NodeBuilderContext) {
|
||||
if (context.flags & NodeBuilderFlags.GenerateNamesForShadowedTypeParams && context.typeParameterNames) {
|
||||
const cached = context.typeParameterNames.get("" + getTypeId(type));
|
||||
const cached = context.typeParameterNames.get(getTypeId(type));
|
||||
if (cached) {
|
||||
return cached;
|
||||
}
|
||||
|
@ -5478,7 +5478,7 @@ namespace ts {
|
|||
if (text !== rawtext) {
|
||||
result = factory.createIdentifier(text, result.typeArguments);
|
||||
}
|
||||
(context.typeParameterNames || (context.typeParameterNames = createMap())).set("" + getTypeId(type), result);
|
||||
(context.typeParameterNames || (context.typeParameterNames = new Map())).set(getTypeId(type), result);
|
||||
(context.typeParameterNamesByText || (context.typeParameterNamesByText = new Set())).add(result.escapedText as string);
|
||||
}
|
||||
return result;
|
||||
|
@ -5635,7 +5635,7 @@ namespace ts {
|
|||
// export const x: <T>(x: T) => T
|
||||
// export const y: <T_1>(x: T_1) => T_1
|
||||
if (initial.typeParameterNames) {
|
||||
initial.typeParameterNames = cloneMap(initial.typeParameterNames);
|
||||
initial.typeParameterNames = new Map(initial.typeParameterNames);
|
||||
}
|
||||
if (initial.typeParameterNamesByText) {
|
||||
initial.typeParameterNamesByText = new Set(initial.typeParameterNamesByText);
|
||||
|
@ -5881,12 +5881,12 @@ namespace ts {
|
|||
const enclosingDeclaration = context.enclosingDeclaration!;
|
||||
let results: Statement[] = [];
|
||||
const visitedSymbols = new Set<number>();
|
||||
let deferredPrivates: ESMap<string, Symbol> | undefined;
|
||||
let deferredPrivates: ESMap<SymbolId, Symbol> | undefined;
|
||||
const oldcontext = context;
|
||||
context = {
|
||||
...oldcontext,
|
||||
usedSymbolNames: new Set(oldcontext.usedSymbolNames),
|
||||
remappedSymbolNames: createMap(),
|
||||
remappedSymbolNames: new Map(),
|
||||
tracker: {
|
||||
...oldcontext.tracker,
|
||||
trackSymbol: (sym, decl, meaning) => {
|
||||
|
@ -6094,7 +6094,7 @@ namespace ts {
|
|||
function visitSymbolTable(symbolTable: SymbolTable, suppressNewPrivateContext?: boolean, propertyAsAlias?: boolean) {
|
||||
const oldDeferredPrivates = deferredPrivates;
|
||||
if (!suppressNewPrivateContext) {
|
||||
deferredPrivates = createMap();
|
||||
deferredPrivates = new Map();
|
||||
}
|
||||
symbolTable.forEach((symbol: Symbol) => {
|
||||
serializeSymbol(symbol, /*isPrivate*/ false, !!propertyAsAlias);
|
||||
|
@ -6293,7 +6293,7 @@ namespace ts {
|
|||
if (some(symbol.declarations, isParameterDeclaration)) return;
|
||||
Debug.assertIsDefined(deferredPrivates);
|
||||
getUnusedName(unescapeLeadingUnderscores(symbol.escapedName), symbol); // Call to cache unique name for symbol
|
||||
deferredPrivates.set("" + getSymbolId(symbol), symbol);
|
||||
deferredPrivates.set(getSymbolId(symbol), symbol);
|
||||
}
|
||||
|
||||
function isExportingScope(enclosingDeclaration: Node) {
|
||||
|
@ -7063,9 +7063,10 @@ namespace ts {
|
|||
}
|
||||
|
||||
function getUnusedName(input: string, symbol?: Symbol): string {
|
||||
if (symbol) {
|
||||
if (context.remappedSymbolNames!.has("" + getSymbolId(symbol))) {
|
||||
return context.remappedSymbolNames!.get("" + getSymbolId(symbol))!;
|
||||
const id = symbol ? getSymbolId(symbol) : undefined;
|
||||
if (id) {
|
||||
if (context.remappedSymbolNames!.has(id)) {
|
||||
return context.remappedSymbolNames!.get(id)!;
|
||||
}
|
||||
}
|
||||
if (symbol) {
|
||||
|
@ -7078,8 +7079,8 @@ namespace ts {
|
|||
input = `${original}_${i}`;
|
||||
}
|
||||
context.usedSymbolNames?.add(input);
|
||||
if (symbol) {
|
||||
context.remappedSymbolNames!.set("" + getSymbolId(symbol), input);
|
||||
if (id) {
|
||||
context.remappedSymbolNames!.set(id, input);
|
||||
}
|
||||
return input;
|
||||
}
|
||||
|
@ -7103,12 +7104,13 @@ namespace ts {
|
|||
}
|
||||
|
||||
function getInternalSymbolName(symbol: Symbol, localName: string) {
|
||||
if (context.remappedSymbolNames!.has("" + getSymbolId(symbol))) {
|
||||
return context.remappedSymbolNames!.get("" + getSymbolId(symbol))!;
|
||||
const id = getSymbolId(symbol);
|
||||
if (context.remappedSymbolNames!.has(id)) {
|
||||
return context.remappedSymbolNames!.get(id)!;
|
||||
}
|
||||
localName = getNameCandidateWorker(symbol, localName);
|
||||
// The result of this is going to be used as the symbol's name - lock it in, so `getUnusedName` will also pick it up
|
||||
context.remappedSymbolNames!.set("" + getSymbolId(symbol), localName);
|
||||
context.remappedSymbolNames!.set(id, localName);
|
||||
return localName;
|
||||
}
|
||||
}
|
||||
|
@ -7195,10 +7197,10 @@ namespace ts {
|
|||
approximateLength: number;
|
||||
truncating?: boolean;
|
||||
typeParameterSymbolList?: Set<number>;
|
||||
typeParameterNames?: ESMap<string, Identifier>;
|
||||
typeParameterNames?: ESMap<TypeId, Identifier>;
|
||||
typeParameterNamesByText?: Set<string>;
|
||||
usedSymbolNames?: Set<string>;
|
||||
remappedSymbolNames?: ESMap<string, string>;
|
||||
remappedSymbolNames?: ESMap<SymbolId, string>;
|
||||
}
|
||||
|
||||
function isDefaultBindingContext(location: Node) {
|
||||
|
@ -7992,13 +7994,13 @@ namespace ts {
|
|||
const exports = createSymbolTable();
|
||||
while (isBinaryExpression(decl) || isPropertyAccessExpression(decl)) {
|
||||
const s = getSymbolOfNode(decl);
|
||||
if (s && hasEntries(s.exports)) {
|
||||
if (s?.exports?.size) {
|
||||
mergeSymbolTable(exports, s.exports);
|
||||
}
|
||||
decl = isBinaryExpression(decl) ? decl.parent : decl.parent.parent;
|
||||
}
|
||||
const s = getSymbolOfNode(decl);
|
||||
if (s && hasEntries(s.exports)) {
|
||||
if (s?.exports?.size) {
|
||||
mergeSymbolTable(exports, s.exports);
|
||||
}
|
||||
const type = createAnonymousType(symbol, exports, emptyArray, emptyArray, undefined, undefined);
|
||||
|
@ -8758,6 +8760,12 @@ namespace ts {
|
|||
(node.kind === SyntaxKind.ClassDeclaration || node.kind === SyntaxKind.ClassExpression || node.kind === SyntaxKind.InterfaceDeclaration || isJSConstructor(node)) &&
|
||||
getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node as ClassLikeDeclaration | InterfaceDeclaration)).thisType;
|
||||
return thisType ? append(outerAndOwnTypeParameters, thisType) : outerAndOwnTypeParameters;
|
||||
case SyntaxKind.JSDocParameterTag:
|
||||
const paramSymbol = getParameterSymbolFromJSDoc(node as JSDocParameterTag);
|
||||
if (paramSymbol) {
|
||||
node = paramSymbol.valueDeclaration;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -9093,7 +9101,7 @@ namespace ts {
|
|||
type.typeParameters = concatenate(outerTypeParameters, localTypeParameters);
|
||||
type.outerTypeParameters = outerTypeParameters;
|
||||
type.localTypeParameters = localTypeParameters;
|
||||
(<GenericType>type).instantiations = createMap<TypeReference>();
|
||||
(<GenericType>type).instantiations = new Map<string, TypeReference>();
|
||||
(<GenericType>type).instantiations.set(getTypeListId(type.typeParameters), <GenericType>type);
|
||||
(<GenericType>type).target = <GenericType>type;
|
||||
(<GenericType>type).resolvedTypeArguments = type.typeParameters;
|
||||
|
@ -9125,7 +9133,7 @@ namespace ts {
|
|||
// Initialize the instantiation cache for generic type aliases. The declared type corresponds to
|
||||
// an instantiation of the type alias with the type parameters supplied as type arguments.
|
||||
links.typeParameters = typeParameters;
|
||||
links.instantiations = createMap<Type>();
|
||||
links.instantiations = new Map<string, Type>();
|
||||
links.instantiations.set(getTypeListId(typeParameters), type);
|
||||
}
|
||||
}
|
||||
|
@ -10119,7 +10127,7 @@ namespace ts {
|
|||
if (symbol.exports) {
|
||||
members = getExportsOfSymbol(symbol);
|
||||
if (symbol === globalThisSymbol) {
|
||||
const varsOnly = createMap<Symbol>() as SymbolTable;
|
||||
const varsOnly = new Map<string, Symbol>() as SymbolTable;
|
||||
members.forEach(p => {
|
||||
if (!(p.flags & SymbolFlags.BlockScoped)) {
|
||||
varsOnly.set(p.escapedName, p);
|
||||
|
@ -10836,7 +10844,7 @@ namespace ts {
|
|||
|
||||
function createUnionOrIntersectionProperty(containingType: UnionOrIntersectionType, name: __String): Symbol | undefined {
|
||||
let singleProp: Symbol | undefined;
|
||||
let propSet: ESMap<string, Symbol> | undefined;
|
||||
let propSet: ESMap<SymbolId, Symbol> | undefined;
|
||||
let indexTypes: Type[] | undefined;
|
||||
const isUnion = containingType.flags & TypeFlags.Union;
|
||||
// Flags we want to propagate to the result if they exist in all source symbols
|
||||
|
@ -10860,10 +10868,10 @@ namespace ts {
|
|||
}
|
||||
else if (prop !== singleProp) {
|
||||
if (!propSet) {
|
||||
propSet = createMap<Symbol>();
|
||||
propSet.set("" + getSymbolId(singleProp), singleProp);
|
||||
propSet = new Map<SymbolId, Symbol>();
|
||||
propSet.set(getSymbolId(singleProp), singleProp);
|
||||
}
|
||||
const id = "" + getSymbolId(prop);
|
||||
const id = getSymbolId(prop);
|
||||
if (!propSet.has(id)) {
|
||||
propSet.set(id, prop);
|
||||
}
|
||||
|
@ -11579,7 +11587,7 @@ namespace ts {
|
|||
}
|
||||
|
||||
function getSignatureInstantiationWithoutFillingInTypeArguments(signature: Signature, typeArguments: readonly Type[] | undefined): Signature {
|
||||
const instantiations = signature.instantiations || (signature.instantiations = createMap<Signature>());
|
||||
const instantiations = signature.instantiations || (signature.instantiations = new Map<string, Signature>());
|
||||
const id = getTypeListId(typeArguments);
|
||||
let instantiation = instantiations.get(id);
|
||||
if (!instantiation) {
|
||||
|
@ -12538,7 +12546,7 @@ namespace ts {
|
|||
type.typeParameters = typeParameters;
|
||||
type.outerTypeParameters = undefined;
|
||||
type.localTypeParameters = typeParameters;
|
||||
type.instantiations = createMap<TypeReference>();
|
||||
type.instantiations = new Map<string, TypeReference>();
|
||||
type.instantiations.set(getTypeListId(type.typeParameters), <GenericType>type);
|
||||
type.target = <GenericType>type;
|
||||
type.resolvedTypeArguments = type.typeParameters;
|
||||
|
@ -12664,7 +12672,7 @@ namespace ts {
|
|||
return strictNullChecks ? getOptionalType(type) : type;
|
||||
}
|
||||
|
||||
function getTypeId(type: Type) {
|
||||
function getTypeId(type: Type): TypeId {
|
||||
return type.id;
|
||||
}
|
||||
|
||||
|
@ -13044,7 +13052,7 @@ namespace ts {
|
|||
// Also, unlike union types, the order of the constituent types is preserved in order that overload resolution
|
||||
// for intersections of types with signatures can be deterministic.
|
||||
function getIntersectionType(types: readonly Type[], aliasSymbol?: Symbol, aliasTypeArguments?: readonly Type[]): Type {
|
||||
const typeMembershipMap: ESMap<string, Type> = createMap();
|
||||
const typeMembershipMap: ESMap<string, Type> = new Map();
|
||||
const includes = addTypesToIntersection(typeMembershipMap, 0, types);
|
||||
const typeSet: Type[] = arrayFrom(typeMembershipMap.values());
|
||||
// An intersection type is considered empty if it contains
|
||||
|
@ -13844,7 +13852,7 @@ namespace ts {
|
|||
};
|
||||
links.resolvedType = getConditionalType(root, /*mapper*/ undefined);
|
||||
if (outerTypeParameters) {
|
||||
root.instantiations = createMap<Type>();
|
||||
root.instantiations = new Map<string, Type>();
|
||||
root.instantiations.set(getTypeListId(outerTypeParameters), links.resolvedType);
|
||||
}
|
||||
}
|
||||
|
@ -14082,7 +14090,7 @@ namespace ts {
|
|||
}
|
||||
|
||||
const members = createSymbolTable();
|
||||
const skippedPrivateMembers = createUnderscoreEscapedMap<boolean>();
|
||||
const skippedPrivateMembers = new Set<__String>();
|
||||
let stringIndexInfo: IndexInfo | undefined;
|
||||
let numberIndexInfo: IndexInfo | undefined;
|
||||
if (left === emptyObjectType) {
|
||||
|
@ -14097,7 +14105,7 @@ namespace ts {
|
|||
|
||||
for (const rightProp of getPropertiesOfType(right)) {
|
||||
if (getDeclarationModifierFlagsFromSymbol(rightProp) & (ModifierFlags.Private | ModifierFlags.Protected)) {
|
||||
skippedPrivateMembers.set(rightProp.escapedName, true);
|
||||
skippedPrivateMembers.add(rightProp.escapedName);
|
||||
}
|
||||
else if (isSpreadableProperty(rightProp)) {
|
||||
members.set(rightProp.escapedName, getSpreadSymbol(rightProp, readonly));
|
||||
|
@ -14584,24 +14592,14 @@ namespace ts {
|
|||
|
||||
function getObjectTypeInstantiation(type: AnonymousType | DeferredTypeReference, mapper: TypeMapper) {
|
||||
const target = type.objectFlags & ObjectFlags.Instantiated ? type.target! : type;
|
||||
const node = type.objectFlags & ObjectFlags.Reference ? (<TypeReference>type).node! : type.symbol.declarations[0];
|
||||
const links = getNodeLinks(node);
|
||||
const declaration = type.objectFlags & ObjectFlags.Reference ? (<TypeReference>type).node! : type.symbol.declarations[0];
|
||||
const links = getNodeLinks(declaration);
|
||||
let typeParameters = links.outerTypeParameters;
|
||||
if (!typeParameters) {
|
||||
// The first time an anonymous type is instantiated we compute and store a list of the type
|
||||
// parameters that are in scope (and therefore potentially referenced). For type literals that
|
||||
// aren't the right hand side of a generic type alias declaration we optimize by reducing the
|
||||
// set of type parameters to those that are possibly referenced in the literal.
|
||||
let declaration = node;
|
||||
if (isInJSFile(declaration)) {
|
||||
const paramTag = findAncestor(declaration, isJSDocParameterTag);
|
||||
if (paramTag) {
|
||||
const paramSymbol = getParameterSymbolFromJSDoc(paramTag);
|
||||
if (paramSymbol) {
|
||||
declaration = paramSymbol.valueDeclaration;
|
||||
}
|
||||
}
|
||||
}
|
||||
let outerTypeParameters = getOuterTypeParameters(declaration, /*includeThisTypes*/ true);
|
||||
if (isJSConstructor(declaration)) {
|
||||
const templateTagParameters = getTypeParametersFromDeclaration(declaration as DeclarationWithTypeParameters);
|
||||
|
@ -14613,7 +14611,7 @@ namespace ts {
|
|||
typeParameters;
|
||||
links.outerTypeParameters = typeParameters;
|
||||
if (typeParameters.length) {
|
||||
links.instantiations = createMap<Type>();
|
||||
links.instantiations = new Map<string, Type>();
|
||||
links.instantiations.set(getTypeListId(typeParameters), target);
|
||||
}
|
||||
}
|
||||
|
@ -17238,14 +17236,14 @@ namespace ts {
|
|||
|
||||
// Compute the set of types for each discriminant property.
|
||||
const sourceDiscriminantTypes: Type[][] = new Array<Type[]>(sourcePropertiesFiltered.length);
|
||||
const excludedProperties = createUnderscoreEscapedMap<true>();
|
||||
const excludedProperties = new Set<__String>();
|
||||
for (let i = 0; i < sourcePropertiesFiltered.length; i++) {
|
||||
const sourceProperty = sourcePropertiesFiltered[i];
|
||||
const sourcePropertyType = getTypeOfSymbol(sourceProperty);
|
||||
sourceDiscriminantTypes[i] = sourcePropertyType.flags & TypeFlags.Union
|
||||
? (sourcePropertyType as UnionType).types
|
||||
: [sourcePropertyType];
|
||||
excludedProperties.set(sourceProperty.escapedName, true);
|
||||
excludedProperties.add(sourceProperty.escapedName);
|
||||
}
|
||||
|
||||
// Match each combination of the cartesian product of discriminant properties to one or more
|
||||
|
@ -17304,7 +17302,7 @@ namespace ts {
|
|||
return result;
|
||||
}
|
||||
|
||||
function excludeProperties(properties: Symbol[], excludedProperties: UnderscoreEscapedMap<true> | undefined) {
|
||||
function excludeProperties(properties: Symbol[], excludedProperties: Set<__String> | undefined) {
|
||||
if (!excludedProperties || properties.length === 0) return properties;
|
||||
let result: Symbol[] | undefined;
|
||||
for (let i = 0; i < properties.length; i++) {
|
||||
|
@ -17473,7 +17471,7 @@ namespace ts {
|
|||
// No array like or unmatched property error - just issue top level error (errorInfo = undefined)
|
||||
}
|
||||
|
||||
function propertiesRelatedTo(source: Type, target: Type, reportErrors: boolean, excludedProperties: UnderscoreEscapedMap<true> | undefined, intersectionState: IntersectionState): Ternary {
|
||||
function propertiesRelatedTo(source: Type, target: Type, reportErrors: boolean, excludedProperties: Set<__String> | undefined, intersectionState: IntersectionState): Ternary {
|
||||
if (relation === identityRelation) {
|
||||
return propertiesIdenticalTo(source, target, excludedProperties);
|
||||
}
|
||||
|
@ -17602,7 +17600,7 @@ namespace ts {
|
|||
return result;
|
||||
}
|
||||
|
||||
function propertiesIdenticalTo(source: Type, target: Type, excludedProperties: UnderscoreEscapedMap<true> | undefined): Ternary {
|
||||
function propertiesIdenticalTo(source: Type, target: Type, excludedProperties: Set<__String> | undefined): Ternary {
|
||||
if (!(source.flags & TypeFlags.Object && target.flags & TypeFlags.Object)) {
|
||||
return Ternary.False;
|
||||
}
|
||||
|
@ -18735,7 +18733,7 @@ namespace ts {
|
|||
|
||||
function getPropertiesOfContext(context: WideningContext): Symbol[] {
|
||||
if (!context.resolvedProperties) {
|
||||
const names = createMap<Symbol>() as UnderscoreEscapedMap<Symbol>;
|
||||
const names = new Map<string, Symbol>() as UnderscoreEscapedMap<Symbol>;
|
||||
for (const t of getSiblingsOfContext(context)) {
|
||||
if (isObjectLiteralType(t) && !(getObjectFlags(t) & ObjectFlags.ContainsSpread)) {
|
||||
for (const prop of getPropertiesOfType(t)) {
|
||||
|
@ -19487,7 +19485,7 @@ namespace ts {
|
|||
inferencePriority = Math.min(inferencePriority, status);
|
||||
return;
|
||||
}
|
||||
(visited || (visited = createMap<number>())).set(key, InferencePriority.Circularity);
|
||||
(visited || (visited = new Map<string, number>())).set(key, InferencePriority.Circularity);
|
||||
const saveInferencePriority = inferencePriority;
|
||||
inferencePriority = InferencePriority.MaxValue;
|
||||
action(source, target);
|
||||
|
@ -20637,7 +20635,7 @@ namespace ts {
|
|||
// we defer subtype reduction until the evolving array type is finalized into a manifest
|
||||
// array type.
|
||||
function addEvolvingArrayElementType(evolvingArrayType: EvolvingArrayType, node: Expression): EvolvingArrayType {
|
||||
const elementType = getBaseTypeOfLiteralType(getContextFreeTypeOfExpression(node));
|
||||
const elementType = getRegularTypeOfObjectLiteral(getBaseTypeOfLiteralType(getContextFreeTypeOfExpression(node)));
|
||||
return isTypeSubsetOf(elementType, evolvingArrayType.elementType) ? evolvingArrayType : getEvolvingArrayType(getUnionType([evolvingArrayType.elementType, elementType]));
|
||||
}
|
||||
|
||||
|
@ -21293,7 +21291,7 @@ namespace ts {
|
|||
// If we have previously computed the control flow type for the reference at
|
||||
// this flow loop junction, return the cached type.
|
||||
const id = getFlowNodeId(flow);
|
||||
const cache = flowLoopCaches[id] || (flowLoopCaches[id] = createMap<Type>());
|
||||
const cache = flowLoopCaches[id] || (flowLoopCaches[id] = new Map<string, Type>());
|
||||
const key = getOrSetCacheKey();
|
||||
if (!key) {
|
||||
// No cache key is generated when binding patterns are in unnarrowable situations
|
||||
|
@ -27387,7 +27385,7 @@ namespace ts {
|
|||
|
||||
// If the symbol of the node has members, treat it like a constructor.
|
||||
const symbol = getSymbolOfNode(func);
|
||||
return !!symbol && hasEntries(symbol.members);
|
||||
return !!symbol?.members?.size;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -27395,21 +27393,21 @@ namespace ts {
|
|||
function mergeJSSymbols(target: Symbol, source: Symbol | undefined) {
|
||||
if (source) {
|
||||
const links = getSymbolLinks(source);
|
||||
if (!links.inferredClassSymbol || !links.inferredClassSymbol.has("" + getSymbolId(target))) {
|
||||
if (!links.inferredClassSymbol || !links.inferredClassSymbol.has(getSymbolId(target))) {
|
||||
const inferred = isTransientSymbol(target) ? target : cloneSymbol(target) as TransientSymbol;
|
||||
inferred.exports = inferred.exports || createSymbolTable();
|
||||
inferred.members = inferred.members || createSymbolTable();
|
||||
inferred.flags |= source.flags & SymbolFlags.Class;
|
||||
if (hasEntries(source.exports)) {
|
||||
if (source.exports?.size) {
|
||||
mergeSymbolTable(inferred.exports, source.exports);
|
||||
}
|
||||
if (hasEntries(source.members)) {
|
||||
if (source.members?.size) {
|
||||
mergeSymbolTable(inferred.members, source.members);
|
||||
}
|
||||
(links.inferredClassSymbol || (links.inferredClassSymbol = createMap<TransientSymbol>())).set("" + getSymbolId(inferred), inferred);
|
||||
(links.inferredClassSymbol || (links.inferredClassSymbol = new Map())).set(getSymbolId(inferred), inferred);
|
||||
return inferred;
|
||||
}
|
||||
return links.inferredClassSymbol.get("" + getSymbolId(target));
|
||||
return links.inferredClassSymbol.get(getSymbolId(target));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -27502,7 +27500,7 @@ namespace ts {
|
|||
const decl = getDeclarationOfExpando(node);
|
||||
if (decl) {
|
||||
const jsSymbol = getSymbolOfNode(decl);
|
||||
if (jsSymbol && hasEntries(jsSymbol.exports)) {
|
||||
if (jsSymbol?.exports?.size) {
|
||||
const jsAssignmentType = createAnonymousType(jsSymbol, jsSymbol.exports, emptyArray, emptyArray, undefined, undefined);
|
||||
jsAssignmentType.objectFlags |= ObjectFlags.JSLiteral;
|
||||
return getIntersectionType([returnType, jsAssignmentType]);
|
||||
|
@ -29536,8 +29534,8 @@ namespace ts {
|
|||
case AssignmentDeclarationKind.ThisProperty:
|
||||
const symbol = getSymbolOfNode(left);
|
||||
const init = getAssignedExpandoInitializer(right);
|
||||
return init && isObjectLiteralExpression(init) &&
|
||||
symbol && hasEntries(symbol.exports);
|
||||
return !!init && isObjectLiteralExpression(init) &&
|
||||
!!symbol?.exports?.size;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
@ -30496,10 +30494,10 @@ namespace ts {
|
|||
}
|
||||
|
||||
function checkClassForDuplicateDeclarations(node: ClassLikeDeclaration) {
|
||||
const instanceNames = createUnderscoreEscapedMap<DeclarationMeaning>();
|
||||
const staticNames = createUnderscoreEscapedMap<DeclarationMeaning>();
|
||||
const instanceNames = new Map<__String, DeclarationMeaning>();
|
||||
const staticNames = new Map<__String, DeclarationMeaning>();
|
||||
// instance and static private identifiers share the same scope
|
||||
const privateIdentifiers = createUnderscoreEscapedMap<DeclarationMeaning>();
|
||||
const privateIdentifiers = new Map<__String, DeclarationMeaning>();
|
||||
for (const member of node.members) {
|
||||
if (member.kind === SyntaxKind.Constructor) {
|
||||
for (const param of (member as ConstructorDeclaration).parameters) {
|
||||
|
@ -30595,7 +30593,7 @@ namespace ts {
|
|||
}
|
||||
|
||||
function checkObjectTypeForDuplicateDeclarations(node: TypeLiteralNode | InterfaceDeclaration) {
|
||||
const names = createMap<boolean>();
|
||||
const names = new Map<string, boolean>();
|
||||
for (const member of node.members) {
|
||||
if (member.kind === SyntaxKind.PropertySignature) {
|
||||
let memberName: string;
|
||||
|
@ -32293,7 +32291,7 @@ namespace ts {
|
|||
if (last(getSymbolOfNode(node).declarations) !== node) return;
|
||||
|
||||
const typeParameters = getEffectiveTypeParameterDeclarations(node);
|
||||
const seenParentsWithEveryUnused = new NodeSet<DeclarationWithTypeParameterChildren>();
|
||||
const seenParentsWithEveryUnused = new Set<DeclarationWithTypeParameterChildren>();
|
||||
|
||||
for (const typeParameter of typeParameters) {
|
||||
if (!isTypeParameterUnused(typeParameter)) continue;
|
||||
|
@ -32301,7 +32299,7 @@ namespace ts {
|
|||
const name = idText(typeParameter.name);
|
||||
const { parent } = typeParameter;
|
||||
if (parent.kind !== SyntaxKind.InferType && parent.typeParameters!.every(isTypeParameterUnused)) {
|
||||
if (seenParentsWithEveryUnused.tryAdd(parent)) {
|
||||
if (tryAddToSet(seenParentsWithEveryUnused, parent)) {
|
||||
const range = isJSDocTemplateTag(parent)
|
||||
// Whole @template tag
|
||||
? rangeOfNode(parent)
|
||||
|
@ -32351,9 +32349,9 @@ namespace ts {
|
|||
|
||||
function checkUnusedLocalsAndParameters(nodeWithLocals: Node, addDiagnostic: AddUnusedDiagnostic): void {
|
||||
// Ideally we could use the ImportClause directly as a key, but must wait until we have full ES6 maps. So must store key along with value.
|
||||
const unusedImports = createMap<[ImportClause, ImportedDeclaration[]]>();
|
||||
const unusedDestructures = createMap<[ObjectBindingPattern, BindingElement[]]>();
|
||||
const unusedVariables = createMap<[VariableDeclarationList, VariableDeclaration[]]>();
|
||||
const unusedImports = new Map<string, [ImportClause, ImportedDeclaration[]]>();
|
||||
const unusedDestructures = new Map<string, [ObjectBindingPattern, BindingElement[]]>();
|
||||
const unusedVariables = new Map<string, [VariableDeclarationList, VariableDeclaration[]]>();
|
||||
nodeWithLocals.locals!.forEach(local => {
|
||||
// If it's purely a type parameter, ignore, will be checked in `checkUnusedTypeParameters`.
|
||||
// If it's a type parameter merged with a parameter, check if the parameter-side is used.
|
||||
|
@ -32780,7 +32778,7 @@ namespace ts {
|
|||
const isJSObjectLiteralInitializer = isInJSFile(node) &&
|
||||
isObjectLiteralExpression(initializer) &&
|
||||
(initializer.properties.length === 0 || isPrototypeAccess(node.name)) &&
|
||||
hasEntries(symbol.exports);
|
||||
!!symbol.exports?.size;
|
||||
if (!isJSObjectLiteralInitializer && node.parent.parent.kind !== SyntaxKind.ForInStatement) {
|
||||
checkTypeAssignableToAndOptionallyElaborate(checkExpressionCached(initializer), type, node, initializer, /*headMessage*/ undefined);
|
||||
}
|
||||
|
@ -34604,7 +34602,7 @@ namespace ts {
|
|||
if (!length(baseTypes)) {
|
||||
return properties;
|
||||
}
|
||||
const seen = createUnderscoreEscapedMap<Symbol>();
|
||||
const seen = new Map<__String, Symbol>();
|
||||
forEach(properties, p => { seen.set(p.escapedName, p); });
|
||||
|
||||
for (const base of baseTypes) {
|
||||
|
@ -34627,7 +34625,7 @@ namespace ts {
|
|||
}
|
||||
|
||||
interface InheritanceInfoMap { prop: Symbol; containingType: Type; }
|
||||
const seen = createUnderscoreEscapedMap<InheritanceInfoMap>();
|
||||
const seen = new Map<__String, InheritanceInfoMap>();
|
||||
forEach(resolveDeclaredMembers(type).declaredProperties, p => { seen.set(p.escapedName, { prop: p, containingType: type }); });
|
||||
let ok = true;
|
||||
|
||||
|
@ -35221,39 +35219,36 @@ namespace ts {
|
|||
const target = resolveAlias(symbol);
|
||||
|
||||
if (target !== unknownSymbol) {
|
||||
const shouldSkipWithJSExpandoTargets = symbol.flags & SymbolFlags.Assignment;
|
||||
if (!shouldSkipWithJSExpandoTargets) {
|
||||
// For external modules symbol represents local symbol for an alias.
|
||||
// This local symbol will merge any other local declarations (excluding other aliases)
|
||||
// and symbol.flags will contains combined representation for all merged declaration.
|
||||
// Based on symbol.flags we can compute a set of excluded meanings (meaning that resolved alias should not have,
|
||||
// otherwise it will conflict with some local declaration). Note that in addition to normal flags we include matching SymbolFlags.Export*
|
||||
// in order to prevent collisions with declarations that were exported from the current module (they still contribute to local names).
|
||||
symbol = getMergedSymbol(symbol.exportSymbol || symbol);
|
||||
const excludedMeanings =
|
||||
(symbol.flags & (SymbolFlags.Value | SymbolFlags.ExportValue) ? SymbolFlags.Value : 0) |
|
||||
(symbol.flags & SymbolFlags.Type ? SymbolFlags.Type : 0) |
|
||||
(symbol.flags & SymbolFlags.Namespace ? SymbolFlags.Namespace : 0);
|
||||
if (target.flags & excludedMeanings) {
|
||||
const message = node.kind === SyntaxKind.ExportSpecifier ?
|
||||
Diagnostics.Export_declaration_conflicts_with_exported_declaration_of_0 :
|
||||
Diagnostics.Import_declaration_conflicts_with_local_declaration_of_0;
|
||||
error(node, message, symbolToString(symbol));
|
||||
}
|
||||
// For external modules, `symbol` represents the local symbol for an alias.
|
||||
// This local symbol will merge any other local declarations (excluding other aliases)
|
||||
// and symbol.flags will contains combined representation for all merged declaration.
|
||||
// Based on symbol.flags we can compute a set of excluded meanings (meaning that resolved alias should not have,
|
||||
// otherwise it will conflict with some local declaration). Note that in addition to normal flags we include matching SymbolFlags.Export*
|
||||
// in order to prevent collisions with declarations that were exported from the current module (they still contribute to local names).
|
||||
symbol = getMergedSymbol(symbol.exportSymbol || symbol);
|
||||
const excludedMeanings =
|
||||
(symbol.flags & (SymbolFlags.Value | SymbolFlags.ExportValue) ? SymbolFlags.Value : 0) |
|
||||
(symbol.flags & SymbolFlags.Type ? SymbolFlags.Type : 0) |
|
||||
(symbol.flags & SymbolFlags.Namespace ? SymbolFlags.Namespace : 0);
|
||||
if (target.flags & excludedMeanings) {
|
||||
const message = node.kind === SyntaxKind.ExportSpecifier ?
|
||||
Diagnostics.Export_declaration_conflicts_with_exported_declaration_of_0 :
|
||||
Diagnostics.Import_declaration_conflicts_with_local_declaration_of_0;
|
||||
error(node, message, symbolToString(symbol));
|
||||
}
|
||||
|
||||
// Don't allow to re-export something with no value side when `--isolatedModules` is set.
|
||||
if (compilerOptions.isolatedModules
|
||||
&& node.kind === SyntaxKind.ExportSpecifier
|
||||
&& !node.parent.parent.isTypeOnly
|
||||
&& !(target.flags & SymbolFlags.Value)
|
||||
&& !(node.flags & NodeFlags.Ambient)) {
|
||||
error(node, Diagnostics.Re_exporting_a_type_when_the_isolatedModules_flag_is_provided_requires_using_export_type);
|
||||
}
|
||||
// Don't allow to re-export something with no value side when `--isolatedModules` is set.
|
||||
if (compilerOptions.isolatedModules
|
||||
&& node.kind === SyntaxKind.ExportSpecifier
|
||||
&& !node.parent.parent.isTypeOnly
|
||||
&& !(target.flags & SymbolFlags.Value)
|
||||
&& !(node.flags & NodeFlags.Ambient)) {
|
||||
error(node, Diagnostics.Re_exporting_a_type_when_the_isolatedModules_flag_is_provided_requires_using_export_type);
|
||||
}
|
||||
|
||||
if (isImportSpecifier(node) &&
|
||||
(target.valueDeclaration && target.valueDeclaration.flags & NodeFlags.Deprecated
|
||||
|| every(target.declarations, d => !!(d.flags & NodeFlags.Deprecated)))) {
|
||||
|| every(target.declarations, d => !!(d.flags & NodeFlags.Deprecated)))) {
|
||||
errorOrSuggestion(/* isError */ false, node.name, Diagnostics._0_is_deprecated, symbol.escapedName as string);
|
||||
}
|
||||
}
|
||||
|
@ -35263,6 +35258,12 @@ namespace ts {
|
|||
checkCollisionWithRequireExportsInGeneratedCode(node, node.name!);
|
||||
checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name!);
|
||||
checkAliasSymbol(node);
|
||||
if (node.kind === SyntaxKind.ImportSpecifier &&
|
||||
idText(node.propertyName || node.name) === "default" &&
|
||||
compilerOptions.esModuleInterop &&
|
||||
moduleKind !== ModuleKind.System && moduleKind < ModuleKind.ES2015) {
|
||||
checkExternalEmitHelpers(node, ExternalEmitHelpers.ImportDefault);
|
||||
}
|
||||
}
|
||||
|
||||
function checkImportDeclaration(node: ImportDeclaration) {
|
||||
|
@ -35282,6 +35283,10 @@ namespace ts {
|
|||
if (importClause.namedBindings) {
|
||||
if (importClause.namedBindings.kind === SyntaxKind.NamespaceImport) {
|
||||
checkImportBinding(importClause.namedBindings);
|
||||
if (moduleKind !== ModuleKind.System && moduleKind < ModuleKind.ES2015 && compilerOptions.esModuleInterop) {
|
||||
// import * as ns from "foo";
|
||||
checkExternalEmitHelpers(node, ExternalEmitHelpers.ImportStar);
|
||||
}
|
||||
}
|
||||
else {
|
||||
const moduleExisted = resolveExternalModuleName(node, node.moduleSpecifier);
|
||||
|
@ -35292,6 +35297,7 @@ namespace ts {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function checkImportEqualsDeclaration(node: ImportEqualsDeclaration) {
|
||||
|
@ -35359,6 +35365,7 @@ namespace ts {
|
|||
}
|
||||
else {
|
||||
// export * from "foo"
|
||||
// export * as ns from "foo";
|
||||
const moduleSymbol = resolveExternalModuleName(node, node.moduleSpecifier!);
|
||||
if (moduleSymbol && hasExportAssignmentSymbol(moduleSymbol)) {
|
||||
error(node.moduleSpecifier, Diagnostics.Module_0_uses_export_and_cannot_be_used_with_export_Asterisk, symbolToString(moduleSymbol));
|
||||
|
@ -35367,7 +35374,18 @@ namespace ts {
|
|||
checkAliasSymbol(node.exportClause);
|
||||
}
|
||||
if (moduleKind !== ModuleKind.System && moduleKind < ModuleKind.ES2015) {
|
||||
checkExternalEmitHelpers(node, ExternalEmitHelpers.ExportStar);
|
||||
if (node.exportClause) {
|
||||
// export * as ns from "foo";
|
||||
// For ES2015 modules, we emit it as a pair of `import * as a_1 ...; export { a_1 as ns }` and don't need the helper.
|
||||
// We only use the helper here when in esModuleInterop
|
||||
if (compilerOptions.esModuleInterop) {
|
||||
checkExternalEmitHelpers(node, ExternalEmitHelpers.ImportStar);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// export * from "foo"
|
||||
checkExternalEmitHelpers(node, ExternalEmitHelpers.ExportStar);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -35439,6 +35457,14 @@ namespace ts {
|
|||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (compilerOptions.esModuleInterop &&
|
||||
moduleKind !== ModuleKind.System &&
|
||||
moduleKind < ModuleKind.ES2015 &&
|
||||
idText(node.propertyName || node.name) === "default") {
|
||||
checkExternalEmitHelpers(node, ExternalEmitHelpers.ImportDefault);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function checkExportAssignment(node: ExportAssignment) {
|
||||
|
@ -35819,8 +35845,8 @@ namespace ts {
|
|||
const enclosingFile = getSourceFileOfNode(node);
|
||||
const links = getNodeLinks(enclosingFile);
|
||||
if (!(links.flags & NodeCheckFlags.TypeChecked)) {
|
||||
links.deferredNodes = links.deferredNodes || createMap();
|
||||
const id = "" + getNodeId(node);
|
||||
links.deferredNodes = links.deferredNodes || new Map();
|
||||
const id = getNodeId(node);
|
||||
links.deferredNodes.set(id, node);
|
||||
}
|
||||
}
|
||||
|
@ -37229,7 +37255,7 @@ namespace ts {
|
|||
let fileToDirective: ESMap<string, string>;
|
||||
if (resolvedTypeReferenceDirectives) {
|
||||
// populate reverse mapping: file path -> type reference directive that was resolved to this file
|
||||
fileToDirective = createMap<string>();
|
||||
fileToDirective = new Map<string, string>();
|
||||
resolvedTypeReferenceDirectives.forEach((resolvedDirective, key) => {
|
||||
if (!resolvedDirective || !resolvedDirective.resolvedFileName) {
|
||||
return;
|
||||
|
@ -37462,7 +37488,7 @@ namespace ts {
|
|||
bindSourceFile(file, compilerOptions);
|
||||
}
|
||||
|
||||
amalgamatedDuplicates = createMap();
|
||||
amalgamatedDuplicates = new Map();
|
||||
|
||||
// Initialize global symbol table
|
||||
let augmentations: (readonly (StringLiteral | Identifier)[])[] | undefined;
|
||||
|
@ -37629,6 +37655,8 @@ namespace ts {
|
|||
case ExternalEmitHelpers.AsyncDelegator: return "__asyncDelegator";
|
||||
case ExternalEmitHelpers.AsyncValues: return "__asyncValues";
|
||||
case ExternalEmitHelpers.ExportStar: return "__exportStar";
|
||||
case ExternalEmitHelpers.ImportStar: return "__importStar";
|
||||
case ExternalEmitHelpers.ImportDefault: return "__importDefault";
|
||||
case ExternalEmitHelpers.MakeTemplateObject: return "__makeTemplateObject";
|
||||
case ExternalEmitHelpers.ClassPrivateFieldGet: return "__classPrivateFieldGet";
|
||||
case ExternalEmitHelpers.ClassPrivateFieldSet: return "__classPrivateFieldSet";
|
||||
|
@ -38268,7 +38296,7 @@ namespace ts {
|
|||
}
|
||||
|
||||
function checkGrammarObjectLiteralExpression(node: ObjectLiteralExpression, inDestructuring: boolean) {
|
||||
const seen = createUnderscoreEscapedMap<DeclarationMeaning>();
|
||||
const seen = new Map<__String, DeclarationMeaning>();
|
||||
|
||||
for (const prop of node.properties) {
|
||||
if (prop.kind === SyntaxKind.SpreadAssignment) {
|
||||
|
@ -38373,7 +38401,7 @@ namespace ts {
|
|||
|
||||
function checkGrammarJsxElement(node: JsxOpeningLikeElement) {
|
||||
checkGrammarTypeArguments(node, node.typeArguments);
|
||||
const seen = createUnderscoreEscapedMap<boolean>();
|
||||
const seen = new Map<__String, boolean>();
|
||||
|
||||
for (const attr of node.attributes.properties) {
|
||||
if (attr.kind === SyntaxKind.JsxSpreadAttribute) {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
@ -1287,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++) {
|
||||
|
@ -1387,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);
|
||||
}
|
||||
|
||||
|
@ -1608,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);
|
||||
|
|
|
@ -31,6 +31,7 @@ namespace ts {
|
|||
createImportStarHelper(expression: Expression): Expression;
|
||||
createImportStarCallbackHelper(): Expression;
|
||||
createImportDefaultHelper(expression: Expression): Expression;
|
||||
createExportStarHelper(moduleExpression: Expression, exportsExpression?: Expression): Expression;
|
||||
// Class Fields Helpers
|
||||
createClassPrivateFieldGetHelper(receiver: Expression, privateField: Identifier): Expression;
|
||||
createClassPrivateFieldSetHelper(receiver: Expression, privateField: Identifier, value: Expression): Expression;
|
||||
|
@ -69,6 +70,7 @@ namespace ts {
|
|||
createImportStarHelper,
|
||||
createImportStarCallbackHelper,
|
||||
createImportDefaultHelper,
|
||||
createExportStarHelper,
|
||||
// Class Fields Helpers
|
||||
createClassPrivateFieldGetHelper,
|
||||
createClassPrivateFieldSetHelper,
|
||||
|
@ -366,6 +368,16 @@ namespace ts {
|
|||
);
|
||||
}
|
||||
|
||||
function createExportStarHelper(moduleExpression: Expression, exportsExpression: Expression = factory.createIdentifier("exports")) {
|
||||
context.requestEmitHelper(exportStarHelper);
|
||||
context.requestEmitHelper(createBindingHelper);
|
||||
return factory.createCallExpression(
|
||||
getUnscopedHelperName("__exportStar"),
|
||||
/*typeArguments*/ undefined,
|
||||
[moduleExpression, exportsExpression]
|
||||
);
|
||||
}
|
||||
|
||||
// Class Fields Helpers
|
||||
|
||||
function createClassPrivateFieldGetHelper(receiver: Expression, privateField: Identifier) {
|
||||
|
@ -568,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);
|
||||
};
|
||||
|
||||
|
@ -798,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;
|
||||
};`
|
||||
|
@ -815,6 +827,19 @@ namespace ts {
|
|||
};`
|
||||
};
|
||||
|
||||
// emit output for the __export helper function
|
||||
export const exportStarHelper: UnscopedEmitHelper = {
|
||||
name: "typescript:export-star",
|
||||
importName: "__exportStar",
|
||||
scoped: false,
|
||||
dependencies: [createBindingHelper],
|
||||
priority: 2,
|
||||
text: `
|
||||
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
||||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
||||
};`
|
||||
};
|
||||
|
||||
// Class fields helpers
|
||||
export const classPrivateFieldGetHelper: UnscopedEmitHelper = {
|
||||
name: "typescript:classPrivateFieldGet",
|
||||
|
@ -864,6 +889,7 @@ namespace ts {
|
|||
generatorHelper,
|
||||
importStarHelper,
|
||||
importDefaultHelper,
|
||||
exportStarHelper,
|
||||
classPrivateFieldGetHelper,
|
||||
classPrivateFieldSetHelper,
|
||||
createBindingHelper,
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1268,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
|
||||
|
@ -2569,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;
|
||||
|
|
|
@ -700,7 +700,6 @@ namespace ts {
|
|||
|
||||
const promise = factory.createNewExpression(factory.createIdentifier("Promise"), /*typeArguments*/ undefined, [func]);
|
||||
if (compilerOptions.esModuleInterop) {
|
||||
context.requestEmitHelper(importStarHelper);
|
||||
return factory.createCallExpression(factory.createPropertyAccessExpression(promise, factory.createIdentifier("then")), /*typeArguments*/ undefined, [emitHelpers().createImportStarCallbackHelper()]);
|
||||
}
|
||||
return promise;
|
||||
|
@ -715,7 +714,6 @@ namespace ts {
|
|||
const promiseResolveCall = factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("Promise"), "resolve"), /*typeArguments*/ undefined, /*argumentsArray*/ []);
|
||||
let requireCall: Expression = factory.createCallExpression(factory.createIdentifier("require"), /*typeArguments*/ undefined, arg ? [arg] : []);
|
||||
if (compilerOptions.esModuleInterop) {
|
||||
context.requestEmitHelper(importStarHelper);
|
||||
requireCall = emitHelpers().createImportStarHelper(requireCall);
|
||||
}
|
||||
|
||||
|
@ -755,8 +753,7 @@ namespace ts {
|
|||
return innerExpr;
|
||||
}
|
||||
if (getExportNeedsImportStarHelper(node)) {
|
||||
context.requestEmitHelper(importStarHelper);
|
||||
return factory.createCallExpression(context.getEmitHelperFactory().getUnscopedHelperName("__importStar"), /*typeArguments*/ undefined, [innerExpr]);
|
||||
return emitHelpers().createImportStarHelper(innerExpr);
|
||||
}
|
||||
return innerExpr;
|
||||
}
|
||||
|
@ -766,11 +763,9 @@ namespace ts {
|
|||
return innerExpr;
|
||||
}
|
||||
if (getImportNeedsImportStarHelper(node)) {
|
||||
context.requestEmitHelper(importStarHelper);
|
||||
return emitHelpers().createImportStarHelper(innerExpr);
|
||||
}
|
||||
if (getImportNeedsImportDefaultHelper(node)) {
|
||||
context.requestEmitHelper(importDefaultHelper);
|
||||
return emitHelpers().createImportDefaultHelper(innerExpr);
|
||||
}
|
||||
return innerExpr;
|
||||
|
@ -1015,7 +1010,7 @@ namespace ts {
|
|||
setOriginalNode(
|
||||
setTextRange(
|
||||
factory.createExpressionStatement(
|
||||
context.getEmitHelperFactory().createCreateBindingHelper(generatedName, factory.createStringLiteralFromNode(specifier.propertyName || specifier.name), specifier.propertyName ? factory.createStringLiteralFromNode(specifier.name) : undefined)
|
||||
emitHelpers().createCreateBindingHelper(generatedName, factory.createStringLiteralFromNode(specifier.propertyName || specifier.name), specifier.propertyName ? factory.createStringLiteralFromNode(specifier.name) : undefined)
|
||||
),
|
||||
specifier),
|
||||
specifier
|
||||
|
@ -1023,10 +1018,13 @@ namespace ts {
|
|||
);
|
||||
}
|
||||
else {
|
||||
const exportNeedsImportDefault =
|
||||
!!compilerOptions.esModuleInterop &&
|
||||
!(getEmitFlags(node) & EmitFlags.NeverApplyImportHelper) &&
|
||||
idText(specifier.propertyName || specifier.name) === "default";
|
||||
const exportedValue = factory.createPropertyAccessExpression(
|
||||
generatedName,
|
||||
specifier.propertyName || specifier.name
|
||||
);
|
||||
exportNeedsImportDefault ? emitHelpers().createImportDefaultHelper(generatedName) : generatedName,
|
||||
specifier.propertyName || specifier.name);
|
||||
statements.push(
|
||||
setOriginalNode(
|
||||
setTextRange(
|
||||
|
@ -1051,9 +1049,9 @@ namespace ts {
|
|||
factory.createExpressionStatement(
|
||||
createExportExpression(
|
||||
factory.cloneNode(node.exportClause.name),
|
||||
moduleKind !== ModuleKind.AMD ?
|
||||
getHelperExpressionForExport(node, createRequireCall(node)) :
|
||||
factory.createIdentifier(idText(node.exportClause.name))
|
||||
getHelperExpressionForExport(node, moduleKind !== ModuleKind.AMD ?
|
||||
createRequireCall(node) :
|
||||
factory.createIdentifier(idText(node.exportClause.name)))
|
||||
)
|
||||
),
|
||||
node
|
||||
|
@ -1069,7 +1067,7 @@ namespace ts {
|
|||
return setOriginalNode(
|
||||
setTextRange(
|
||||
factory.createExpressionStatement(
|
||||
createExportStarHelper(context, moduleKind !== ModuleKind.AMD ? createRequireCall(node) : generatedName)
|
||||
emitHelpers().createExportStarHelper(moduleKind !== ModuleKind.AMD ? createRequireCall(node) : generatedName)
|
||||
),
|
||||
node),
|
||||
node
|
||||
|
@ -1857,24 +1855,6 @@ namespace ts {
|
|||
}
|
||||
}
|
||||
|
||||
// emit output for the __export helper function
|
||||
const exportStarHelper: UnscopedEmitHelper = {
|
||||
name: "typescript:export-star",
|
||||
importName: "__exportStar",
|
||||
scoped: false,
|
||||
dependencies: [createBindingHelper],
|
||||
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);
|
||||
};`
|
||||
};
|
||||
|
||||
function createExportStarHelper(context: TransformationContext, module: Expression) {
|
||||
context.requestEmitHelper(exportStarHelper);
|
||||
return context.factory.createCallExpression(context.getEmitHelperFactory().getUnscopedHelperName("__exportStar"), /*typeArguments*/ undefined, [module, context.factory.createIdentifier("exports")]);
|
||||
}
|
||||
|
||||
// emit helper for dynamic import
|
||||
const dynamicImportUMDHelper: EmitHelper = {
|
||||
name: "typescript:dynamicimport-sync-require",
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -2529,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;
|
||||
|
@ -122,6 +122,8 @@ namespace ts {
|
|||
uniqueExports.set(idText(name), true);
|
||||
exportedNames = append(exportedNames, name);
|
||||
}
|
||||
// we use the same helpers for `export * as ns` as we do for `import * as ns`
|
||||
hasImportStar = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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;
|
||||
|
@ -4587,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
|
||||
|
@ -4595,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
|
||||
|
@ -4616,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)
|
||||
|
@ -4635,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
|
||||
}
|
||||
|
||||
|
@ -4727,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> {
|
||||
|
@ -4776,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 {
|
||||
|
@ -4891,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 */
|
||||
|
@ -6427,10 +6436,12 @@ namespace ts {
|
|||
AsyncDelegator = 1 << 14, // __asyncDelegator (used by ES2017 async generator yield* transformation)
|
||||
AsyncValues = 1 << 15, // __asyncValues (used by ES2017 for..await..of transformation)
|
||||
ExportStar = 1 << 16, // __exportStar (used by CommonJS/AMD/UMD module transformation)
|
||||
MakeTemplateObject = 1 << 17, // __makeTemplateObject (used for constructing template string array objects)
|
||||
ClassPrivateFieldGet = 1 << 18, // __classPrivateFieldGet (used by the class private field transformation)
|
||||
ClassPrivateFieldSet = 1 << 19, // __classPrivateFieldSet (used by the class private field transformation)
|
||||
CreateBinding = 1 << 20, // __createBinding (use by the module transform for (re)exports and namespace imports)
|
||||
ImportStar = 1 << 17, // __importStar (used by CommonJS/AMD/UMD module transformation)
|
||||
ImportDefault = 1 << 18, // __importStar (used by CommonJS/AMD/UMD module transformation)
|
||||
MakeTemplateObject = 1 << 19, // __makeTemplateObject (used for constructing template string array objects)
|
||||
ClassPrivateFieldGet = 1 << 20, // __classPrivateFieldGet (used by the class private field transformation)
|
||||
ClassPrivateFieldSet = 1 << 21, // __classPrivateFieldSet (used by the class private field transformation)
|
||||
CreateBinding = 1 << 22, // __createBinding (use by the module transform for (re)exports and namespace imports)
|
||||
FirstEmitHelper = Extends,
|
||||
LastEmitHelper = CreateBinding,
|
||||
|
||||
|
|
|
@ -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 };
|
||||
|
||||
|
@ -3592,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 {
|
||||
|
@ -3690,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",
|
||||
|
@ -3704,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();
|
||||
|
@ -3754,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();
|
||||
|
@ -5944,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)))));
|
||||
|
@ -6202,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);
|
||||
|
@ -6566,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 };
|
||||
|
@ -6654,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;
|
||||
}
|
||||
|
@ -3850,7 +3850,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[] = [];
|
||||
|
||||
|
@ -4239,7 +4239,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);
|
||||
|
||||
|
|
|
@ -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: [] });
|
||||
|
@ -2407,7 +2407,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);
|
||||
|
@ -2790,7 +2790,7 @@ namespace ts.server {
|
|||
[CommandNames.UncommentSelectionFull]: (request: protocol.UncommentSelectionRequest) => {
|
||||
return this.requiredResponse(this.uncommentSelection(request.arguments, /*simplifiedResult*/ false));
|
||||
},
|
||||
});
|
||||
}));
|
||||
|
||||
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;
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -230,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))) {
|
||||
|
@ -947,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:
|
||||
|
|
|
@ -373,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();
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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))) {
|
||||
|
|
|
@ -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[] {
|
||||
|
@ -2533,7 +2533,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 {
|
||||
|
@ -827,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)) {
|
||||
|
@ -1278,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;
|
||||
|
@ -1400,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) {
|
||||
|
@ -1443,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);
|
||||
|
|
|
@ -1857,7 +1857,7 @@ namespace ts {
|
|||
* The value of previousIterationSymbol is undefined when the function is first called.
|
||||
*/
|
||||
export function getPropertySymbolsFromBaseTypes<T>(symbol: Symbol, propertyName: string, checker: TypeChecker, cb: (symbol: Symbol) => T | undefined): T | undefined {
|
||||
const seen = createMap<true>();
|
||||
const seen = new Map<string, true>();
|
||||
return recur(symbol);
|
||||
|
||||
function recur(symbol: Symbol): T | undefined {
|
||||
|
@ -2746,7 +2746,7 @@ namespace ts {
|
|||
if (!dependencies) {
|
||||
continue;
|
||||
}
|
||||
const dependencyMap = createMap<string>();
|
||||
const dependencyMap = new Map<string, string>();
|
||||
for (const packageName in dependencies) {
|
||||
dependencyMap.set(packageName, dependencies[packageName]);
|
||||
}
|
||||
|
|
|
@ -159,13 +159,12 @@ namespace Harness {
|
|||
let configuredName = "";
|
||||
const keys = Object
|
||||
.keys(configurationOverrides)
|
||||
.map(k => k.toLowerCase())
|
||||
.sort();
|
||||
for (const key of keys) {
|
||||
if (configuredName) {
|
||||
configuredName += ",";
|
||||
}
|
||||
configuredName += `${key}=${configurationOverrides[key].toLowerCase()}`;
|
||||
configuredName += `${key.toLowerCase()}=${configurationOverrides[key].toLowerCase()}`;
|
||||
}
|
||||
if (configuredName) {
|
||||
const extname = vpath.extname(this.justName);
|
||||
|
|
|
@ -30,7 +30,7 @@ namespace Harness {
|
|||
|
||||
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
||||
const cls = this;
|
||||
describe(`${this.kind()} code samples`, function (this: Mocha.ISuiteCallbackContext) {
|
||||
describe(`${this.kind()} code samples`, function (this: Mocha.Suite) {
|
||||
this.timeout(600_000); // 10 minutes
|
||||
for (const test of testList) {
|
||||
cls.runTest(typeof test === "string" ? test : test.file);
|
||||
|
@ -41,7 +41,7 @@ namespace Harness {
|
|||
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
||||
const cls = this;
|
||||
const timeout = 600_000; // 10 minutes
|
||||
describe(directoryName, function (this: Mocha.ISuiteCallbackContext) {
|
||||
describe(directoryName, function (this: Mocha.Suite) {
|
||||
this.timeout(timeout);
|
||||
const cp: typeof import("child_process") = require("child_process");
|
||||
|
||||
|
@ -127,7 +127,7 @@ ${stripAbsoluteImportPaths(result.stderr.toString().replace(/\r\n/g, "\n"))}`;
|
|||
|
||||
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
||||
const cls = this;
|
||||
describe(`${this.kind()} code samples`, function (this: Mocha.ISuiteCallbackContext) {
|
||||
describe(`${this.kind()} code samples`, function (this: Mocha.Suite) {
|
||||
this.timeout(cls.timeout); // 20 minutes
|
||||
before(() => {
|
||||
cls.exec("docker", ["build", ".", "-t", "typescript/typescript"], { cwd: IO.getWorkspaceRoot() }); // cached because workspace is hashed to determine cacheability
|
||||
|
|
|
@ -24,7 +24,7 @@ namespace Harness.Parallel.Host {
|
|||
let totalCost = 0;
|
||||
|
||||
class RemoteSuite extends Mocha.Suite {
|
||||
suiteMap = ts.createMap<RemoteSuite>();
|
||||
suiteMap = new ts.Map<string, RemoteSuite>();
|
||||
constructor(title: string) {
|
||||
super(title);
|
||||
this.pending = false;
|
||||
|
|
|
@ -146,13 +146,13 @@ namespace Harness.Parallel.Worker {
|
|||
|
||||
function executeUnitTests(task: UnitTestTask, fn: (payload: TaskResult) => void) {
|
||||
if (!unitTestSuiteMap && unitTestSuite.suites.length) {
|
||||
unitTestSuiteMap = ts.createMap<Mocha.Suite>();
|
||||
unitTestSuiteMap = new ts.Map<string, Mocha.Suite>();
|
||||
for (const suite of unitTestSuite.suites) {
|
||||
unitTestSuiteMap.set(suite.title, suite);
|
||||
}
|
||||
}
|
||||
if (!unitTestTestMap && unitTestSuite.tests.length) {
|
||||
unitTestTestMap = ts.createMap<Mocha.Test>();
|
||||
unitTestTestMap = new ts.Map<string, Mocha.Test>();
|
||||
for (const test of unitTestSuite.tests) {
|
||||
unitTestTestMap.set(test.title, test);
|
||||
}
|
||||
|
@ -297,7 +297,7 @@ namespace Harness.Parallel.Worker {
|
|||
}
|
||||
|
||||
// A cache of test harness Runner instances.
|
||||
const runners = ts.createMap<RunnerBase>();
|
||||
const runners = new ts.Map<string, RunnerBase>();
|
||||
|
||||
// The root suite for all unit tests.
|
||||
let unitTestSuite: Suite;
|
||||
|
|
|
@ -47,7 +47,7 @@ namespace RWC {
|
|||
caseSensitive = false;
|
||||
});
|
||||
|
||||
it("can compile", function (this: Mocha.ITestCallbackContext) {
|
||||
it("can compile", function (this: Mocha.Context) {
|
||||
this.timeout(800_000); // Allow long timeouts for RWC compilations
|
||||
let opts!: ts.ParsedCommandLine;
|
||||
|
||||
|
@ -83,7 +83,7 @@ namespace RWC {
|
|||
}
|
||||
|
||||
// Deduplicate files so they are only printed once in baselines (they are deduplicated within the compiler already)
|
||||
const uniqueNames = ts.createMap<true>();
|
||||
const uniqueNames = new ts.Map<string, true>();
|
||||
for (const fileName of fileNames) {
|
||||
// Must maintain order, build result list while checking map
|
||||
const normalized = ts.normalizeSlashes(Harness.IO.resolvePath(fileName)!);
|
||||
|
@ -145,7 +145,7 @@ namespace RWC {
|
|||
});
|
||||
|
||||
|
||||
it("has the expected emitted code", function (this: Mocha.ITestCallbackContext) {
|
||||
it("has the expected emitted code", function (this: Mocha.Context) {
|
||||
this.timeout(100_000); // Allow longer timeouts for RWC js verification
|
||||
Harness.Baseline.runMultifileBaseline(baseName, "", () => {
|
||||
return Harness.Compiler.iterateOutputs(compilerResult.js.values());
|
||||
|
|
|
@ -571,10 +571,10 @@ namespace ts {
|
|||
|
||||
describe("option of type Map<number | string>", () => {
|
||||
verifyNullNonIncludedOption({
|
||||
type: () => createMapFromTemplate({
|
||||
type: () => new Map(getEntries({
|
||||
node: ModuleResolutionKind.NodeJs,
|
||||
classic: ModuleResolutionKind.Classic,
|
||||
}),
|
||||
})),
|
||||
nonNullValue: "node"
|
||||
});
|
||||
});
|
||||
|
|
|
@ -43,7 +43,7 @@ namespace ts {
|
|||
}
|
||||
|
||||
function testProjectReferences(spec: TestSpecification, entryPointConfigFileName: string, checkResult: (prog: Program, host: fakes.CompilerHost) => void) {
|
||||
const files = createMap<string>();
|
||||
const files = new Map<string, string>();
|
||||
for (const key in spec) {
|
||||
const sp = spec[key];
|
||||
const configFileName = combineAllPaths("/", key, sp.configFileName || "tsconfig.json");
|
||||
|
|
|
@ -139,11 +139,11 @@ namespace ts {
|
|||
const expectedResult = "1:1;3:3;2:Y2;4:X4;0:X0;3:Y3;999:999;A:A;Z:Z;X:X;Y:Y;";
|
||||
|
||||
// First, ensure the test actually has the same behavior as a native Map.
|
||||
let nativeMap = createMap<string>();
|
||||
let nativeMap = new Map<string, string>();
|
||||
const nativeMapForEachResult = testMapIterationAddedValues(stringKeys, nativeMap, /* useForEach */ true);
|
||||
assert.equal(nativeMapForEachResult, expectedResult, "nativeMap-forEach");
|
||||
|
||||
nativeMap = createMap<string>();
|
||||
nativeMap = new Map<string, string>();
|
||||
const nativeMapIteratorResult = testMapIterationAddedValues(stringKeys, nativeMap, /* useForEach */ false);
|
||||
assert.equal(nativeMapIteratorResult, expectedResult, "nativeMap-iterator");
|
||||
|
||||
|
@ -161,11 +161,11 @@ namespace ts {
|
|||
const expectedResult = "true:1;3:3;2:Y2;4:X4;false:X0;3:Y3;null:999;undefined:A;Z:Z;X:X;Y:Y;";
|
||||
|
||||
// First, ensure the test actually has the same behavior as a native Map.
|
||||
let nativeMap = createMap<any, string>();
|
||||
let nativeMap = new Map<any, string>();
|
||||
const nativeMapForEachResult = testMapIterationAddedValues(mixedKeys, nativeMap, /* useForEach */ true);
|
||||
assert.equal(nativeMapForEachResult, expectedResult, "nativeMap-forEach");
|
||||
|
||||
nativeMap = createMap<any, string>();
|
||||
nativeMap = new Map<any, string>();
|
||||
const nativeMapIteratorResult = testMapIterationAddedValues(mixedKeys, nativeMap, /* useForEach */ false);
|
||||
assert.equal(nativeMapIteratorResult, expectedResult, "nativeMap-iterator");
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ namespace ts {
|
|||
it(name, () => {
|
||||
const roots = sources.map(source => createSourceFile(source.file, source.text, ScriptTarget.ES2015));
|
||||
const fileMap = arrayToMap(roots, file => file.fileName);
|
||||
const outputs = createMap<string>();
|
||||
const outputs = new Map<string, string>();
|
||||
const host: CompilerHost = {
|
||||
getSourceFile: (fileName) => fileMap.get(fileName),
|
||||
getDefaultLibFileName: () => "lib.d.ts",
|
||||
|
|
|
@ -35,7 +35,7 @@ namespace ts {
|
|||
}
|
||||
|
||||
function createModuleResolutionHost(hasDirectoryExists: boolean, ...files: File[]): ModuleResolutionHost {
|
||||
const map = createMap<File>();
|
||||
const map = new Map<string, File>();
|
||||
for (const file of files) {
|
||||
map.set(file.name, file);
|
||||
if (file.symlinks) {
|
||||
|
@ -46,7 +46,7 @@ namespace ts {
|
|||
}
|
||||
|
||||
if (hasDirectoryExists) {
|
||||
const directories = createMap<string>();
|
||||
const directories = new Map<string, string>();
|
||||
for (const f of files) {
|
||||
let name = getDirectoryPath(f.name);
|
||||
while (true) {
|
||||
|
@ -495,7 +495,7 @@ namespace ts {
|
|||
}
|
||||
|
||||
it("should find all modules", () => {
|
||||
const files = createMapFromTemplate({
|
||||
const files = new Map(getEntries({
|
||||
"/a/b/c/first/shared.ts": `
|
||||
class A {}
|
||||
export = A`,
|
||||
|
@ -509,23 +509,23 @@ import Shared = require('../first/shared');
|
|||
class C {}
|
||||
export = C;
|
||||
`
|
||||
});
|
||||
}));
|
||||
test(files, "/a/b/c/first/second", ["class_a.ts"], 3, ["../../../c/third/class_c.ts"]);
|
||||
});
|
||||
|
||||
it("should find modules in node_modules", () => {
|
||||
const files = createMapFromTemplate({
|
||||
const files = new Map(getEntries({
|
||||
"/parent/node_modules/mod/index.d.ts": "export var x",
|
||||
"/parent/app/myapp.ts": `import {x} from "mod"`
|
||||
});
|
||||
}));
|
||||
test(files, "/parent/app", ["myapp.ts"], 2, []);
|
||||
});
|
||||
|
||||
it("should find file referenced via absolute and relative names", () => {
|
||||
const files = createMapFromTemplate({
|
||||
const files = new Map(getEntries({
|
||||
"/a/b/c.ts": `/// <reference path="b.ts"/>`,
|
||||
"/a/b/b.ts": "var x"
|
||||
});
|
||||
}));
|
||||
test(files, "/a/b", ["c.ts", "/a/b/b.ts"], 2, []);
|
||||
});
|
||||
});
|
||||
|
@ -543,7 +543,7 @@ export = C;
|
|||
const getCanonicalFileName = createGetCanonicalFileName(useCaseSensitiveFileNames);
|
||||
if (!useCaseSensitiveFileNames) {
|
||||
const oldFiles = files;
|
||||
files = createMap<string>();
|
||||
files = new Map<string, string>();
|
||||
oldFiles.forEach((file, fileName) => {
|
||||
files.set(getCanonicalFileName(fileName), file);
|
||||
});
|
||||
|
@ -580,10 +580,10 @@ export = C;
|
|||
}
|
||||
|
||||
it("should succeed when the same file is referenced using absolute and relative names", () => {
|
||||
const files = createMapFromTemplate({
|
||||
const files = new Map(getEntries({
|
||||
"/a/b/c.ts": `/// <reference path="d.ts"/>`,
|
||||
"/a/b/d.ts": "var x"
|
||||
});
|
||||
}));
|
||||
test(
|
||||
files,
|
||||
{ module: ModuleKind.AMD },
|
||||
|
@ -595,10 +595,10 @@ export = C;
|
|||
});
|
||||
|
||||
it("should fail when two files used in program differ only in casing (tripleslash references)", () => {
|
||||
const files = createMapFromTemplate({
|
||||
const files = new Map(getEntries({
|
||||
"/a/b/c.ts": `/// <reference path="D.ts"/>`,
|
||||
"/a/b/d.ts": "var x"
|
||||
});
|
||||
}));
|
||||
test(
|
||||
files,
|
||||
{ module: ModuleKind.AMD, forceConsistentCasingInFileNames: true },
|
||||
|
@ -622,10 +622,10 @@ export = C;
|
|||
});
|
||||
|
||||
it("should fail when two files used in program differ only in casing (imports)", () => {
|
||||
const files = createMapFromTemplate({
|
||||
const files = new Map(getEntries({
|
||||
"/a/b/c.ts": `import {x} from "D"`,
|
||||
"/a/b/d.ts": "export var x"
|
||||
});
|
||||
}));
|
||||
test(
|
||||
files,
|
||||
{ module: ModuleKind.AMD, forceConsistentCasingInFileNames: true },
|
||||
|
@ -649,10 +649,10 @@ export = C;
|
|||
});
|
||||
|
||||
it("should fail when two files used in program differ only in casing (imports, relative module names)", () => {
|
||||
const files = createMapFromTemplate({
|
||||
const files = new Map(getEntries({
|
||||
"moduleA.ts": `import {x} from "./ModuleB"`,
|
||||
"moduleB.ts": "export var x"
|
||||
});
|
||||
}));
|
||||
test(
|
||||
files,
|
||||
{ module: ModuleKind.CommonJS, forceConsistentCasingInFileNames: true },
|
||||
|
@ -676,11 +676,11 @@ export = C;
|
|||
});
|
||||
|
||||
it("should fail when two files exist on disk that differs only in casing", () => {
|
||||
const files = createMapFromTemplate({
|
||||
const files = new Map(getEntries({
|
||||
"/a/b/c.ts": `import {x} from "D"`,
|
||||
"/a/b/D.ts": "export var x",
|
||||
"/a/b/d.ts": "export var y"
|
||||
});
|
||||
}));
|
||||
test(
|
||||
files,
|
||||
{ module: ModuleKind.AMD },
|
||||
|
@ -704,11 +704,11 @@ export = C;
|
|||
});
|
||||
|
||||
it("should fail when module name in 'require' calls has inconsistent casing", () => {
|
||||
const files = createMapFromTemplate({
|
||||
const files = new Map(getEntries({
|
||||
"moduleA.ts": `import a = require("./ModuleC")`,
|
||||
"moduleB.ts": `import a = require("./moduleC")`,
|
||||
"moduleC.ts": "export var x"
|
||||
});
|
||||
}));
|
||||
test(
|
||||
files,
|
||||
{ module: ModuleKind.CommonJS, forceConsistentCasingInFileNames: true },
|
||||
|
@ -747,7 +747,7 @@ export = C;
|
|||
});
|
||||
|
||||
it("should fail when module names in 'require' calls has inconsistent casing and current directory has uppercase chars", () => {
|
||||
const files = createMapFromTemplate({
|
||||
const files = new Map(getEntries({
|
||||
"/a/B/c/moduleA.ts": `import a = require("./ModuleC")`,
|
||||
"/a/B/c/moduleB.ts": `import a = require("./moduleC")`,
|
||||
"/a/B/c/moduleC.ts": "export var x",
|
||||
|
@ -755,7 +755,7 @@ export = C;
|
|||
import a = require("./moduleA");
|
||||
import b = require("./moduleB");
|
||||
`
|
||||
});
|
||||
}));
|
||||
test(
|
||||
files,
|
||||
{ module: ModuleKind.CommonJS, forceConsistentCasingInFileNames: true },
|
||||
|
@ -778,7 +778,7 @@ import b = require("./moduleB");
|
|||
);
|
||||
});
|
||||
it("should not fail when module names in 'require' calls has consistent casing and current directory has uppercase chars", () => {
|
||||
const files = createMapFromTemplate({
|
||||
const files = new Map(getEntries({
|
||||
"/a/B/c/moduleA.ts": `import a = require("./moduleC")`,
|
||||
"/a/B/c/moduleB.ts": `import a = require("./moduleC")`,
|
||||
"/a/B/c/moduleC.ts": "export var x",
|
||||
|
@ -786,7 +786,7 @@ import b = require("./moduleB");
|
|||
import a = require("./moduleA");
|
||||
import b = require("./moduleB");
|
||||
`
|
||||
});
|
||||
}));
|
||||
test(
|
||||
files,
|
||||
{ module: ModuleKind.CommonJS, forceConsistentCasingInFileNames: true },
|
||||
|
@ -798,11 +798,11 @@ import b = require("./moduleB");
|
|||
});
|
||||
|
||||
it("should succeed when the two files in program differ only in drive letter in their names", () => {
|
||||
const files = createMapFromTemplate({
|
||||
const files = new Map(getEntries({
|
||||
"d:/someFolder/moduleA.ts": `import a = require("D:/someFolder/moduleC")`,
|
||||
"d:/someFolder/moduleB.ts": `import a = require("./moduleC")`,
|
||||
"D:/someFolder/moduleC.ts": "export const x = 10",
|
||||
});
|
||||
}));
|
||||
test(
|
||||
files,
|
||||
{ module: ModuleKind.CommonJS, forceConsistentCasingInFileNames: true },
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
namespace ts {
|
||||
function verifyMissingFilePaths(missingPaths: readonly Path[], expected: readonly string[]) {
|
||||
assert.isDefined(missingPaths);
|
||||
const map = arrayToSet(expected) as ESMap<string, boolean>;
|
||||
const map = new Set(expected);
|
||||
for (const missing of missingPaths) {
|
||||
const value = map.get(missing);
|
||||
const value = map.has(missing);
|
||||
assert.isTrue(value, `${missing} to be ${value === undefined ? "not present" : "present only once"}, in actual: ${missingPaths} expected: ${expected}`);
|
||||
map.set(missing, false);
|
||||
map.delete(missing);
|
||||
}
|
||||
const notFound = arrayFrom(mapDefinedIterator(map.keys(), k => map.get(k) === true ? k : undefined));
|
||||
const notFound = arrayFrom(mapDefinedIterator(map.keys(), k => map.has(k) ? k : undefined));
|
||||
assert.equal(notFound.length, 0, `Not found ${notFound} in actual: ${missingPaths} expected: ${expected}`);
|
||||
}
|
||||
|
||||
|
|
|
@ -344,7 +344,7 @@ namespace ts {
|
|||
const options: CompilerOptions = { target };
|
||||
|
||||
const program1 = newProgram(files, ["a.ts"], options);
|
||||
checkResolvedModulesCache(program1, "a.ts", createMapFromTemplate({ b: createResolvedModule("b.ts") }));
|
||||
checkResolvedModulesCache(program1, "a.ts", new Map(getEntries({ b: createResolvedModule("b.ts") })));
|
||||
checkResolvedModulesCache(program1, "b.ts", /*expectedContent*/ undefined);
|
||||
|
||||
const program2 = updateProgram(program1, ["a.ts"], options, files => {
|
||||
|
@ -353,7 +353,7 @@ namespace ts {
|
|||
assert.equal(program1.structureIsReused, StructureIsReused.Completely);
|
||||
|
||||
// content of resolution cache should not change
|
||||
checkResolvedModulesCache(program1, "a.ts", createMapFromTemplate({ b: createResolvedModule("b.ts") }));
|
||||
checkResolvedModulesCache(program1, "a.ts", new Map(getEntries({ b: createResolvedModule("b.ts") })));
|
||||
checkResolvedModulesCache(program1, "b.ts", /*expectedContent*/ undefined);
|
||||
|
||||
// imports has changed - program is not reused
|
||||
|
@ -370,7 +370,7 @@ namespace ts {
|
|||
files[0].text = files[0].text.updateImportsAndExports(newImports);
|
||||
});
|
||||
assert.equal(program3.structureIsReused, StructureIsReused.SafeModules);
|
||||
checkResolvedModulesCache(program4, "a.ts", createMapFromTemplate({ b: createResolvedModule("b.ts"), c: undefined }));
|
||||
checkResolvedModulesCache(program4, "a.ts", new Map(getEntries({ b: createResolvedModule("b.ts"), c: undefined })));
|
||||
});
|
||||
|
||||
it("set the resolvedImports after re-using an ambient external module declaration", () => {
|
||||
|
@ -418,7 +418,7 @@ namespace ts {
|
|||
const options: CompilerOptions = { target, typeRoots: ["/types"] };
|
||||
|
||||
const program1 = newProgram(files, ["/a.ts"], options);
|
||||
checkResolvedTypeDirectivesCache(program1, "/a.ts", createMapFromTemplate({ typedefs: { resolvedFileName: "/types/typedefs/index.d.ts", primary: true } }));
|
||||
checkResolvedTypeDirectivesCache(program1, "/a.ts", new Map(getEntries({ typedefs: { resolvedFileName: "/types/typedefs/index.d.ts", primary: true } })));
|
||||
checkResolvedTypeDirectivesCache(program1, "/types/typedefs/index.d.ts", /*expectedContent*/ undefined);
|
||||
|
||||
const program2 = updateProgram(program1, ["/a.ts"], options, files => {
|
||||
|
@ -427,7 +427,7 @@ namespace ts {
|
|||
assert.equal(program1.structureIsReused, StructureIsReused.Completely);
|
||||
|
||||
// content of resolution cache should not change
|
||||
checkResolvedTypeDirectivesCache(program1, "/a.ts", createMapFromTemplate({ typedefs: { resolvedFileName: "/types/typedefs/index.d.ts", primary: true } }));
|
||||
checkResolvedTypeDirectivesCache(program1, "/a.ts", new Map(getEntries({ typedefs: { resolvedFileName: "/types/typedefs/index.d.ts", primary: true } })));
|
||||
checkResolvedTypeDirectivesCache(program1, "/types/typedefs/index.d.ts", /*expectedContent*/ undefined);
|
||||
|
||||
// type reference directives has changed - program is not reused
|
||||
|
@ -445,7 +445,7 @@ namespace ts {
|
|||
files[0].text = files[0].text.updateReferences(newReferences);
|
||||
});
|
||||
assert.equal(program3.structureIsReused, StructureIsReused.SafeModules);
|
||||
checkResolvedTypeDirectivesCache(program1, "/a.ts", createMapFromTemplate({ typedefs: { resolvedFileName: "/types/typedefs/index.d.ts", primary: true } }));
|
||||
checkResolvedTypeDirectivesCache(program1, "/a.ts", new Map(getEntries({ typedefs: { resolvedFileName: "/types/typedefs/index.d.ts", primary: true } })));
|
||||
});
|
||||
|
||||
it("fetches imports after npm install", () => {
|
||||
|
|
|
@ -15,7 +15,7 @@ namespace ts {
|
|||
let text = "";
|
||||
let lastPos = 0;
|
||||
let pos = 0;
|
||||
const ranges = createMap<Range>();
|
||||
const ranges = new Map<string, Range>();
|
||||
|
||||
while (pos < source.length) {
|
||||
if (source.charCodeAt(pos) === CharacterCodes.openBracket &&
|
||||
|
|
|
@ -86,7 +86,7 @@ export function Component(x: Config): any;`
|
|||
describe("detects program upto date correctly", () => {
|
||||
function verifyProgramUptoDate(useProjectVersion: boolean) {
|
||||
let projectVersion = "1";
|
||||
const files = createMap<{ version: string, text: string; }>();
|
||||
const files = new Map<string, { version: string, text: string; }>();
|
||||
files.set("/project/root.ts", { version: "1", text: `import { foo } from "./other"` });
|
||||
files.set("/project/other.ts", { version: "1", text: `export function foo() { }` });
|
||||
files.set("/lib/lib.d.ts", { version: "1", text: projectSystem.libFile.content });
|
||||
|
|
|
@ -316,7 +316,7 @@ namespace ts {
|
|||
tick();
|
||||
appendText(fs, "/src/logic/index.ts", "function foo() {}");
|
||||
const originalWriteFile = fs.writeFileSync;
|
||||
const writtenFiles = createMap<true>();
|
||||
const writtenFiles = new Map<string, true>();
|
||||
fs.writeFileSync = (path, data, encoding) => {
|
||||
writtenFiles.set(path, true);
|
||||
originalWriteFile.call(fs, path, data, encoding);
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue