typescript 5.6.0-dev.20240819 → 5.7.0-dev.20240821
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/tsc.js +124 -43
- package/lib/typesMap.json +497 -497
- package/lib/typescript.d.ts +22 -1
- package/lib/typescript.js +270 -96
- package/package.json +2 -2
package/lib/typescript.js
CHANGED
|
@@ -2262,8 +2262,8 @@ __export(typescript_exports, {
|
|
|
2262
2262
|
module.exports = __toCommonJS(typescript_exports);
|
|
2263
2263
|
|
|
2264
2264
|
// src/compiler/corePublic.ts
|
|
2265
|
-
var versionMajorMinor = "5.
|
|
2266
|
-
var version = `${versionMajorMinor}.0-dev.
|
|
2265
|
+
var versionMajorMinor = "5.7";
|
|
2266
|
+
var version = `${versionMajorMinor}.0-dev.20240821`;
|
|
2267
2267
|
var Comparison = /* @__PURE__ */ ((Comparison3) => {
|
|
2268
2268
|
Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
|
|
2269
2269
|
Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
|
|
@@ -21026,6 +21026,9 @@ function accessKind(node) {
|
|
|
21026
21026
|
return node === parent2.objectAssignmentInitializer ? 0 /* Read */ : accessKind(parent2.parent);
|
|
21027
21027
|
case 209 /* ArrayLiteralExpression */:
|
|
21028
21028
|
return accessKind(parent2);
|
|
21029
|
+
case 249 /* ForInStatement */:
|
|
21030
|
+
case 250 /* ForOfStatement */:
|
|
21031
|
+
return node === parent2.initializer ? 1 /* Write */ : 0 /* Read */;
|
|
21029
21032
|
default:
|
|
21030
21033
|
return 0 /* Read */;
|
|
21031
21034
|
}
|
|
@@ -74394,6 +74397,12 @@ function createTypeChecker(host) {
|
|
|
74394
74397
|
function getControlFlowContainer(node) {
|
|
74395
74398
|
return findAncestor(node.parent, (node2) => isFunctionLike(node2) && !getImmediatelyInvokedFunctionExpression(node2) || node2.kind === 268 /* ModuleBlock */ || node2.kind === 307 /* SourceFile */ || node2.kind === 172 /* PropertyDeclaration */);
|
|
74396
74399
|
}
|
|
74400
|
+
function isSymbolAssignedDefinitely(symbol) {
|
|
74401
|
+
if (symbol.lastAssignmentPos !== void 0) {
|
|
74402
|
+
return symbol.lastAssignmentPos < 0;
|
|
74403
|
+
}
|
|
74404
|
+
return isSymbolAssigned(symbol) && symbol.lastAssignmentPos !== void 0 && symbol.lastAssignmentPos < 0;
|
|
74405
|
+
}
|
|
74397
74406
|
function isSymbolAssigned(symbol) {
|
|
74398
74407
|
return !isPastLastAssignment(
|
|
74399
74408
|
symbol,
|
|
@@ -74413,7 +74422,7 @@ function createTypeChecker(host) {
|
|
|
74413
74422
|
markNodeAssignments(parent2);
|
|
74414
74423
|
}
|
|
74415
74424
|
}
|
|
74416
|
-
return !symbol.lastAssignmentPos || location && symbol.lastAssignmentPos < location.pos;
|
|
74425
|
+
return !symbol.lastAssignmentPos || location && Math.abs(symbol.lastAssignmentPos) < location.pos;
|
|
74417
74426
|
}
|
|
74418
74427
|
function isSomeSymbolAssigned(rootDeclaration) {
|
|
74419
74428
|
Debug.assert(isVariableDeclaration(rootDeclaration) || isParameter(rootDeclaration));
|
|
@@ -74434,12 +74443,19 @@ function createTypeChecker(host) {
|
|
|
74434
74443
|
function markNodeAssignments(node) {
|
|
74435
74444
|
switch (node.kind) {
|
|
74436
74445
|
case 80 /* Identifier */:
|
|
74437
|
-
|
|
74446
|
+
const assigmentTarget = getAssignmentTargetKind(node);
|
|
74447
|
+
if (assigmentTarget !== 0 /* None */) {
|
|
74438
74448
|
const symbol = getResolvedSymbol(node);
|
|
74439
|
-
|
|
74440
|
-
|
|
74441
|
-
|
|
74442
|
-
|
|
74449
|
+
const hasDefiniteAssignment = assigmentTarget === 1 /* Definite */ || symbol.lastAssignmentPos !== void 0 && symbol.lastAssignmentPos < 0;
|
|
74450
|
+
if (isParameterOrMutableLocalVariable(symbol)) {
|
|
74451
|
+
if (symbol.lastAssignmentPos === void 0 || Math.abs(symbol.lastAssignmentPos) !== Number.MAX_VALUE) {
|
|
74452
|
+
const referencingFunction = findAncestor(node, isFunctionOrSourceFile);
|
|
74453
|
+
const declaringFunction = findAncestor(symbol.valueDeclaration, isFunctionOrSourceFile);
|
|
74454
|
+
symbol.lastAssignmentPos = referencingFunction === declaringFunction ? extendAssignmentPosition(node, symbol.valueDeclaration) : Number.MAX_VALUE;
|
|
74455
|
+
}
|
|
74456
|
+
if (hasDefiniteAssignment && symbol.lastAssignmentPos > 0) {
|
|
74457
|
+
symbol.lastAssignmentPos *= -1;
|
|
74458
|
+
}
|
|
74443
74459
|
}
|
|
74444
74460
|
}
|
|
74445
74461
|
return;
|
|
@@ -74456,7 +74472,8 @@ function createTypeChecker(host) {
|
|
|
74456
74472
|
true
|
|
74457
74473
|
);
|
|
74458
74474
|
if (symbol && isParameterOrMutableLocalVariable(symbol)) {
|
|
74459
|
-
symbol.lastAssignmentPos
|
|
74475
|
+
const sign = symbol.lastAssignmentPos !== void 0 && symbol.lastAssignmentPos < 0 ? -1 : 1;
|
|
74476
|
+
symbol.lastAssignmentPos = sign * Number.MAX_VALUE;
|
|
74460
74477
|
}
|
|
74461
74478
|
}
|
|
74462
74479
|
return;
|
|
@@ -75040,6 +75057,7 @@ function createTypeChecker(host) {
|
|
|
75040
75057
|
}
|
|
75041
75058
|
const localOrExportSymbol = getExportSymbolOfValueSymbolIfExported(symbol);
|
|
75042
75059
|
let declaration = localOrExportSymbol.valueDeclaration;
|
|
75060
|
+
const immediateDeclaration = declaration;
|
|
75043
75061
|
if (declaration && declaration.kind === 208 /* BindingElement */ && contains(contextualBindingPatterns, declaration.parent) && findAncestor(node, (parent2) => parent2 === declaration.parent)) {
|
|
75044
75062
|
return nonInferrableAnyType;
|
|
75045
75063
|
}
|
|
@@ -75085,7 +75103,8 @@ function createTypeChecker(host) {
|
|
|
75085
75103
|
while (flowContainer !== declarationContainer && (flowContainer.kind === 218 /* FunctionExpression */ || flowContainer.kind === 219 /* ArrowFunction */ || isObjectLiteralOrClassExpressionMethodOrAccessor(flowContainer)) && (isConstantVariable(localOrExportSymbol) && type !== autoArrayType || isParameterOrMutableLocalVariable(localOrExportSymbol) && isPastLastAssignment(localOrExportSymbol, node))) {
|
|
75086
75104
|
flowContainer = getControlFlowContainer(flowContainer);
|
|
75087
75105
|
}
|
|
75088
|
-
const
|
|
75106
|
+
const isNeverInitialized = immediateDeclaration && isVariableDeclaration(immediateDeclaration) && !immediateDeclaration.initializer && !immediateDeclaration.exclamationToken && isMutableLocalVariableDeclaration(immediateDeclaration) && !isSymbolAssignedDefinitely(symbol);
|
|
75107
|
+
const assumeInitialized = isParameter2 || isAlias || isOuterVariable && !isNeverInitialized || isSpreadDestructuringAssignmentTarget || isModuleExports || isSameScopedBindingElement(node, declaration) || type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & (3 /* AnyOrUnknown */ | 16384 /* Void */)) !== 0 || isInTypeQuery(node) || isInAmbientOrTypeNode(node) || node.parent.kind === 281 /* ExportSpecifier */) || node.parent.kind === 235 /* NonNullExpression */ || declaration.kind === 260 /* VariableDeclaration */ && declaration.exclamationToken || declaration.flags & 33554432 /* Ambient */;
|
|
75089
75108
|
const initialType = isAutomaticTypeInNonNull ? undefinedType : assumeInitialized ? isParameter2 ? removeOptionalityFromDeclaredType(type, declaration) : type : typeIsAutomatic ? undefinedType : getOptionalType(type);
|
|
75090
75109
|
const flowType = isAutomaticTypeInNonNull ? getNonNullableType(getFlowTypeOfReference(node, type, initialType, flowContainer)) : getFlowTypeOfReference(node, type, initialType, flowContainer);
|
|
75091
75110
|
if (!isEvolvingArrayOperationTarget(node) && (type === autoType || type === autoArrayType)) {
|
|
@@ -75990,46 +76009,108 @@ function createTypeChecker(host) {
|
|
|
75990
76009
|
function isCircularMappedProperty(symbol) {
|
|
75991
76010
|
return !!(getCheckFlags(symbol) & 262144 /* Mapped */ && !symbol.links.type && findResolutionCycleStartIndex(symbol, 0 /* Type */) >= 0);
|
|
75992
76011
|
}
|
|
76012
|
+
function isExcludedMappedPropertyName(constraint, propertyNameType) {
|
|
76013
|
+
if (constraint.flags & 16777216 /* Conditional */) {
|
|
76014
|
+
const type = constraint;
|
|
76015
|
+
return !!(getReducedType(getTrueTypeFromConditionalType(type)).flags & 131072 /* Never */) && getActualTypeVariable(getFalseTypeFromConditionalType(type)) === getActualTypeVariable(type.checkType) && isTypeAssignableTo(propertyNameType, type.extendsType);
|
|
76016
|
+
}
|
|
76017
|
+
if (constraint.flags & 2097152 /* Intersection */) {
|
|
76018
|
+
return some(constraint.types, (t) => isExcludedMappedPropertyName(t, propertyNameType));
|
|
76019
|
+
}
|
|
76020
|
+
return false;
|
|
76021
|
+
}
|
|
75993
76022
|
function getTypeOfPropertyOfContextualType(type, name, nameType) {
|
|
75994
76023
|
return mapType(
|
|
75995
76024
|
type,
|
|
75996
76025
|
(t) => {
|
|
75997
|
-
|
|
75998
|
-
|
|
75999
|
-
|
|
76000
|
-
|
|
76001
|
-
const
|
|
76002
|
-
|
|
76003
|
-
|
|
76004
|
-
|
|
76005
|
-
|
|
76006
|
-
|
|
76007
|
-
|
|
76008
|
-
|
|
76026
|
+
if (t.flags & 2097152 /* Intersection */) {
|
|
76027
|
+
let types;
|
|
76028
|
+
let indexInfoCandidates;
|
|
76029
|
+
let ignoreIndexInfos = false;
|
|
76030
|
+
for (const constituentType of t.types) {
|
|
76031
|
+
if (!(constituentType.flags & 524288 /* Object */)) {
|
|
76032
|
+
continue;
|
|
76033
|
+
}
|
|
76034
|
+
if (isGenericMappedType(constituentType) && getMappedTypeNameTypeKind(constituentType) !== 2 /* Remapping */) {
|
|
76035
|
+
const substitutedType = getIndexedMappedTypeSubstitutedTypeOfContextualType(constituentType, name, nameType);
|
|
76036
|
+
types = appendContextualPropertyTypeConstituent(types, substitutedType);
|
|
76037
|
+
continue;
|
|
76038
|
+
}
|
|
76039
|
+
const propertyType = getTypeOfConcretePropertyOfContextualType(constituentType, name);
|
|
76040
|
+
if (!propertyType) {
|
|
76041
|
+
if (!ignoreIndexInfos) {
|
|
76042
|
+
indexInfoCandidates = append(indexInfoCandidates, constituentType);
|
|
76043
|
+
}
|
|
76044
|
+
continue;
|
|
76045
|
+
}
|
|
76046
|
+
ignoreIndexInfos = true;
|
|
76047
|
+
indexInfoCandidates = void 0;
|
|
76048
|
+
types = appendContextualPropertyTypeConstituent(types, propertyType);
|
|
76009
76049
|
}
|
|
76010
|
-
if (
|
|
76011
|
-
const
|
|
76012
|
-
|
|
76013
|
-
|
|
76014
|
-
/*endSkipCount*/
|
|
76015
|
-
0,
|
|
76016
|
-
/*writing*/
|
|
76017
|
-
false,
|
|
76018
|
-
/*noReductions*/
|
|
76019
|
-
true
|
|
76020
|
-
);
|
|
76021
|
-
if (restType) {
|
|
76022
|
-
return restType;
|
|
76050
|
+
if (indexInfoCandidates) {
|
|
76051
|
+
for (const candidate of indexInfoCandidates) {
|
|
76052
|
+
const indexInfoType = getTypeFromIndexInfosOfContextualType(candidate, name, nameType);
|
|
76053
|
+
types = appendContextualPropertyTypeConstituent(types, indexInfoType);
|
|
76023
76054
|
}
|
|
76024
76055
|
}
|
|
76025
|
-
|
|
76056
|
+
if (!types) {
|
|
76057
|
+
return;
|
|
76058
|
+
}
|
|
76059
|
+
if (types.length === 1) {
|
|
76060
|
+
return types[0];
|
|
76061
|
+
}
|
|
76062
|
+
return getIntersectionType(types);
|
|
76026
76063
|
}
|
|
76027
|
-
|
|
76064
|
+
if (!(t.flags & 524288 /* Object */)) {
|
|
76065
|
+
return;
|
|
76066
|
+
}
|
|
76067
|
+
return isGenericMappedType(t) && getMappedTypeNameTypeKind(t) !== 2 /* Remapping */ ? getIndexedMappedTypeSubstitutedTypeOfContextualType(t, name, nameType) : getTypeOfConcretePropertyOfContextualType(t, name) ?? getTypeFromIndexInfosOfContextualType(t, name, nameType);
|
|
76028
76068
|
},
|
|
76029
76069
|
/*noReductions*/
|
|
76030
76070
|
true
|
|
76031
76071
|
);
|
|
76032
76072
|
}
|
|
76073
|
+
function appendContextualPropertyTypeConstituent(types, type) {
|
|
76074
|
+
return type ? append(types, type.flags & 1 /* Any */ ? unknownType : type) : types;
|
|
76075
|
+
}
|
|
76076
|
+
function getIndexedMappedTypeSubstitutedTypeOfContextualType(type, name, nameType) {
|
|
76077
|
+
const propertyNameType = nameType || getStringLiteralType(unescapeLeadingUnderscores(name));
|
|
76078
|
+
const constraint = getConstraintTypeFromMappedType(type);
|
|
76079
|
+
if (type.nameType && isExcludedMappedPropertyName(type.nameType, propertyNameType) || isExcludedMappedPropertyName(constraint, propertyNameType)) {
|
|
76080
|
+
return;
|
|
76081
|
+
}
|
|
76082
|
+
const constraintOfConstraint = getBaseConstraintOfType(constraint) || constraint;
|
|
76083
|
+
if (!isTypeAssignableTo(propertyNameType, constraintOfConstraint)) {
|
|
76084
|
+
return;
|
|
76085
|
+
}
|
|
76086
|
+
return substituteIndexedMappedType(type, propertyNameType);
|
|
76087
|
+
}
|
|
76088
|
+
function getTypeOfConcretePropertyOfContextualType(type, name) {
|
|
76089
|
+
const prop = getPropertyOfType(type, name);
|
|
76090
|
+
if (!prop || isCircularMappedProperty(prop)) {
|
|
76091
|
+
return;
|
|
76092
|
+
}
|
|
76093
|
+
return removeMissingType(getTypeOfSymbol(prop), !!(prop.flags & 16777216 /* Optional */));
|
|
76094
|
+
}
|
|
76095
|
+
function getTypeFromIndexInfosOfContextualType(type, name, nameType) {
|
|
76096
|
+
var _a;
|
|
76097
|
+
if (isTupleType(type) && isNumericLiteralName(name) && +name >= 0) {
|
|
76098
|
+
const restType = getElementTypeOfSliceOfTupleType(
|
|
76099
|
+
type,
|
|
76100
|
+
type.target.fixedLength,
|
|
76101
|
+
/*endSkipCount*/
|
|
76102
|
+
0,
|
|
76103
|
+
/*writing*/
|
|
76104
|
+
false,
|
|
76105
|
+
/*noReductions*/
|
|
76106
|
+
true
|
|
76107
|
+
);
|
|
76108
|
+
if (restType) {
|
|
76109
|
+
return restType;
|
|
76110
|
+
}
|
|
76111
|
+
}
|
|
76112
|
+
return (_a = findApplicableIndexInfo(getIndexInfosOfStructuredType(type), nameType || getStringLiteralType(unescapeLeadingUnderscores(name)))) == null ? void 0 : _a.type;
|
|
76113
|
+
}
|
|
76033
76114
|
function getContextualTypeForObjectLiteralMethod(node, contextFlags) {
|
|
76034
76115
|
Debug.assert(isObjectLiteralMethod(node));
|
|
76035
76116
|
if (node.flags & 67108864 /* InWithStatement */) {
|
|
@@ -96209,7 +96290,7 @@ function transformTypeScript(context) {
|
|
|
96209
96290
|
let currentNamespaceContainerName;
|
|
96210
96291
|
let currentLexicalScope;
|
|
96211
96292
|
let currentScopeFirstDeclarationsOfName;
|
|
96212
|
-
let enabledSubstitutions
|
|
96293
|
+
let enabledSubstitutions = 0 /* None */;
|
|
96213
96294
|
let applicableSubstitutions;
|
|
96214
96295
|
return transformSourceFileOrBundle;
|
|
96215
96296
|
function transformSourceFileOrBundle(node) {
|
|
@@ -98017,7 +98098,7 @@ function transformClassFields(context) {
|
|
|
98017
98098
|
const previousOnEmitNode = context.onEmitNode;
|
|
98018
98099
|
context.onEmitNode = onEmitNode;
|
|
98019
98100
|
let shouldTransformPrivateStaticElementsInFile = false;
|
|
98020
|
-
let enabledSubstitutions
|
|
98101
|
+
let enabledSubstitutions = 0 /* None */;
|
|
98021
98102
|
let classAliases;
|
|
98022
98103
|
let pendingExpressions;
|
|
98023
98104
|
let pendingStatements;
|
|
@@ -102946,7 +103027,7 @@ function transformES2017(context) {
|
|
|
102946
103027
|
const resolver = context.getEmitResolver();
|
|
102947
103028
|
const compilerOptions = context.getCompilerOptions();
|
|
102948
103029
|
const languageVersion = getEmitScriptTarget(compilerOptions);
|
|
102949
|
-
let enabledSubstitutions
|
|
103030
|
+
let enabledSubstitutions = 0 /* None */;
|
|
102950
103031
|
let enclosingSuperContainerFlags = 0;
|
|
102951
103032
|
let enclosingFunctionParameterNames;
|
|
102952
103033
|
let capturedSuperProperties;
|
|
@@ -103821,7 +103902,7 @@ function transformES2018(context) {
|
|
|
103821
103902
|
const previousOnSubstituteNode = context.onSubstituteNode;
|
|
103822
103903
|
context.onSubstituteNode = onSubstituteNode;
|
|
103823
103904
|
let exportedVariableStatement = false;
|
|
103824
|
-
let enabledSubstitutions
|
|
103905
|
+
let enabledSubstitutions = 0 /* None */;
|
|
103825
103906
|
let enclosingFunctionFlags;
|
|
103826
103907
|
let parametersWithPrecedingObjectRestOrSpread;
|
|
103827
103908
|
let enclosingSuperContainerFlags = 0;
|
|
@@ -106956,7 +107037,7 @@ function transformES2015(context) {
|
|
|
106956
107037
|
);
|
|
106957
107038
|
}
|
|
106958
107039
|
let convertedLoopState;
|
|
106959
|
-
let enabledSubstitutions
|
|
107040
|
+
let enabledSubstitutions = 0 /* None */;
|
|
106960
107041
|
return chainBundle(context, transformSourceFile);
|
|
106961
107042
|
function transformSourceFile(node) {
|
|
106962
107043
|
if (node.isDeclarationFile) {
|
|
@@ -163481,6 +163562,8 @@ var SortText = {
|
|
|
163481
163562
|
return sortText + "1";
|
|
163482
163563
|
}
|
|
163483
163564
|
};
|
|
163565
|
+
var allCommitCharacters = [".", ",", ";"];
|
|
163566
|
+
var noCommaCommitCharacters = [".", ";"];
|
|
163484
163567
|
var CompletionSource = /* @__PURE__ */ ((CompletionSource2) => {
|
|
163485
163568
|
CompletionSource2["ThisProperty"] = "ThisProperty/";
|
|
163486
163569
|
CompletionSource2["ClassMemberSnippet"] = "ClassMemberSnippet/";
|
|
@@ -163587,7 +163670,7 @@ function getDefaultCommitCharacters(isNewIdentifierLocation) {
|
|
|
163587
163670
|
if (isNewIdentifierLocation) {
|
|
163588
163671
|
return [];
|
|
163589
163672
|
}
|
|
163590
|
-
return
|
|
163673
|
+
return allCommitCharacters;
|
|
163591
163674
|
}
|
|
163592
163675
|
function getCompletionsAtPosition(host, program, log, sourceFile, position, preferences, triggerCharacter, completionKind, cancellationToken, formatContext, includeSymbol = false) {
|
|
163593
163676
|
var _a;
|
|
@@ -164085,7 +164168,8 @@ function completionInfoFromData(sourceFile, host, program, compilerOptions, log,
|
|
|
164085
164168
|
importStatementCompletion,
|
|
164086
164169
|
insideJsDocTagTypeExpression,
|
|
164087
164170
|
symbolToSortTextMap,
|
|
164088
|
-
hasUnresolvedAutoImports
|
|
164171
|
+
hasUnresolvedAutoImports,
|
|
164172
|
+
defaultCommitCharacters
|
|
164089
164173
|
} = completionData;
|
|
164090
164174
|
let literals = completionData.literals;
|
|
164091
164175
|
const checker = program.getTypeChecker();
|
|
@@ -164203,7 +164287,7 @@ function completionInfoFromData(sourceFile, host, program, compilerOptions, log,
|
|
|
164203
164287
|
isNewIdentifierLocation,
|
|
164204
164288
|
optionalReplacementSpan: getOptionalReplacementSpan(location),
|
|
164205
164289
|
entries,
|
|
164206
|
-
defaultCommitCharacters: getDefaultCommitCharacters(isNewIdentifierLocation)
|
|
164290
|
+
defaultCommitCharacters: defaultCommitCharacters ?? getDefaultCommitCharacters(isNewIdentifierLocation)
|
|
164207
164291
|
};
|
|
164208
164292
|
}
|
|
164209
164293
|
function isCheckedFile(sourceFile, compilerOptions) {
|
|
@@ -165602,6 +165686,7 @@ function getCompletionData(program, log, sourceFile, compilerOptions, position,
|
|
|
165602
165686
|
let keywordFilters = 0 /* None */;
|
|
165603
165687
|
let isNewIdentifierLocation = false;
|
|
165604
165688
|
let flags = 0 /* None */;
|
|
165689
|
+
let defaultCommitCharacters;
|
|
165605
165690
|
if (contextToken) {
|
|
165606
165691
|
const importStatementCompletionInfo = getImportStatementCompletionInfo(contextToken, sourceFile);
|
|
165607
165692
|
if (importStatementCompletionInfo.keywordCompletion) {
|
|
@@ -165621,7 +165706,7 @@ function getCompletionData(program, log, sourceFile, compilerOptions, position,
|
|
|
165621
165706
|
}
|
|
165622
165707
|
if (!importStatementCompletionInfo.replacementSpan && isCompletionListBlocker(contextToken)) {
|
|
165623
165708
|
log("Returning an empty list because completion was requested in an invalid position.");
|
|
165624
|
-
return keywordFilters ? keywordCompletionData(keywordFilters, isJsOnlyLocation,
|
|
165709
|
+
return keywordFilters ? keywordCompletionData(keywordFilters, isJsOnlyLocation, computeCommitCharactersAndIsNewIdentifier().isNewIdentifierLocation) : void 0;
|
|
165625
165710
|
}
|
|
165626
165711
|
let parent2 = contextToken.parent;
|
|
165627
165712
|
if (contextToken.kind === 25 /* DotToken */ || contextToken.kind === 29 /* QuestionDotToken */) {
|
|
@@ -165780,7 +165865,8 @@ function getCompletionData(program, log, sourceFile, compilerOptions, position,
|
|
|
165780
165865
|
isRightOfDotOrQuestionDot: isRightOfDot || isRightOfQuestionDot,
|
|
165781
165866
|
importStatementCompletion,
|
|
165782
165867
|
hasUnresolvedAutoImports,
|
|
165783
|
-
flags
|
|
165868
|
+
flags,
|
|
165869
|
+
defaultCommitCharacters
|
|
165784
165870
|
};
|
|
165785
165871
|
function isTagWithTypeExpression(tag) {
|
|
165786
165872
|
switch (tag.kind) {
|
|
@@ -165815,7 +165901,10 @@ function getCompletionData(program, log, sourceFile, compilerOptions, position,
|
|
|
165815
165901
|
const isRhsOfImportDeclaration = isInRightSideOfInternalImportEqualsDeclaration(node);
|
|
165816
165902
|
if (isEntityName(node) || isImportType || isPropertyAccessExpression(node)) {
|
|
165817
165903
|
const isNamespaceName = isModuleDeclaration(node.parent);
|
|
165818
|
-
if (isNamespaceName)
|
|
165904
|
+
if (isNamespaceName) {
|
|
165905
|
+
isNewIdentifierLocation = true;
|
|
165906
|
+
defaultCommitCharacters = [];
|
|
165907
|
+
}
|
|
165819
165908
|
let symbol = typeChecker.getSymbolAtLocation(node);
|
|
165820
165909
|
if (symbol) {
|
|
165821
165910
|
symbol = skipAlias(symbol, typeChecker);
|
|
@@ -165885,9 +165974,13 @@ function getCompletionData(program, log, sourceFile, compilerOptions, position,
|
|
|
165885
165974
|
}
|
|
165886
165975
|
}
|
|
165887
165976
|
function addTypeProperties(type, insertAwait, insertQuestionDot) {
|
|
165888
|
-
|
|
165977
|
+
if (type.getStringIndexType()) {
|
|
165978
|
+
isNewIdentifierLocation = true;
|
|
165979
|
+
defaultCommitCharacters = [];
|
|
165980
|
+
}
|
|
165889
165981
|
if (isRightOfQuestionDot && some(type.getCallSignatures())) {
|
|
165890
165982
|
isNewIdentifierLocation = true;
|
|
165983
|
+
defaultCommitCharacters ?? (defaultCommitCharacters = allCommitCharacters);
|
|
165891
165984
|
}
|
|
165892
165985
|
const propertyAccess = node.kind === 205 /* ImportType */ ? node : node.parent;
|
|
165893
165986
|
if (inCheckedFile) {
|
|
@@ -166026,7 +166119,7 @@ function getCompletionData(program, log, sourceFile, compilerOptions, position,
|
|
|
166026
166119
|
function getGlobalCompletions() {
|
|
166027
166120
|
keywordFilters = tryGetFunctionLikeBodyCompletionContainer(contextToken) ? 5 /* FunctionLikeBodyKeywords */ : 1 /* All */;
|
|
166028
166121
|
completionKind = 1 /* Global */;
|
|
166029
|
-
isNewIdentifierLocation =
|
|
166122
|
+
({ isNewIdentifierLocation, defaultCommitCharacters } = computeCommitCharactersAndIsNewIdentifier());
|
|
166030
166123
|
if (previousToken !== contextToken) {
|
|
166031
166124
|
Debug.assert(!!previousToken, "Expected 'contextToken' to be defined when different from 'previousToken'.");
|
|
166032
166125
|
}
|
|
@@ -166292,41 +166385,109 @@ function getCompletionData(program, log, sourceFile, compilerOptions, position,
|
|
|
166292
166385
|
}
|
|
166293
166386
|
return false;
|
|
166294
166387
|
}
|
|
166295
|
-
function
|
|
166388
|
+
function computeCommitCharactersAndIsNewIdentifier() {
|
|
166296
166389
|
if (contextToken) {
|
|
166297
166390
|
const containingNodeKind = contextToken.parent.kind;
|
|
166298
166391
|
const tokenKind = keywordForNode(contextToken);
|
|
166299
166392
|
switch (tokenKind) {
|
|
166300
166393
|
case 28 /* CommaToken */:
|
|
166301
|
-
|
|
166394
|
+
switch (containingNodeKind) {
|
|
166395
|
+
case 213 /* CallExpression */:
|
|
166396
|
+
case 214 /* NewExpression */: {
|
|
166397
|
+
const expression = contextToken.parent.expression;
|
|
166398
|
+
if (getLineAndCharacterOfPosition(sourceFile, expression.end).line !== getLineAndCharacterOfPosition(sourceFile, position).line) {
|
|
166399
|
+
return { defaultCommitCharacters: noCommaCommitCharacters, isNewIdentifierLocation: true };
|
|
166400
|
+
}
|
|
166401
|
+
return { defaultCommitCharacters: allCommitCharacters, isNewIdentifierLocation: true };
|
|
166402
|
+
}
|
|
166403
|
+
case 226 /* BinaryExpression */:
|
|
166404
|
+
return { defaultCommitCharacters: noCommaCommitCharacters, isNewIdentifierLocation: true };
|
|
166405
|
+
case 176 /* Constructor */:
|
|
166406
|
+
case 184 /* FunctionType */:
|
|
166407
|
+
case 210 /* ObjectLiteralExpression */:
|
|
166408
|
+
return { defaultCommitCharacters: [], isNewIdentifierLocation: true };
|
|
166409
|
+
case 209 /* ArrayLiteralExpression */:
|
|
166410
|
+
return { defaultCommitCharacters: allCommitCharacters, isNewIdentifierLocation: true };
|
|
166411
|
+
default:
|
|
166412
|
+
return { defaultCommitCharacters: allCommitCharacters, isNewIdentifierLocation: false };
|
|
166413
|
+
}
|
|
166302
166414
|
case 21 /* OpenParenToken */:
|
|
166303
|
-
|
|
166415
|
+
switch (containingNodeKind) {
|
|
166416
|
+
case 213 /* CallExpression */:
|
|
166417
|
+
case 214 /* NewExpression */: {
|
|
166418
|
+
const expression = contextToken.parent.expression;
|
|
166419
|
+
if (getLineAndCharacterOfPosition(sourceFile, expression.end).line !== getLineAndCharacterOfPosition(sourceFile, position).line) {
|
|
166420
|
+
return { defaultCommitCharacters: noCommaCommitCharacters, isNewIdentifierLocation: true };
|
|
166421
|
+
}
|
|
166422
|
+
return { defaultCommitCharacters: allCommitCharacters, isNewIdentifierLocation: true };
|
|
166423
|
+
}
|
|
166424
|
+
case 217 /* ParenthesizedExpression */:
|
|
166425
|
+
return { defaultCommitCharacters: noCommaCommitCharacters, isNewIdentifierLocation: true };
|
|
166426
|
+
case 176 /* Constructor */:
|
|
166427
|
+
case 196 /* ParenthesizedType */:
|
|
166428
|
+
return { defaultCommitCharacters: [], isNewIdentifierLocation: true };
|
|
166429
|
+
default:
|
|
166430
|
+
return { defaultCommitCharacters: allCommitCharacters, isNewIdentifierLocation: false };
|
|
166431
|
+
}
|
|
166304
166432
|
case 23 /* OpenBracketToken */:
|
|
166305
|
-
|
|
166433
|
+
switch (containingNodeKind) {
|
|
166434
|
+
case 209 /* ArrayLiteralExpression */:
|
|
166435
|
+
case 181 /* IndexSignature */:
|
|
166436
|
+
case 189 /* TupleType */:
|
|
166437
|
+
case 167 /* ComputedPropertyName */:
|
|
166438
|
+
return { defaultCommitCharacters: allCommitCharacters, isNewIdentifierLocation: true };
|
|
166439
|
+
default:
|
|
166440
|
+
return { defaultCommitCharacters: allCommitCharacters, isNewIdentifierLocation: false };
|
|
166441
|
+
}
|
|
166306
166442
|
case 144 /* ModuleKeyword */:
|
|
166307
166443
|
case 145 /* NamespaceKeyword */:
|
|
166308
166444
|
case 102 /* ImportKeyword */:
|
|
166309
|
-
return true;
|
|
166445
|
+
return { defaultCommitCharacters: [], isNewIdentifierLocation: true };
|
|
166310
166446
|
case 25 /* DotToken */:
|
|
166311
|
-
|
|
166447
|
+
switch (containingNodeKind) {
|
|
166448
|
+
case 267 /* ModuleDeclaration */:
|
|
166449
|
+
return { defaultCommitCharacters: [], isNewIdentifierLocation: true };
|
|
166450
|
+
default:
|
|
166451
|
+
return { defaultCommitCharacters: allCommitCharacters, isNewIdentifierLocation: false };
|
|
166452
|
+
}
|
|
166312
166453
|
case 19 /* OpenBraceToken */:
|
|
166313
|
-
|
|
166454
|
+
switch (containingNodeKind) {
|
|
166455
|
+
case 263 /* ClassDeclaration */:
|
|
166456
|
+
case 210 /* ObjectLiteralExpression */:
|
|
166457
|
+
return { defaultCommitCharacters: [], isNewIdentifierLocation: true };
|
|
166458
|
+
default:
|
|
166459
|
+
return { defaultCommitCharacters: allCommitCharacters, isNewIdentifierLocation: false };
|
|
166460
|
+
}
|
|
166314
166461
|
case 64 /* EqualsToken */:
|
|
166315
|
-
|
|
166462
|
+
switch (containingNodeKind) {
|
|
166463
|
+
case 260 /* VariableDeclaration */:
|
|
166464
|
+
case 226 /* BinaryExpression */:
|
|
166465
|
+
return { defaultCommitCharacters: allCommitCharacters, isNewIdentifierLocation: true };
|
|
166466
|
+
default:
|
|
166467
|
+
return { defaultCommitCharacters: allCommitCharacters, isNewIdentifierLocation: false };
|
|
166468
|
+
}
|
|
166316
166469
|
case 16 /* TemplateHead */:
|
|
166317
|
-
return
|
|
166470
|
+
return {
|
|
166471
|
+
defaultCommitCharacters: allCommitCharacters,
|
|
166472
|
+
isNewIdentifierLocation: containingNodeKind === 228 /* TemplateExpression */
|
|
166473
|
+
// `aa ${|
|
|
166474
|
+
};
|
|
166318
166475
|
case 17 /* TemplateMiddle */:
|
|
166319
|
-
return
|
|
166476
|
+
return {
|
|
166477
|
+
defaultCommitCharacters: allCommitCharacters,
|
|
166478
|
+
isNewIdentifierLocation: containingNodeKind === 239 /* TemplateSpan */
|
|
166479
|
+
// `aa ${10} dd ${|
|
|
166480
|
+
};
|
|
166320
166481
|
case 134 /* AsyncKeyword */:
|
|
166321
|
-
return containingNodeKind === 174 /* MethodDeclaration */ || containingNodeKind === 304 /* ShorthandPropertyAssignment
|
|
166482
|
+
return containingNodeKind === 174 /* MethodDeclaration */ || containingNodeKind === 304 /* ShorthandPropertyAssignment */ ? { defaultCommitCharacters: [], isNewIdentifierLocation: true } : { defaultCommitCharacters: allCommitCharacters, isNewIdentifierLocation: false };
|
|
166322
166483
|
case 42 /* AsteriskToken */:
|
|
166323
|
-
return containingNodeKind === 174 /* MethodDeclaration
|
|
166484
|
+
return containingNodeKind === 174 /* MethodDeclaration */ ? { defaultCommitCharacters: [], isNewIdentifierLocation: true } : { defaultCommitCharacters: allCommitCharacters, isNewIdentifierLocation: false };
|
|
166324
166485
|
}
|
|
166325
166486
|
if (isClassMemberCompletionKeyword(tokenKind)) {
|
|
166326
|
-
return true;
|
|
166487
|
+
return { defaultCommitCharacters: [], isNewIdentifierLocation: true };
|
|
166327
166488
|
}
|
|
166328
166489
|
}
|
|
166329
|
-
return false;
|
|
166490
|
+
return { defaultCommitCharacters: allCommitCharacters, isNewIdentifierLocation: false };
|
|
166330
166491
|
}
|
|
166331
166492
|
function isInStringOrRegularExpressionOrTemplateLiteral(contextToken2) {
|
|
166332
166493
|
return (isRegularExpressionLiteral(contextToken2) || isStringTextContainingNode(contextToken2)) && (rangeContainsPositionExclusive(contextToken2, position) || position === contextToken2.end && (!!contextToken2.isUnterminated || isRegularExpressionLiteral(contextToken2)));
|
|
@@ -179399,13 +179560,13 @@ function pasteEditsProvider(targetFile, pastedText, pasteLocations, copiedFrom,
|
|
|
179399
179560
|
function pasteEdits(targetFile, pastedText, pasteLocations, copiedFrom, host, preferences, formatContext, cancellationToken, changes) {
|
|
179400
179561
|
let actualPastedText;
|
|
179401
179562
|
if (pastedText.length !== pasteLocations.length) {
|
|
179402
|
-
actualPastedText = pastedText.length === 1 ? pastedText :
|
|
179563
|
+
actualPastedText = pastedText.length === 1 ? pastedText[0] : pastedText.join(getNewLineOrDefaultFromHost(formatContext.host, formatContext.options));
|
|
179403
179564
|
}
|
|
179404
179565
|
const statements = [];
|
|
179405
179566
|
let newText = targetFile.text;
|
|
179406
179567
|
for (let i = pasteLocations.length - 1; i >= 0; i--) {
|
|
179407
179568
|
const { pos, end } = pasteLocations[i];
|
|
179408
|
-
newText = actualPastedText ? newText.slice(0, pos) + actualPastedText
|
|
179569
|
+
newText = actualPastedText ? newText.slice(0, pos) + actualPastedText + newText.slice(end) : newText.slice(0, pos) + pastedText[i] + newText.slice(end);
|
|
179409
179570
|
}
|
|
179410
179571
|
let importAdder;
|
|
179411
179572
|
Debug.checkDefined(host.runWithTemporaryFileUpdate).call(host, targetFile.fileName, newText, (updatedProgram, originalProgram, updatedFile) => {
|
|
@@ -179436,22 +179597,37 @@ function pasteEdits(targetFile, pastedText, pasteLocations, copiedFrom, host, pr
|
|
|
179436
179597
|
preferences,
|
|
179437
179598
|
formatContext
|
|
179438
179599
|
};
|
|
179439
|
-
|
|
179440
|
-
|
|
179441
|
-
|
|
179442
|
-
|
|
179443
|
-
|
|
179444
|
-
|
|
179445
|
-
|
|
179446
|
-
|
|
179447
|
-
|
|
179448
|
-
|
|
179600
|
+
let offset = 0;
|
|
179601
|
+
pasteLocations.forEach((location, i) => {
|
|
179602
|
+
const oldTextLength = location.end - location.pos;
|
|
179603
|
+
const textToBePasted = actualPastedText ?? pastedText[i];
|
|
179604
|
+
const startPos = location.pos + offset;
|
|
179605
|
+
const endPos = startPos + textToBePasted.length;
|
|
179606
|
+
const range = { pos: startPos, end: endPos };
|
|
179607
|
+
offset += textToBePasted.length - oldTextLength;
|
|
179608
|
+
const enclosingNode = findAncestor(
|
|
179609
|
+
getTokenAtPosition(context.sourceFile, range.pos),
|
|
179610
|
+
(ancestorNode) => rangeContainsRange(ancestorNode, range)
|
|
179611
|
+
);
|
|
179612
|
+
if (!enclosingNode) return;
|
|
179613
|
+
forEachChild(enclosingNode, function importUnresolvedIdentifiers(node) {
|
|
179614
|
+
const isImportCandidate = isIdentifier(node) && rangeContainsPosition(range, node.getStart(updatedFile)) && !(updatedProgram == null ? void 0 : updatedProgram.getTypeChecker().resolveName(
|
|
179615
|
+
node.text,
|
|
179449
179616
|
node,
|
|
179450
|
-
/*
|
|
179451
|
-
|
|
179452
|
-
|
|
179453
|
-
|
|
179454
|
-
|
|
179617
|
+
-1 /* All */,
|
|
179618
|
+
/*excludeGlobals*/
|
|
179619
|
+
false
|
|
179620
|
+
));
|
|
179621
|
+
if (isImportCandidate) {
|
|
179622
|
+
return importAdder.addImportForUnresolvedIdentifier(
|
|
179623
|
+
context,
|
|
179624
|
+
node,
|
|
179625
|
+
/*useAutoImportProvider*/
|
|
179626
|
+
true
|
|
179627
|
+
);
|
|
179628
|
+
}
|
|
179629
|
+
node.forEachChild(importUnresolvedIdentifiers);
|
|
179630
|
+
});
|
|
179455
179631
|
});
|
|
179456
179632
|
}
|
|
179457
179633
|
importAdder.writeFixes(changes, getQuotePreference(copiedFrom ? copiedFrom.file : targetFile, preferences));
|
|
@@ -179463,7 +179639,7 @@ function pasteEdits(targetFile, pastedText, pasteLocations, copiedFrom, host, pr
|
|
|
179463
179639
|
changes.replaceRangeWithText(
|
|
179464
179640
|
targetFile,
|
|
179465
179641
|
{ pos: paste.pos, end: paste.end },
|
|
179466
|
-
actualPastedText
|
|
179642
|
+
actualPastedText ?? pastedText[i]
|
|
179467
179643
|
);
|
|
179468
179644
|
});
|
|
179469
179645
|
}
|
|
@@ -184078,19 +184254,12 @@ var Project2 = class _Project {
|
|
|
184078
184254
|
}
|
|
184079
184255
|
/** @internal */
|
|
184080
184256
|
onAutoImportProviderSettingsChanged() {
|
|
184081
|
-
|
|
184082
|
-
if (this.autoImportProviderHost === false) {
|
|
184083
|
-
this.autoImportProviderHost = void 0;
|
|
184084
|
-
} else {
|
|
184085
|
-
(_a = this.autoImportProviderHost) == null ? void 0 : _a.markAsDirty();
|
|
184086
|
-
}
|
|
184257
|
+
this.markAutoImportProviderAsDirty();
|
|
184087
184258
|
}
|
|
184088
184259
|
/** @internal */
|
|
184089
184260
|
onPackageJsonChange() {
|
|
184090
184261
|
this.moduleSpecifierCache.clear();
|
|
184091
|
-
|
|
184092
|
-
this.autoImportProviderHost.markAsDirty();
|
|
184093
|
-
}
|
|
184262
|
+
this.markAutoImportProviderAsDirty();
|
|
184094
184263
|
}
|
|
184095
184264
|
/** @internal */
|
|
184096
184265
|
onFileAddedOrRemoved(isSymlink) {
|
|
@@ -184846,7 +185015,7 @@ var Project2 = class _Project {
|
|
|
184846
185015
|
if (dependencySelection) {
|
|
184847
185016
|
(_a = tracing) == null ? void 0 : _a.push(tracing.Phase.Session, "getPackageJsonAutoImportProvider");
|
|
184848
185017
|
const start = timestamp();
|
|
184849
|
-
this.autoImportProviderHost = AutoImportProviderProject.create(dependencySelection, this, this.getHostForAutoImportProvider(), this.documentRegistry);
|
|
185018
|
+
this.autoImportProviderHost = AutoImportProviderProject.create(dependencySelection, this, this.getHostForAutoImportProvider(), this.documentRegistry) ?? false;
|
|
184850
185019
|
if (this.autoImportProviderHost) {
|
|
184851
185020
|
updateProjectIfDirty(this.autoImportProviderHost);
|
|
184852
185021
|
this.sendPerformanceEvent("CreatePackageJsonAutoImportProvider", timestamp() - start);
|
|
@@ -185104,7 +185273,7 @@ var _AutoImportProviderProject = class _AutoImportProviderProject extends Projec
|
|
|
185104
185273
|
if (dependencyNames) {
|
|
185105
185274
|
const symlinkCache = hostProject.getSymlinkCache();
|
|
185106
185275
|
for (const name of arrayFrom(dependencyNames.keys())) {
|
|
185107
|
-
if (dependencySelection === 2 /* Auto */ && dependenciesAdded
|
|
185276
|
+
if (dependencySelection === 2 /* Auto */ && dependenciesAdded >= this.maxDependencies) {
|
|
185108
185277
|
hostProject.log(`AutoImportProviderProject: attempted to add more than ${this.maxDependencies} dependencies. Aborting.`);
|
|
185109
185278
|
return emptyArray;
|
|
185110
185279
|
}
|
|
@@ -188606,6 +188775,7 @@ Dynamic files must always be opened with service's current directory or service
|
|
|
188606
188775
|
}
|
|
188607
188776
|
};
|
|
188608
188777
|
toRetainConfiguredProjects == null ? void 0 : toRetainConfiguredProjects.forEach(retainConfiguredProject);
|
|
188778
|
+
if (!toRemoveConfiguredProjects.size) return toRemoveConfiguredProjects;
|
|
188609
188779
|
this.inferredProjects.forEach(markOriginalProjectsAsUsed);
|
|
188610
188780
|
this.externalProjects.forEach(markOriginalProjectsAsUsed);
|
|
188611
188781
|
this.externalProjectToConfiguredProjectMap.forEach((projects, externalProjectName) => {
|
|
@@ -188613,7 +188783,8 @@ Dynamic files must always be opened with service's current directory or service
|
|
|
188613
188783
|
projects.forEach(retainConfiguredProject);
|
|
188614
188784
|
}
|
|
188615
188785
|
});
|
|
188616
|
-
|
|
188786
|
+
if (!toRemoveConfiguredProjects.size) return toRemoveConfiguredProjects;
|
|
188787
|
+
forEachEntry(this.openFiles, (_projectRootPath, path) => {
|
|
188617
188788
|
if (openFilesWithRetainedConfiguredProject == null ? void 0 : openFilesWithRetainedConfiguredProject.has(path)) return;
|
|
188618
188789
|
const info = this.getScriptInfoForPath(path);
|
|
188619
188790
|
if (find(info.containingProjects, isExternalProject)) return;
|
|
@@ -188623,12 +188794,15 @@ Dynamic files must always be opened with service's current directory or service
|
|
|
188623
188794
|
);
|
|
188624
188795
|
if (result == null ? void 0 : result.defaultProject) {
|
|
188625
188796
|
result == null ? void 0 : result.seenProjects.forEach(retainConfiguredProject);
|
|
188797
|
+
if (!toRemoveConfiguredProjects.size) return toRemoveConfiguredProjects;
|
|
188626
188798
|
}
|
|
188627
188799
|
});
|
|
188628
|
-
|
|
188800
|
+
if (!toRemoveConfiguredProjects.size) return toRemoveConfiguredProjects;
|
|
188801
|
+
forEachEntry(this.configuredProjects, (project) => {
|
|
188629
188802
|
if (toRemoveConfiguredProjects.has(project)) {
|
|
188630
188803
|
if (isPendingUpdate(project) || forEachReferencedProject(project, isRetained)) {
|
|
188631
188804
|
retainConfiguredProject(project);
|
|
188805
|
+
if (!toRemoveConfiguredProjects.size) return toRemoveConfiguredProjects;
|
|
188632
188806
|
}
|
|
188633
188807
|
}
|
|
188634
188808
|
});
|
|
@@ -188987,7 +189161,7 @@ Dynamic files must always be opened with service's current directory or service
|
|
|
188987
189161
|
if (cleanupAfter) {
|
|
188988
189162
|
this.cleanupConfiguredProjects(
|
|
188989
189163
|
configuredProjects,
|
|
188990
|
-
new Set(proj.projectFileName)
|
|
189164
|
+
/* @__PURE__ */ new Set([proj.projectFileName])
|
|
188991
189165
|
);
|
|
188992
189166
|
this.printProjects();
|
|
188993
189167
|
}
|