@typescript-deploys/pr-build 5.2.0-pr-55028-5 → 5.2.0-pr-52095-16
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 +151 -82
- package/lib/tsserver.js +315 -145
- package/lib/tsserverlibrary.d.ts +13 -2
- package/lib/tsserverlibrary.js +314 -146
- package/lib/typescript.d.ts +7 -1
- package/lib/typescript.js +296 -142
- package/lib/typingsInstaller.js +11 -4
- package/package.json +2 -2
package/lib/tsserver.js
CHANGED
|
@@ -970,6 +970,7 @@ __export(server_exports, {
|
|
|
970
970
|
getPropertyAssignmentAliasLikeExpression: () => getPropertyAssignmentAliasLikeExpression,
|
|
971
971
|
getPropertyNameForPropertyNameNode: () => getPropertyNameForPropertyNameNode,
|
|
972
972
|
getPropertyNameForUniqueESSymbol: () => getPropertyNameForUniqueESSymbol,
|
|
973
|
+
getPropertyNameFromType: () => getPropertyNameFromType,
|
|
973
974
|
getPropertyNameOfBindingOrAssignmentElement: () => getPropertyNameOfBindingOrAssignmentElement,
|
|
974
975
|
getPropertySymbolFromBindingElement: () => getPropertySymbolFromBindingElement,
|
|
975
976
|
getPropertySymbolsFromContextualType: () => getPropertySymbolsFromContextualType,
|
|
@@ -1802,6 +1803,7 @@ __export(server_exports, {
|
|
|
1802
1803
|
isTypeQueryNode: () => isTypeQueryNode,
|
|
1803
1804
|
isTypeReferenceNode: () => isTypeReferenceNode,
|
|
1804
1805
|
isTypeReferenceType: () => isTypeReferenceType,
|
|
1806
|
+
isTypeUsableAsPropertyName: () => isTypeUsableAsPropertyName,
|
|
1805
1807
|
isUMDExportSymbol: () => isUMDExportSymbol,
|
|
1806
1808
|
isUnaryExpression: () => isUnaryExpression,
|
|
1807
1809
|
isUnaryExpressionWithWrite: () => isUnaryExpressionWithWrite,
|
|
@@ -2327,7 +2329,7 @@ module.exports = __toCommonJS(server_exports);
|
|
|
2327
2329
|
|
|
2328
2330
|
// src/compiler/corePublic.ts
|
|
2329
2331
|
var versionMajorMinor = "5.2";
|
|
2330
|
-
var version = `${versionMajorMinor}.0-insiders.
|
|
2332
|
+
var version = `${versionMajorMinor}.0-insiders.20230725`;
|
|
2331
2333
|
var Comparison = /* @__PURE__ */ ((Comparison3) => {
|
|
2332
2334
|
Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
|
|
2333
2335
|
Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
|
|
@@ -21601,6 +21603,18 @@ function getTextOfJsxNamespacedName(node) {
|
|
|
21601
21603
|
function intrinsicTagNameToString(node) {
|
|
21602
21604
|
return isIdentifier(node) ? idText(node) : getTextOfJsxNamespacedName(node);
|
|
21603
21605
|
}
|
|
21606
|
+
function isTypeUsableAsPropertyName(type) {
|
|
21607
|
+
return !!(type.flags & 8576 /* StringOrNumberLiteralOrUnique */);
|
|
21608
|
+
}
|
|
21609
|
+
function getPropertyNameFromType(type) {
|
|
21610
|
+
if (type.flags & 8192 /* UniqueESSymbol */) {
|
|
21611
|
+
return type.escapedName;
|
|
21612
|
+
}
|
|
21613
|
+
if (type.flags & (128 /* StringLiteral */ | 256 /* NumberLiteral */)) {
|
|
21614
|
+
return escapeLeadingUnderscores("" + type.value);
|
|
21615
|
+
}
|
|
21616
|
+
return Debug.fail();
|
|
21617
|
+
}
|
|
21604
21618
|
|
|
21605
21619
|
// src/compiler/factory/baseNodeFactory.ts
|
|
21606
21620
|
function createBaseNodeFactory() {
|
|
@@ -35109,10 +35123,14 @@ var Parser;
|
|
|
35109
35123
|
case 124 /* ProtectedKeyword */:
|
|
35110
35124
|
case 125 /* PublicKeyword */:
|
|
35111
35125
|
case 148 /* ReadonlyKeyword */:
|
|
35126
|
+
const previousToken = token();
|
|
35112
35127
|
nextToken();
|
|
35113
35128
|
if (scanner2.hasPrecedingLineBreak()) {
|
|
35114
35129
|
return false;
|
|
35115
35130
|
}
|
|
35131
|
+
if (previousToken === 138 /* DeclareKeyword */ && token() === 156 /* TypeKeyword */) {
|
|
35132
|
+
return true;
|
|
35133
|
+
}
|
|
35116
35134
|
continue;
|
|
35117
35135
|
case 162 /* GlobalKeyword */:
|
|
35118
35136
|
nextToken();
|
|
@@ -35477,14 +35495,14 @@ var Parser;
|
|
|
35477
35495
|
function parseObjectBindingPattern() {
|
|
35478
35496
|
const pos = getNodePos();
|
|
35479
35497
|
parseExpected(19 /* OpenBraceToken */);
|
|
35480
|
-
const elements = parseDelimitedList(9 /* ObjectBindingElements */, parseObjectBindingElement);
|
|
35498
|
+
const elements = allowInAnd(() => parseDelimitedList(9 /* ObjectBindingElements */, parseObjectBindingElement));
|
|
35481
35499
|
parseExpected(20 /* CloseBraceToken */);
|
|
35482
35500
|
return finishNode(factory2.createObjectBindingPattern(elements), pos);
|
|
35483
35501
|
}
|
|
35484
35502
|
function parseArrayBindingPattern() {
|
|
35485
35503
|
const pos = getNodePos();
|
|
35486
35504
|
parseExpected(23 /* OpenBracketToken */);
|
|
35487
|
-
const elements = parseDelimitedList(10 /* ArrayBindingElements */, parseArrayBindingElement);
|
|
35505
|
+
const elements = allowInAnd(() => parseDelimitedList(10 /* ArrayBindingElements */, parseArrayBindingElement));
|
|
35488
35506
|
parseExpected(24 /* CloseBracketToken */);
|
|
35489
35507
|
return finishNode(factory2.createArrayBindingPattern(elements), pos);
|
|
35490
35508
|
}
|
|
@@ -36002,6 +36020,9 @@ var Parser;
|
|
|
36002
36020
|
}
|
|
36003
36021
|
function parseTypeAliasDeclaration(pos, hasJSDoc, modifiers) {
|
|
36004
36022
|
parseExpected(156 /* TypeKeyword */);
|
|
36023
|
+
if (scanner2.hasPrecedingLineBreak()) {
|
|
36024
|
+
parseErrorAtCurrentToken(Diagnostics.Line_break_not_permitted_here);
|
|
36025
|
+
}
|
|
36005
36026
|
const name = parseIdentifier();
|
|
36006
36027
|
const typeParameters = parseTypeParameters();
|
|
36007
36028
|
parseExpected(64 /* EqualsToken */);
|
|
@@ -37903,7 +37924,7 @@ function getNamedArgRegEx(name) {
|
|
|
37903
37924
|
return result;
|
|
37904
37925
|
}
|
|
37905
37926
|
var tripleSlashXMLCommentStartRegEx = /^\/\/\/\s*<(\S+)\s.*?\/>/im;
|
|
37906
|
-
var singleLinePragmaRegEx = /^\/\/\/?\s*@(
|
|
37927
|
+
var singleLinePragmaRegEx = /^\/\/\/?\s*@([^\s:]+)(.*)\s*$/im;
|
|
37907
37928
|
function extractPragmas(pragmas, range, text) {
|
|
37908
37929
|
const tripleSlash = range.kind === 2 /* SingleLineCommentTrivia */ && tripleSlashXMLCommentStartRegEx.exec(text);
|
|
37909
37930
|
if (tripleSlash) {
|
|
@@ -43870,6 +43891,9 @@ function getModuleInstanceStateForAliasTarget(specifier, visited) {
|
|
|
43870
43891
|
if (found === 1 /* Instantiated */) {
|
|
43871
43892
|
return found;
|
|
43872
43893
|
}
|
|
43894
|
+
if (statement.kind === 271 /* ImportEqualsDeclaration */) {
|
|
43895
|
+
found = 1 /* Instantiated */;
|
|
43896
|
+
}
|
|
43873
43897
|
}
|
|
43874
43898
|
}
|
|
43875
43899
|
if (found !== void 0) {
|
|
@@ -47818,7 +47842,7 @@ function createTypeChecker(host) {
|
|
|
47818
47842
|
return node ? getTypeFromTypeNode(node) : errorType;
|
|
47819
47843
|
},
|
|
47820
47844
|
getParameterType: getTypeAtPosition,
|
|
47821
|
-
|
|
47845
|
+
getParameterIdentifierInfoAtPosition,
|
|
47822
47846
|
getPromisedTypeOfPromise,
|
|
47823
47847
|
getAwaitedType: (type) => getAwaitedType(type),
|
|
47824
47848
|
getReturnTypeOfSignature,
|
|
@@ -49082,7 +49106,7 @@ function createTypeChecker(host) {
|
|
|
49082
49106
|
false
|
|
49083
49107
|
);
|
|
49084
49108
|
} else if (isParameterPropertyDeclaration(declaration, declaration.parent)) {
|
|
49085
|
-
return !(useDefineForClassFields && getContainingClass(declaration) === getContainingClass(usage) && isUsedInFunctionOrInstanceProperty(usage, declaration));
|
|
49109
|
+
return !(getEmitScriptTarget(compilerOptions) === 99 /* ESNext */ && useDefineForClassFields && getContainingClass(declaration) === getContainingClass(usage) && isUsedInFunctionOrInstanceProperty(usage, declaration));
|
|
49086
49110
|
}
|
|
49087
49111
|
return true;
|
|
49088
49112
|
}
|
|
@@ -49096,7 +49120,7 @@ function createTypeChecker(host) {
|
|
|
49096
49120
|
return true;
|
|
49097
49121
|
}
|
|
49098
49122
|
if (isUsedInFunctionOrInstanceProperty(usage, declaration)) {
|
|
49099
|
-
if (useDefineForClassFields && getContainingClass(declaration) && (isPropertyDeclaration(declaration) || isParameterPropertyDeclaration(declaration, declaration.parent))) {
|
|
49123
|
+
if (getEmitScriptTarget(compilerOptions) >= 9 /* ES2022 */ && useDefineForClassFields && getContainingClass(declaration) && (isPropertyDeclaration(declaration) || isParameterPropertyDeclaration(declaration, declaration.parent))) {
|
|
49100
49124
|
return !isPropertyImmediatelyReferencedWithinDeclaration(
|
|
49101
49125
|
declaration,
|
|
49102
49126
|
usage,
|
|
@@ -49220,7 +49244,7 @@ function createTypeChecker(host) {
|
|
|
49220
49244
|
return requiresScopeChangeWorker(node.name);
|
|
49221
49245
|
case 172 /* PropertyDeclaration */:
|
|
49222
49246
|
if (hasStaticModifier(node)) {
|
|
49223
|
-
return !useDefineForClassFields;
|
|
49247
|
+
return target < 99 /* ESNext */ || !useDefineForClassFields;
|
|
49224
49248
|
}
|
|
49225
49249
|
return requiresScopeChangeWorker(node.name);
|
|
49226
49250
|
default:
|
|
@@ -49491,7 +49515,7 @@ function createTypeChecker(host) {
|
|
|
49491
49515
|
}
|
|
49492
49516
|
}
|
|
49493
49517
|
function checkAndReportErrorForInvalidInitializer() {
|
|
49494
|
-
if (propertyWithInvalidInitializer && !useDefineForClassFields) {
|
|
49518
|
+
if (propertyWithInvalidInitializer && !(useDefineForClassFields && getEmitScriptTarget(compilerOptions) >= 9 /* ES2022 */)) {
|
|
49495
49519
|
error2(
|
|
49496
49520
|
errorLocation,
|
|
49497
49521
|
errorLocation && propertyWithInvalidInitializer.type && textRangeContainsPositionInclusive(propertyWithInvalidInitializer.type, errorLocation.pos) ? Diagnostics.Type_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor : Diagnostics.Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor,
|
|
@@ -50875,7 +50899,7 @@ function createTypeChecker(host) {
|
|
|
50875
50899
|
return isStringLiteralLike(moduleReferenceExpression) ? resolveExternalModule(location, moduleReferenceExpression.text, moduleNotFoundError, moduleReferenceExpression, isForAugmentation) : void 0;
|
|
50876
50900
|
}
|
|
50877
50901
|
function resolveExternalModule(location, moduleReference, moduleNotFoundError, errorNode, isForAugmentation = false) {
|
|
50878
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
50902
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
50879
50903
|
if (startsWith(moduleReference, "@types/")) {
|
|
50880
50904
|
const diag2 = Diagnostics.Cannot_import_type_declaration_files_Consider_importing_0_instead_of_1;
|
|
50881
50905
|
const withoutAtTypePrefix = removePrefix(moduleReference, "@types/");
|
|
@@ -50910,8 +50934,11 @@ function createTypeChecker(host) {
|
|
|
50910
50934
|
);
|
|
50911
50935
|
}
|
|
50912
50936
|
} else if (resolvedModule.resolvedUsingTsExtension && !shouldAllowImportingTsExtension(compilerOptions, currentSourceFile.fileName)) {
|
|
50913
|
-
const
|
|
50914
|
-
|
|
50937
|
+
const importOrExport = ((_h = findAncestor(location, isImportDeclaration)) == null ? void 0 : _h.importClause) || findAncestor(location, or(isImportEqualsDeclaration, isExportDeclaration));
|
|
50938
|
+
if (!((importOrExport == null ? void 0 : importOrExport.isTypeOnly) || findAncestor(location, isImportTypeNode))) {
|
|
50939
|
+
const tsExtension = Debug.checkDefined(tryExtractTSExtension(moduleReference));
|
|
50940
|
+
error2(errorNode, Diagnostics.An_import_path_can_only_end_with_a_0_extension_when_allowImportingTsExtensions_is_enabled, tsExtension);
|
|
50941
|
+
}
|
|
50915
50942
|
}
|
|
50916
50943
|
if (sourceFile.symbol) {
|
|
50917
50944
|
if (resolvedModule.isExternalLibraryImport && !resolutionExtensionIsTSOrJson(resolvedModule.extension)) {
|
|
@@ -50928,7 +50955,7 @@ function createTypeChecker(host) {
|
|
|
50928
50955
|
if (moduleResolutionKind === 3 /* Node16 */ || moduleResolutionKind === 99 /* NodeNext */) {
|
|
50929
50956
|
const isSyncImport = currentSourceFile.impliedNodeFormat === 1 /* CommonJS */ && !findAncestor(location, isImportCall) || !!findAncestor(location, isImportEqualsDeclaration);
|
|
50930
50957
|
const overrideClauseHost = findAncestor(location, (l) => isImportTypeNode(l) || isExportDeclaration(l) || isImportDeclaration(l));
|
|
50931
|
-
const overrideClause = overrideClauseHost && isImportTypeNode(overrideClauseHost) ? (
|
|
50958
|
+
const overrideClause = overrideClauseHost && isImportTypeNode(overrideClauseHost) ? (_i = overrideClauseHost.assertions) == null ? void 0 : _i.assertClause : overrideClauseHost == null ? void 0 : overrideClauseHost.assertClause;
|
|
50932
50959
|
if (isSyncImport && sourceFile.impliedNodeFormat === 99 /* ESNext */ && !getResolutionModeOverrideForClause(overrideClause)) {
|
|
50933
50960
|
if (findAncestor(location, isImportEqualsDeclaration)) {
|
|
50934
50961
|
error2(errorNode, Diagnostics.Module_0_cannot_be_imported_using_this_construct_The_specifier_only_resolves_to_an_ES_module_which_cannot_be_imported_with_require_Use_an_ECMAScript_import_instead, moduleReference);
|
|
@@ -51031,7 +51058,7 @@ function createTypeChecker(host) {
|
|
|
51031
51058
|
error2(errorNode, Diagnostics.Cannot_find_module_0_Consider_using_resolveJsonModule_to_import_module_with_json_extension, moduleReference);
|
|
51032
51059
|
} else if (mode === 99 /* ESNext */ && resolutionIsNode16OrNext && isExtensionlessRelativePathImport) {
|
|
51033
51060
|
const absoluteRef = getNormalizedAbsolutePath(moduleReference, getDirectoryPath(currentSourceFile.path));
|
|
51034
|
-
const suggestedExt = (
|
|
51061
|
+
const suggestedExt = (_j = suggestedExtensions.find(([actualExt, _importExt]) => host.fileExists(absoluteRef + actualExt))) == null ? void 0 : _j[1];
|
|
51035
51062
|
if (suggestedExt) {
|
|
51036
51063
|
error2(
|
|
51037
51064
|
errorNode,
|
|
@@ -52467,11 +52494,13 @@ function createTypeChecker(host) {
|
|
|
52467
52494
|
return !!type2.target && isMappedTypeHomomorphic(type2.target) && !isMappedTypeHomomorphic(type2);
|
|
52468
52495
|
}
|
|
52469
52496
|
function createMappedTypeNodeFromType(type2) {
|
|
52497
|
+
var _a2;
|
|
52470
52498
|
Debug.assert(!!(type2.flags & 524288 /* Object */));
|
|
52471
52499
|
const readonlyToken = type2.declaration.readonlyToken ? factory.createToken(type2.declaration.readonlyToken.kind) : void 0;
|
|
52472
52500
|
const questionToken = type2.declaration.questionToken ? factory.createToken(type2.declaration.questionToken.kind) : void 0;
|
|
52473
52501
|
let appropriateConstraintTypeNode;
|
|
52474
52502
|
let newTypeVariable;
|
|
52503
|
+
const needsModifierPreservingWrapper = !isMappedTypeWithKeyofConstraintDeclaration(type2) && !(getModifiersTypeFromMappedType(type2).flags & 2 /* Unknown */) && context.flags & 4 /* GenerateNamesForShadowedTypeParams */ && !(getConstraintTypeFromMappedType(type2).flags & 262144 /* TypeParameter */ && ((_a2 = getConstraintOfTypeParameter(getConstraintTypeFromMappedType(type2))) == null ? void 0 : _a2.flags) & 4194304 /* Index */);
|
|
52475
52504
|
if (isMappedTypeWithKeyofConstraintDeclaration(type2)) {
|
|
52476
52505
|
if (isHomomorphicMappedTypeWithNonHomomorphicInstantiation(type2) && context.flags & 4 /* GenerateNamesForShadowedTypeParams */) {
|
|
52477
52506
|
const newParam = createTypeParameter(createSymbol(262144 /* TypeParameter */, "T"));
|
|
@@ -52479,6 +52508,11 @@ function createTypeChecker(host) {
|
|
|
52479
52508
|
newTypeVariable = factory.createTypeReferenceNode(name);
|
|
52480
52509
|
}
|
|
52481
52510
|
appropriateConstraintTypeNode = factory.createTypeOperatorNode(143 /* KeyOfKeyword */, newTypeVariable || typeToTypeNodeHelper(getModifiersTypeFromMappedType(type2), context));
|
|
52511
|
+
} else if (needsModifierPreservingWrapper) {
|
|
52512
|
+
const newParam = createTypeParameter(createSymbol(262144 /* TypeParameter */, "T"));
|
|
52513
|
+
const name = typeParameterToName(newParam, context);
|
|
52514
|
+
newTypeVariable = factory.createTypeReferenceNode(name);
|
|
52515
|
+
appropriateConstraintTypeNode = newTypeVariable;
|
|
52482
52516
|
} else {
|
|
52483
52517
|
appropriateConstraintTypeNode = typeToTypeNodeHelper(getConstraintTypeFromMappedType(type2), context);
|
|
52484
52518
|
}
|
|
@@ -52509,6 +52543,18 @@ function createTypeChecker(host) {
|
|
|
52509
52543
|
result,
|
|
52510
52544
|
factory.createKeywordTypeNode(146 /* NeverKeyword */)
|
|
52511
52545
|
);
|
|
52546
|
+
} else if (needsModifierPreservingWrapper) {
|
|
52547
|
+
return factory.createConditionalTypeNode(
|
|
52548
|
+
typeToTypeNodeHelper(getConstraintTypeFromMappedType(type2), context),
|
|
52549
|
+
factory.createInferTypeNode(factory.createTypeParameterDeclaration(
|
|
52550
|
+
/*modifiers*/
|
|
52551
|
+
void 0,
|
|
52552
|
+
factory.cloneNode(newTypeVariable.typeName),
|
|
52553
|
+
factory.createTypeOperatorNode(143 /* KeyOfKeyword */, typeToTypeNodeHelper(getModifiersTypeFromMappedType(type2), context))
|
|
52554
|
+
)),
|
|
52555
|
+
result,
|
|
52556
|
+
factory.createKeywordTypeNode(146 /* NeverKeyword */)
|
|
52557
|
+
);
|
|
52512
52558
|
}
|
|
52513
52559
|
return result;
|
|
52514
52560
|
}
|
|
@@ -57560,9 +57606,6 @@ function createTypeChecker(host) {
|
|
|
57560
57606
|
}
|
|
57561
57607
|
return type;
|
|
57562
57608
|
}
|
|
57563
|
-
function isTypeUsableAsPropertyName(type) {
|
|
57564
|
-
return !!(type.flags & 8576 /* StringOrNumberLiteralOrUnique */);
|
|
57565
|
-
}
|
|
57566
57609
|
function isLateBindableName(node) {
|
|
57567
57610
|
if (!isComputedPropertyName(node) && !isElementAccessExpression(node)) {
|
|
57568
57611
|
return false;
|
|
@@ -57583,15 +57626,6 @@ function createTypeChecker(host) {
|
|
|
57583
57626
|
function isNonBindableDynamicName(node) {
|
|
57584
57627
|
return isDynamicName(node) && !isLateBindableName(node);
|
|
57585
57628
|
}
|
|
57586
|
-
function getPropertyNameFromType(type) {
|
|
57587
|
-
if (type.flags & 8192 /* UniqueESSymbol */) {
|
|
57588
|
-
return type.escapedName;
|
|
57589
|
-
}
|
|
57590
|
-
if (type.flags & (128 /* StringLiteral */ | 256 /* NumberLiteral */)) {
|
|
57591
|
-
return escapeLeadingUnderscores("" + type.value);
|
|
57592
|
-
}
|
|
57593
|
-
return Debug.fail();
|
|
57594
|
-
}
|
|
57595
57629
|
function addDeclarationToLateBoundSymbol(symbol, member, symbolFlags) {
|
|
57596
57630
|
Debug.assert(!!(getCheckFlags(symbol) & 4096 /* Late */), "Expected a late-bound symbol.");
|
|
57597
57631
|
symbol.flags |= symbolFlags;
|
|
@@ -58238,20 +58272,17 @@ function createTypeChecker(host) {
|
|
|
58238
58272
|
setStructuredTypeMembers(type, members2, callSignatures, constructSignatures, indexInfos2);
|
|
58239
58273
|
return;
|
|
58240
58274
|
}
|
|
58241
|
-
let members =
|
|
58275
|
+
let members = getExportsOfSymbol(symbol);
|
|
58242
58276
|
let indexInfos;
|
|
58243
|
-
if (symbol
|
|
58244
|
-
|
|
58245
|
-
|
|
58246
|
-
|
|
58247
|
-
|
|
58248
|
-
|
|
58249
|
-
|
|
58250
|
-
|
|
58251
|
-
|
|
58252
|
-
});
|
|
58253
|
-
members = varsOnly;
|
|
58254
|
-
}
|
|
58277
|
+
if (symbol === globalThisSymbol) {
|
|
58278
|
+
const varsOnly = /* @__PURE__ */ new Map();
|
|
58279
|
+
members.forEach((p) => {
|
|
58280
|
+
var _a;
|
|
58281
|
+
if (!(p.flags & 418 /* BlockScoped */) && !(p.flags & 512 /* ValueModule */ && ((_a = p.declarations) == null ? void 0 : _a.length) && every(p.declarations, isAmbientModule))) {
|
|
58282
|
+
varsOnly.set(p.escapedName, p);
|
|
58283
|
+
}
|
|
58284
|
+
});
|
|
58285
|
+
members = varsOnly;
|
|
58255
58286
|
}
|
|
58256
58287
|
let baseConstructorIndexInfo;
|
|
58257
58288
|
setStructuredTypeMembers(type, members, emptyArray, emptyArray, emptyArray);
|
|
@@ -71950,41 +71981,75 @@ function createTypeChecker(host) {
|
|
|
71950
71981
|
return mapType(
|
|
71951
71982
|
type,
|
|
71952
71983
|
(t) => {
|
|
71953
|
-
|
|
71954
|
-
|
|
71955
|
-
|
|
71956
|
-
|
|
71957
|
-
const
|
|
71958
|
-
|
|
71959
|
-
|
|
71960
|
-
|
|
71961
|
-
|
|
71962
|
-
|
|
71963
|
-
|
|
71964
|
-
|
|
71965
|
-
}
|
|
71966
|
-
if (isTupleType(t) && isNumericLiteralName(name) && +name >= 0) {
|
|
71967
|
-
const restType = getElementTypeOfSliceOfTupleType(
|
|
71968
|
-
t,
|
|
71969
|
-
t.target.fixedLength,
|
|
71970
|
-
/*endSkipCount*/
|
|
71971
|
-
0,
|
|
71972
|
-
/*writing*/
|
|
71973
|
-
false,
|
|
71974
|
-
/*noReductions*/
|
|
71975
|
-
true
|
|
71976
|
-
);
|
|
71977
|
-
if (restType) {
|
|
71978
|
-
return restType;
|
|
71984
|
+
if (!(t.flags & 3670016 /* StructuredType */)) {
|
|
71985
|
+
return void 0;
|
|
71986
|
+
}
|
|
71987
|
+
if (t.flags & 2097152 /* Intersection */) {
|
|
71988
|
+
const intersection = t;
|
|
71989
|
+
let applicableIndexedMappedTypeSubstitions;
|
|
71990
|
+
let concretePropertyTypes;
|
|
71991
|
+
let applicableIndexInfoCandidates;
|
|
71992
|
+
for (const t2 of intersection.types) {
|
|
71993
|
+
if (isGenericMappedType(t2) && !t2.declaration.nameType) {
|
|
71994
|
+
applicableIndexedMappedTypeSubstitions = append(applicableIndexedMappedTypeSubstitions, getTypeOfApplicableIndexedMappedTypeSubstitutionOfContextualType(t2));
|
|
71995
|
+
continue;
|
|
71979
71996
|
}
|
|
71997
|
+
const typeOfConcreteProperty = getTypeOfConcretePropertyOfContextualType(t2);
|
|
71998
|
+
if (typeOfConcreteProperty) {
|
|
71999
|
+
concretePropertyTypes = append(concretePropertyTypes, typeOfConcreteProperty);
|
|
72000
|
+
continue;
|
|
72001
|
+
}
|
|
72002
|
+
applicableIndexInfoCandidates = append(applicableIndexInfoCandidates, t2);
|
|
72003
|
+
}
|
|
72004
|
+
if (concretePropertyTypes) {
|
|
72005
|
+
return getIntersectionType(concatenate(concretePropertyTypes, applicableIndexedMappedTypeSubstitions));
|
|
71980
72006
|
}
|
|
71981
|
-
|
|
72007
|
+
const types = concatenate(mapDefined(applicableIndexInfoCandidates, getTypeOfApplicableIndexInfoOfContextualType), applicableIndexedMappedTypeSubstitions);
|
|
72008
|
+
if (types.length > 0) {
|
|
72009
|
+
return getIntersectionType(types);
|
|
72010
|
+
}
|
|
72011
|
+
return void 0;
|
|
71982
72012
|
}
|
|
71983
|
-
return
|
|
72013
|
+
return isGenericMappedType(t) && !t.declaration.nameType ? getTypeOfApplicableIndexedMappedTypeSubstitutionOfContextualType(t) : getTypeOfConcretePropertyOfContextualType(t) || getTypeOfApplicableIndexInfoOfContextualType(t);
|
|
71984
72014
|
},
|
|
71985
72015
|
/*noReductions*/
|
|
71986
72016
|
true
|
|
71987
72017
|
);
|
|
72018
|
+
function getTypeOfApplicableIndexedMappedTypeSubstitutionOfContextualType(t) {
|
|
72019
|
+
const constraint = getConstraintTypeFromMappedType(t);
|
|
72020
|
+
const constraintOfConstraint = getBaseConstraintOfType(constraint) || constraint;
|
|
72021
|
+
const propertyNameType = nameType || getStringLiteralType(unescapeLeadingUnderscores(name));
|
|
72022
|
+
if (isTypeAssignableTo(propertyNameType, constraintOfConstraint)) {
|
|
72023
|
+
return substituteIndexedMappedType(t, propertyNameType);
|
|
72024
|
+
}
|
|
72025
|
+
return void 0;
|
|
72026
|
+
}
|
|
72027
|
+
function getTypeOfConcretePropertyOfContextualType(t) {
|
|
72028
|
+
const prop = getPropertyOfType(t, name);
|
|
72029
|
+
if (prop) {
|
|
72030
|
+
return isCircularMappedProperty(prop) ? void 0 : getTypeOfSymbol(prop);
|
|
72031
|
+
}
|
|
72032
|
+
if (isTupleType(t) && isNumericLiteralName(name) && +name >= 0) {
|
|
72033
|
+
const restType = getElementTypeOfSliceOfTupleType(
|
|
72034
|
+
t,
|
|
72035
|
+
t.target.fixedLength,
|
|
72036
|
+
/*endSkipCount*/
|
|
72037
|
+
0,
|
|
72038
|
+
/*writing*/
|
|
72039
|
+
false,
|
|
72040
|
+
/*noReductions*/
|
|
72041
|
+
true
|
|
72042
|
+
);
|
|
72043
|
+
if (restType) {
|
|
72044
|
+
return restType;
|
|
72045
|
+
}
|
|
72046
|
+
}
|
|
72047
|
+
return void 0;
|
|
72048
|
+
}
|
|
72049
|
+
function getTypeOfApplicableIndexInfoOfContextualType(t) {
|
|
72050
|
+
var _a;
|
|
72051
|
+
return (_a = findApplicableIndexInfo(getIndexInfosOfStructuredType(t), nameType || getStringLiteralType(unescapeLeadingUnderscores(name)))) == null ? void 0 : _a.type;
|
|
72052
|
+
}
|
|
71988
72053
|
}
|
|
71989
72054
|
function getContextualTypeForObjectLiteralMethod(node, contextFlags) {
|
|
71990
72055
|
Debug.assert(isObjectLiteralMethod(node));
|
|
@@ -74069,7 +74134,7 @@ function createTypeChecker(host) {
|
|
|
74069
74134
|
}
|
|
74070
74135
|
let diagnosticMessage;
|
|
74071
74136
|
const declarationName = idText(right);
|
|
74072
|
-
if (isInPropertyInitializerOrClassStaticBlock(node) && !isOptionalPropertyDeclaration(valueDeclaration) && !(isAccessExpression(node) && isAccessExpression(node.expression)) && !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right) && !(isMethodDeclaration(valueDeclaration) && getCombinedModifierFlagsCached(valueDeclaration) & 32 /* Static */) && (useDefineForClassFields || !isPropertyDeclaredInAncestorClass(prop))) {
|
|
74137
|
+
if (isInPropertyInitializerOrClassStaticBlock(node) && !isOptionalPropertyDeclaration(valueDeclaration) && !(isAccessExpression(node) && isAccessExpression(node.expression)) && !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right) && !(isMethodDeclaration(valueDeclaration) && getCombinedModifierFlagsCached(valueDeclaration) & 32 /* Static */) && (compilerOptions.useDefineForClassFields || !isPropertyDeclaredInAncestorClass(prop))) {
|
|
74073
74138
|
diagnosticMessage = error2(right, Diagnostics.Property_0_is_used_before_its_initialization, declarationName);
|
|
74074
74139
|
} else if (valueDeclaration.kind === 263 /* ClassDeclaration */ && node.parent.kind !== 183 /* TypeReference */ && !(valueDeclaration.flags & 33554432 /* Ambient */) && !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right)) {
|
|
74075
74140
|
diagnosticMessage = error2(right, Diagnostics.Class_0_used_before_its_declaration, declarationName);
|
|
@@ -76763,7 +76828,7 @@ function createTypeChecker(host) {
|
|
|
76763
76828
|
}
|
|
76764
76829
|
return restParameter.escapedName;
|
|
76765
76830
|
}
|
|
76766
|
-
function
|
|
76831
|
+
function getParameterIdentifierInfoAtPosition(signature, pos) {
|
|
76767
76832
|
var _a;
|
|
76768
76833
|
if (((_a = signature.declaration) == null ? void 0 : _a.kind) === 324 /* JSDocFunctionType */) {
|
|
76769
76834
|
return void 0;
|
|
@@ -76771,10 +76836,16 @@ function createTypeChecker(host) {
|
|
|
76771
76836
|
const paramCount = signature.parameters.length - (signatureHasRestParameter(signature) ? 1 : 0);
|
|
76772
76837
|
if (pos < paramCount) {
|
|
76773
76838
|
const param = signature.parameters[pos];
|
|
76774
|
-
|
|
76839
|
+
const paramIdent = getParameterDeclarationIdentifier(param);
|
|
76840
|
+
return paramIdent ? {
|
|
76841
|
+
parameter: paramIdent,
|
|
76842
|
+
parameterName: param.escapedName,
|
|
76843
|
+
isRestParameter: false
|
|
76844
|
+
} : void 0;
|
|
76775
76845
|
}
|
|
76776
76846
|
const restParameter = signature.parameters[paramCount] || unknownSymbol;
|
|
76777
|
-
|
|
76847
|
+
const restIdent = getParameterDeclarationIdentifier(restParameter);
|
|
76848
|
+
if (!restIdent) {
|
|
76778
76849
|
return void 0;
|
|
76779
76850
|
}
|
|
76780
76851
|
const restType = getTypeOfSymbol(restParameter);
|
|
@@ -76783,18 +76854,19 @@ function createTypeChecker(host) {
|
|
|
76783
76854
|
const index = pos - paramCount;
|
|
76784
76855
|
const associatedName = associatedNames == null ? void 0 : associatedNames[index];
|
|
76785
76856
|
const isRestTupleElement = !!(associatedName == null ? void 0 : associatedName.dotDotDotToken);
|
|
76786
|
-
|
|
76787
|
-
|
|
76788
|
-
isRestTupleElement
|
|
76789
|
-
|
|
76857
|
+
if (associatedName) {
|
|
76858
|
+
Debug.assert(isIdentifier(associatedName.name));
|
|
76859
|
+
return { parameter: associatedName.name, parameterName: associatedName.name.escapedText, isRestParameter: isRestTupleElement };
|
|
76860
|
+
}
|
|
76861
|
+
return void 0;
|
|
76790
76862
|
}
|
|
76791
76863
|
if (pos === paramCount) {
|
|
76792
|
-
return
|
|
76864
|
+
return { parameter: restIdent, parameterName: restParameter.escapedName, isRestParameter: true };
|
|
76793
76865
|
}
|
|
76794
76866
|
return void 0;
|
|
76795
76867
|
}
|
|
76796
|
-
function
|
|
76797
|
-
return symbol.valueDeclaration && isParameter(symbol.valueDeclaration) && isIdentifier(symbol.valueDeclaration.name);
|
|
76868
|
+
function getParameterDeclarationIdentifier(symbol) {
|
|
76869
|
+
return symbol.valueDeclaration && isParameter(symbol.valueDeclaration) && isIdentifier(symbol.valueDeclaration.name) && symbol.valueDeclaration.name;
|
|
76798
76870
|
}
|
|
76799
76871
|
function isValidDeclarationForTupleLabel(d) {
|
|
76800
76872
|
return d.kind === 202 /* NamedTupleMember */ || isParameter(d) && d.name && isIdentifier(d.name);
|
|
@@ -79763,7 +79835,7 @@ function createTypeChecker(host) {
|
|
|
79763
79835
|
case "length":
|
|
79764
79836
|
case "caller":
|
|
79765
79837
|
case "arguments":
|
|
79766
|
-
if (useDefineForClassFields) {
|
|
79838
|
+
if (compilerOptions.useDefineForClassFields) {
|
|
79767
79839
|
break;
|
|
79768
79840
|
}
|
|
79769
79841
|
case "prototype":
|
|
@@ -79911,7 +79983,7 @@ function createTypeChecker(host) {
|
|
|
79911
79983
|
if (classExtendsNull) {
|
|
79912
79984
|
error2(superCall, Diagnostics.A_constructor_cannot_contain_a_super_call_when_its_class_extends_null);
|
|
79913
79985
|
}
|
|
79914
|
-
const superCallShouldBeRootLevel = !useDefineForClassFields && (some(node.parent.members, isInstancePropertyWithInitializerOrPrivateIdentifierProperty) || some(node.parameters, (p) => hasSyntacticModifier(p, 16476 /* ParameterPropertyModifier */)));
|
|
79986
|
+
const superCallShouldBeRootLevel = (getEmitScriptTarget(compilerOptions) !== 99 /* ESNext */ || !useDefineForClassFields) && (some(node.parent.members, isInstancePropertyWithInitializerOrPrivateIdentifierProperty) || some(node.parameters, (p) => hasSyntacticModifier(p, 16476 /* ParameterPropertyModifier */)));
|
|
79915
79987
|
if (superCallShouldBeRootLevel) {
|
|
79916
79988
|
if (!superCallIsRootLevelInConstructor(superCall, node.body)) {
|
|
79917
79989
|
error2(superCall, Diagnostics.A_super_call_must_be_a_root_level_statement_within_a_constructor_of_a_derived_class_that_contains_initialized_properties_parameter_properties_or_private_identifiers);
|
|
@@ -83181,7 +83253,7 @@ function createTypeChecker(host) {
|
|
|
83181
83253
|
node
|
|
83182
83254
|
);
|
|
83183
83255
|
const willTransformPrivateElementsOrClassStaticBlocks = languageVersion <= 9 /* ES2022 */;
|
|
83184
|
-
const willTransformInitializers = !useDefineForClassFields
|
|
83256
|
+
const willTransformInitializers = !useDefineForClassFields || languageVersion < 9 /* ES2022 */;
|
|
83185
83257
|
if (willTransformStaticElementsOfDecoratedClass || willTransformPrivateElementsOrClassStaticBlocks) {
|
|
83186
83258
|
for (const member of node.members) {
|
|
83187
83259
|
if (willTransformStaticElementsOfDecoratedClass && classElementOrClassElementParameterIsDecorated(
|
|
@@ -127040,7 +127112,6 @@ function createWatchProgram(host) {
|
|
|
127040
127112
|
if (hasChangedCompilerOptions) {
|
|
127041
127113
|
newLine = updateNewLine();
|
|
127042
127114
|
if (program && changesAffectModuleResolution(program.getCompilerOptions(), compilerOptions)) {
|
|
127043
|
-
debugger;
|
|
127044
127115
|
resolutionCache.onChangesAffectModuleResolution();
|
|
127045
127116
|
}
|
|
127046
127117
|
}
|
|
@@ -136034,8 +136105,8 @@ function computeSuggestionDiagnostics(sourceFile, program, cancellationToken) {
|
|
|
136034
136105
|
diags.push(createDiagnosticForNode(init, Diagnostics.require_call_may_be_converted_to_an_import));
|
|
136035
136106
|
}
|
|
136036
136107
|
}
|
|
136037
|
-
const
|
|
136038
|
-
|
|
136108
|
+
const jsdocTypedefNodes = ts_codefix_exports.getJSDocTypedefNodes(node);
|
|
136109
|
+
for (const jsdocTypedefNode of jsdocTypedefNodes) {
|
|
136039
136110
|
diags.push(createDiagnosticForNode(jsdocTypedefNode, Diagnostics.JSDoc_typedef_may_be_converted_to_TypeScript_type));
|
|
136040
136111
|
}
|
|
136041
136112
|
if (ts_codefix_exports.parameterShouldGetTypeFromJSDoc(node)) {
|
|
@@ -146854,7 +146925,7 @@ __export(ts_codefix_exports, {
|
|
|
146854
146925
|
getFixes: () => getFixes,
|
|
146855
146926
|
getImportCompletionAction: () => getImportCompletionAction,
|
|
146856
146927
|
getImportKind: () => getImportKind,
|
|
146857
|
-
|
|
146928
|
+
getJSDocTypedefNodes: () => getJSDocTypedefNodes,
|
|
146858
146929
|
getNoopSymbolTrackerWithResolver: () => getNoopSymbolTrackerWithResolver,
|
|
146859
146930
|
getPromoteTypeOnlyCompletionAction: () => getPromoteTypeOnlyCompletionAction,
|
|
146860
146931
|
getSupportedErrorCodes: () => getSupportedErrorCodes,
|
|
@@ -149576,13 +149647,14 @@ registerCodeFix({
|
|
|
149576
149647
|
fixIds: [fixId14],
|
|
149577
149648
|
errorCodes: errorCodes15,
|
|
149578
149649
|
getCodeActions(context) {
|
|
149650
|
+
const newLineCharacter = getNewLineOrDefaultFromHost(context.host, context.formatContext.options);
|
|
149579
149651
|
const node = getTokenAtPosition(
|
|
149580
149652
|
context.sourceFile,
|
|
149581
149653
|
context.span.start
|
|
149582
149654
|
);
|
|
149583
149655
|
if (!node)
|
|
149584
149656
|
return;
|
|
149585
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange12(t, node, context.sourceFile));
|
|
149657
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange12(t, node, context.sourceFile, newLineCharacter));
|
|
149586
149658
|
if (changes.length > 0) {
|
|
149587
149659
|
return [
|
|
149588
149660
|
createCodeFixAction(
|
|
@@ -149595,29 +149667,72 @@ registerCodeFix({
|
|
|
149595
149667
|
];
|
|
149596
149668
|
}
|
|
149597
149669
|
},
|
|
149598
|
-
getAllCodeActions: (context) => codeFixAll(
|
|
149599
|
-
|
|
149600
|
-
|
|
149601
|
-
|
|
149602
|
-
|
|
149670
|
+
getAllCodeActions: (context) => codeFixAll(
|
|
149671
|
+
context,
|
|
149672
|
+
errorCodes15,
|
|
149673
|
+
(changes, diag2) => {
|
|
149674
|
+
const newLineCharacter = getNewLineOrDefaultFromHost(context.host, context.formatContext.options);
|
|
149675
|
+
const node = getTokenAtPosition(diag2.file, diag2.start);
|
|
149676
|
+
const fixAll = true;
|
|
149677
|
+
if (node)
|
|
149678
|
+
doChange12(changes, node, diag2.file, newLineCharacter, fixAll);
|
|
149679
|
+
}
|
|
149680
|
+
)
|
|
149603
149681
|
});
|
|
149604
|
-
function doChange12(changes, node, sourceFile) {
|
|
149605
|
-
if (isJSDocTypedefTag(node))
|
|
149606
|
-
fixSingleTypeDef(changes, node, sourceFile);
|
|
149607
|
-
}
|
|
149608
|
-
}
|
|
149609
|
-
function fixSingleTypeDef(changes, typeDefNode, sourceFile) {
|
|
149610
|
-
if (!typeDefNode)
|
|
149682
|
+
function doChange12(changes, node, sourceFile, newLine, fixAll = false) {
|
|
149683
|
+
if (!isJSDocTypedefTag(node))
|
|
149611
149684
|
return;
|
|
149612
|
-
const declaration = createDeclaration(
|
|
149685
|
+
const declaration = createDeclaration(node);
|
|
149613
149686
|
if (!declaration)
|
|
149614
149687
|
return;
|
|
149615
|
-
const
|
|
149616
|
-
|
|
149617
|
-
|
|
149618
|
-
|
|
149619
|
-
|
|
149688
|
+
const commentNode = node.parent;
|
|
149689
|
+
const { leftSibling, rightSibling } = getLeftAndRightSiblings(node);
|
|
149690
|
+
let pos = commentNode.getStart();
|
|
149691
|
+
let prefix = "";
|
|
149692
|
+
if (!leftSibling && commentNode.comment) {
|
|
149693
|
+
pos = findEndOfTextBetween(commentNode, commentNode.getStart(), node.getStart());
|
|
149694
|
+
prefix = `${newLine} */${newLine}`;
|
|
149695
|
+
}
|
|
149696
|
+
if (leftSibling) {
|
|
149697
|
+
if (fixAll && isJSDocTypedefTag(leftSibling)) {
|
|
149698
|
+
pos = node.getStart();
|
|
149699
|
+
prefix = "";
|
|
149700
|
+
} else {
|
|
149701
|
+
pos = findEndOfTextBetween(commentNode, leftSibling.getStart(), node.getStart());
|
|
149702
|
+
prefix = `${newLine} */${newLine}`;
|
|
149703
|
+
}
|
|
149704
|
+
}
|
|
149705
|
+
let end = commentNode.getEnd();
|
|
149706
|
+
let suffix = "";
|
|
149707
|
+
if (rightSibling) {
|
|
149708
|
+
if (fixAll && isJSDocTypedefTag(rightSibling)) {
|
|
149709
|
+
end = rightSibling.getStart();
|
|
149710
|
+
suffix = `${newLine}${newLine}`;
|
|
149711
|
+
} else {
|
|
149712
|
+
end = rightSibling.getStart();
|
|
149713
|
+
suffix = `${newLine}/**${newLine} * `;
|
|
149714
|
+
}
|
|
149715
|
+
}
|
|
149716
|
+
changes.replaceRange(sourceFile, { pos, end }, declaration, { prefix, suffix });
|
|
149717
|
+
}
|
|
149718
|
+
function getLeftAndRightSiblings(typedefNode) {
|
|
149719
|
+
const commentNode = typedefNode.parent;
|
|
149720
|
+
const maxChildIndex = commentNode.getChildCount() - 1;
|
|
149721
|
+
const currentNodeIndex = commentNode.getChildren().findIndex(
|
|
149722
|
+
(n) => n.getStart() === typedefNode.getStart() && n.getEnd() === typedefNode.getEnd()
|
|
149620
149723
|
);
|
|
149724
|
+
const leftSibling = currentNodeIndex > 0 ? commentNode.getChildAt(currentNodeIndex - 1) : void 0;
|
|
149725
|
+
const rightSibling = currentNodeIndex < maxChildIndex ? commentNode.getChildAt(currentNodeIndex + 1) : void 0;
|
|
149726
|
+
return { leftSibling, rightSibling };
|
|
149727
|
+
}
|
|
149728
|
+
function findEndOfTextBetween(jsDocComment, from, to) {
|
|
149729
|
+
const comment = jsDocComment.getText().substring(from - jsDocComment.getStart(), to - jsDocComment.getStart());
|
|
149730
|
+
for (let i = comment.length; i > 0; i--) {
|
|
149731
|
+
if (!/[*\/\s]/g.test(comment.substring(i - 1, i))) {
|
|
149732
|
+
return from + i;
|
|
149733
|
+
}
|
|
149734
|
+
}
|
|
149735
|
+
return to;
|
|
149621
149736
|
}
|
|
149622
149737
|
function createDeclaration(tag) {
|
|
149623
149738
|
var _a;
|
|
@@ -149638,7 +149753,7 @@ function createInterfaceForTypeLiteral(typeName, typeLiteral) {
|
|
|
149638
149753
|
const propertySignatures = createSignatureFromTypeLiteral(typeLiteral);
|
|
149639
149754
|
if (!some(propertySignatures))
|
|
149640
149755
|
return;
|
|
149641
|
-
|
|
149756
|
+
return factory.createInterfaceDeclaration(
|
|
149642
149757
|
/*modifiers*/
|
|
149643
149758
|
void 0,
|
|
149644
149759
|
typeName,
|
|
@@ -149648,13 +149763,12 @@ function createInterfaceForTypeLiteral(typeName, typeLiteral) {
|
|
|
149648
149763
|
void 0,
|
|
149649
149764
|
propertySignatures
|
|
149650
149765
|
);
|
|
149651
|
-
return interfaceDeclaration;
|
|
149652
149766
|
}
|
|
149653
149767
|
function createTypeAliasForTypeExpression(typeName, typeExpression) {
|
|
149654
149768
|
const typeReference = getSynthesizedDeepClone(typeExpression.type);
|
|
149655
149769
|
if (!typeReference)
|
|
149656
149770
|
return;
|
|
149657
|
-
|
|
149771
|
+
return factory.createTypeAliasDeclaration(
|
|
149658
149772
|
/*modifiers*/
|
|
149659
149773
|
void 0,
|
|
149660
149774
|
factory.createIdentifier(typeName),
|
|
@@ -149662,7 +149776,6 @@ function createTypeAliasForTypeExpression(typeName, typeExpression) {
|
|
|
149662
149776
|
void 0,
|
|
149663
149777
|
typeReference
|
|
149664
149778
|
);
|
|
149665
|
-
return declaration;
|
|
149666
149779
|
}
|
|
149667
149780
|
function createSignatureFromTypeLiteral(typeLiteral) {
|
|
149668
149781
|
const propertyTags = typeLiteral.jsDocPropertyTags;
|
|
@@ -149682,30 +149795,28 @@ function createSignatureFromTypeLiteral(typeLiteral) {
|
|
|
149682
149795
|
}
|
|
149683
149796
|
if (typeReference && name) {
|
|
149684
149797
|
const questionToken = isOptional ? factory.createToken(58 /* QuestionToken */) : void 0;
|
|
149685
|
-
|
|
149798
|
+
return factory.createPropertySignature(
|
|
149686
149799
|
/*modifiers*/
|
|
149687
149800
|
void 0,
|
|
149688
149801
|
name,
|
|
149689
149802
|
questionToken,
|
|
149690
149803
|
typeReference
|
|
149691
149804
|
);
|
|
149692
|
-
return prop;
|
|
149693
149805
|
}
|
|
149694
149806
|
};
|
|
149695
|
-
|
|
149696
|
-
return props;
|
|
149807
|
+
return mapDefined(propertyTags, getSignature);
|
|
149697
149808
|
}
|
|
149698
149809
|
function getPropertyName(tag) {
|
|
149699
149810
|
return tag.name.kind === 80 /* Identifier */ ? tag.name.text : tag.name.right.text;
|
|
149700
149811
|
}
|
|
149701
|
-
function
|
|
149812
|
+
function getJSDocTypedefNodes(node) {
|
|
149702
149813
|
if (hasJSDocNodes(node)) {
|
|
149703
|
-
return
|
|
149814
|
+
return flatMap(node.jsDoc, (doc) => {
|
|
149704
149815
|
var _a;
|
|
149705
|
-
return (_a =
|
|
149816
|
+
return (_a = doc.tags) == null ? void 0 : _a.filter((tag) => isJSDocTypedefTag(tag));
|
|
149706
149817
|
});
|
|
149707
149818
|
}
|
|
149708
|
-
return
|
|
149819
|
+
return [];
|
|
149709
149820
|
}
|
|
149710
149821
|
|
|
149711
149822
|
// src/services/codefixes/convertLiteralTypeToMappedType.ts
|
|
@@ -150838,6 +150949,14 @@ function promoteFromTypeOnly(changes, aliasDeclaration, compilerOptions, sourceF
|
|
|
150838
150949
|
}
|
|
150839
150950
|
function promoteImportClause(importClause) {
|
|
150840
150951
|
changes.delete(sourceFile, getTypeKeywordOfTypeOnlyImport(importClause, sourceFile));
|
|
150952
|
+
if (!compilerOptions.allowImportingTsExtensions) {
|
|
150953
|
+
const moduleSpecifier = tryGetModuleSpecifierFromDeclaration(importClause.parent);
|
|
150954
|
+
const resolvedModule = moduleSpecifier && getResolvedModule(sourceFile, moduleSpecifier.text, getModeForUsageLocation(sourceFile, moduleSpecifier));
|
|
150955
|
+
if (resolvedModule == null ? void 0 : resolvedModule.resolvedUsingTsExtension) {
|
|
150956
|
+
const changedExtension = changeAnyExtension(moduleSpecifier.text, getOutputExtension(moduleSpecifier.text, compilerOptions));
|
|
150957
|
+
changes.replaceNode(sourceFile, moduleSpecifier, factory.createStringLiteral(changedExtension));
|
|
150958
|
+
}
|
|
150959
|
+
}
|
|
150841
150960
|
if (convertExistingToTypeOnly) {
|
|
150842
150961
|
const namedImports = tryCast(importClause.namedBindings, isNamedImports);
|
|
150843
150962
|
if (namedImports && namedImports.elements.length > 1) {
|
|
@@ -151955,6 +152074,8 @@ function getInfo9(checker, sourceFile, position, errorCode) {
|
|
|
151955
152074
|
if (!declaration || !isCallExpression(declaration.parent) || !declaration.body)
|
|
151956
152075
|
return void 0;
|
|
151957
152076
|
const pos = declaration.parent.arguments.indexOf(declaration);
|
|
152077
|
+
if (pos === -1)
|
|
152078
|
+
return void 0;
|
|
151958
152079
|
const type = checker.getContextualTypeForArgumentAtIndex(declaration.parent, pos);
|
|
151959
152080
|
if (!type)
|
|
151960
152081
|
return void 0;
|
|
@@ -155122,15 +155243,11 @@ var PreserveOptionalFlags = /* @__PURE__ */ ((PreserveOptionalFlags2) => {
|
|
|
155122
155243
|
})(PreserveOptionalFlags || {});
|
|
155123
155244
|
function addNewNodeForMemberSymbol(symbol, enclosingDeclaration, sourceFile, context, preferences, importAdder, addClassElement, body, preserveOptional = 3 /* All */, isAmbient = false) {
|
|
155124
155245
|
const declarations = symbol.getDeclarations();
|
|
155125
|
-
const declaration = declarations
|
|
155246
|
+
const declaration = firstOrUndefined(declarations);
|
|
155126
155247
|
const checker = context.program.getTypeChecker();
|
|
155127
155248
|
const scriptTarget = getEmitScriptTarget(context.program.getCompilerOptions());
|
|
155128
155249
|
const kind = (declaration == null ? void 0 : declaration.kind) ?? 171 /* PropertySignature */;
|
|
155129
|
-
const declarationName =
|
|
155130
|
-
getNameOfDeclaration(declaration),
|
|
155131
|
-
/*includeTrivia*/
|
|
155132
|
-
false
|
|
155133
|
-
);
|
|
155250
|
+
const declarationName = createDeclarationName(symbol, declaration);
|
|
155134
155251
|
const effectiveModifierFlags = declaration ? getEffectiveModifierFlags(declaration) : 0 /* None */;
|
|
155135
155252
|
let modifierFlags = effectiveModifierFlags & 32 /* Static */;
|
|
155136
155253
|
modifierFlags |= effectiveModifierFlags & 4 /* Public */ ? 4 /* Public */ : effectiveModifierFlags & 16 /* Protected */ ? 16 /* Protected */ : 0 /* None */;
|
|
@@ -155281,6 +155398,19 @@ function addNewNodeForMemberSymbol(symbol, enclosingDeclaration, sourceFile, con
|
|
|
155281
155398
|
false
|
|
155282
155399
|
);
|
|
155283
155400
|
}
|
|
155401
|
+
function createDeclarationName(symbol2, declaration2) {
|
|
155402
|
+
if (getCheckFlags(symbol2) & 262144 /* Mapped */) {
|
|
155403
|
+
const nameType = symbol2.links.nameType;
|
|
155404
|
+
if (nameType && isTypeUsableAsPropertyName(nameType)) {
|
|
155405
|
+
return factory.createIdentifier(unescapeLeadingUnderscores(getPropertyNameFromType(nameType)));
|
|
155406
|
+
}
|
|
155407
|
+
}
|
|
155408
|
+
return getSynthesizedDeepClone(
|
|
155409
|
+
getNameOfDeclaration(declaration2),
|
|
155410
|
+
/*includeTrivia*/
|
|
155411
|
+
false
|
|
155412
|
+
);
|
|
155413
|
+
}
|
|
155284
155414
|
}
|
|
155285
155415
|
function createSignatureDeclarationFromSignature(kind, context, quotePreference, signature, body, name, modifiers, optional, enclosingDeclaration, importAdder) {
|
|
155286
155416
|
const program = context.program;
|
|
@@ -164498,7 +164628,7 @@ __export(ts_InlayHints_exports, {
|
|
|
164498
164628
|
});
|
|
164499
164629
|
|
|
164500
164630
|
// src/services/inlayHints.ts
|
|
164501
|
-
var
|
|
164631
|
+
var maxTypeHintLength = 30;
|
|
164502
164632
|
var leadingParameterNameCommentRegexFactory = (name) => {
|
|
164503
164633
|
return new RegExp(`^\\s?/\\*\\*?\\s?${name}\\s?\\*\\/\\s?$`);
|
|
164504
164634
|
};
|
|
@@ -164508,6 +164638,9 @@ function shouldShowParameterNameHints(preferences) {
|
|
|
164508
164638
|
function shouldShowLiteralParameterNameHintsOnly(preferences) {
|
|
164509
164639
|
return preferences.includeInlayParameterNameHints === "literals";
|
|
164510
164640
|
}
|
|
164641
|
+
function shouldUseInteractiveInlayHints(preferences) {
|
|
164642
|
+
return preferences.interactiveInlayHints === true;
|
|
164643
|
+
}
|
|
164511
164644
|
function provideInlayHints(context) {
|
|
164512
164645
|
const { file, program, span, cancellationToken, preferences } = context;
|
|
164513
164646
|
const sourceFileText = file.text;
|
|
@@ -164558,9 +164691,15 @@ function provideInlayHints(context) {
|
|
|
164558
164691
|
function isSignatureSupportingReturnAnnotation(node) {
|
|
164559
164692
|
return isArrowFunction(node) || isFunctionExpression(node) || isFunctionDeclaration(node) || isMethodDeclaration(node) || isGetAccessorDeclaration(node);
|
|
164560
164693
|
}
|
|
164561
|
-
function addParameterHints(text, position, isFirstVariadicArgument) {
|
|
164694
|
+
function addParameterHints(text, parameter, position, isFirstVariadicArgument, sourceFile) {
|
|
164695
|
+
let hintText = `${isFirstVariadicArgument ? "..." : ""}${text}`;
|
|
164696
|
+
if (shouldUseInteractiveInlayHints(preferences)) {
|
|
164697
|
+
hintText = [getNodeDisplayPart(hintText, parameter, sourceFile), { text: ":" }];
|
|
164698
|
+
} else {
|
|
164699
|
+
hintText += ":";
|
|
164700
|
+
}
|
|
164562
164701
|
result.push({
|
|
164563
|
-
text:
|
|
164702
|
+
text: hintText,
|
|
164564
164703
|
position,
|
|
164565
164704
|
kind: "Parameter" /* Parameter */,
|
|
164566
164705
|
whitespaceAfter: true
|
|
@@ -164568,7 +164707,7 @@ function provideInlayHints(context) {
|
|
|
164568
164707
|
}
|
|
164569
164708
|
function addTypeHints(text, position) {
|
|
164570
164709
|
result.push({
|
|
164571
|
-
text: `: ${
|
|
164710
|
+
text: `: ${text.length > maxTypeHintLength ? text.substr(0, maxTypeHintLength - "...".length) + "..." : text}`,
|
|
164572
164711
|
position,
|
|
164573
164712
|
kind: "Type" /* Type */,
|
|
164574
164713
|
whitespaceBefore: true
|
|
@@ -164576,7 +164715,7 @@ function provideInlayHints(context) {
|
|
|
164576
164715
|
}
|
|
164577
164716
|
function addEnumMemberValueHints(text, position) {
|
|
164578
164717
|
result.push({
|
|
164579
|
-
text: `= ${
|
|
164718
|
+
text: `= ${text}`,
|
|
164580
164719
|
position,
|
|
164581
164720
|
kind: "Enum" /* Enum */,
|
|
164582
164721
|
whitespaceBefore: true
|
|
@@ -164626,6 +164765,7 @@ function provideInlayHints(context) {
|
|
|
164626
164765
|
return;
|
|
164627
164766
|
}
|
|
164628
164767
|
let signatureParamPos = 0;
|
|
164768
|
+
const sourceFile = shouldUseInteractiveInlayHints(preferences) ? expr.getSourceFile() : void 0;
|
|
164629
164769
|
for (const originalArg of args) {
|
|
164630
164770
|
const arg = skipParentheses(originalArg);
|
|
164631
164771
|
if (shouldShowLiteralParameterNameHintsOnly(preferences) && !isHintableLiteral(arg)) {
|
|
@@ -164646,10 +164786,10 @@ function provideInlayHints(context) {
|
|
|
164646
164786
|
}
|
|
164647
164787
|
}
|
|
164648
164788
|
}
|
|
164649
|
-
const
|
|
164789
|
+
const identifierInfo = checker.getParameterIdentifierInfoAtPosition(signature, signatureParamPos);
|
|
164650
164790
|
signatureParamPos = signatureParamPos + (spreadArgs || 1);
|
|
164651
|
-
if (
|
|
164652
|
-
const
|
|
164791
|
+
if (identifierInfo) {
|
|
164792
|
+
const { parameter, parameterName, isRestParameter: isFirstVariadicArgument } = identifierInfo;
|
|
164653
164793
|
const isParameterNameNotSameAsArgument = preferences.includeInlayParameterNameHintsWhenArgumentMatchesName || !identifierOrAccessExpressionPostfixMatchesParameterName(arg, parameterName);
|
|
164654
164794
|
if (!isParameterNameNotSameAsArgument && !isFirstVariadicArgument) {
|
|
164655
164795
|
continue;
|
|
@@ -164658,7 +164798,7 @@ function provideInlayHints(context) {
|
|
|
164658
164798
|
if (leadingCommentsContainsParameterName(arg, name)) {
|
|
164659
164799
|
continue;
|
|
164660
164800
|
}
|
|
164661
|
-
addParameterHints(name, originalArg.getStart(), isFirstVariadicArgument);
|
|
164801
|
+
addParameterHints(name, parameter, originalArg.getStart(), isFirstVariadicArgument, sourceFile);
|
|
164662
164802
|
}
|
|
164663
164803
|
}
|
|
164664
164804
|
}
|
|
@@ -164764,12 +164904,6 @@ function provideInlayHints(context) {
|
|
|
164764
164904
|
}
|
|
164765
164905
|
return printTypeInSingleLine(signatureParamType);
|
|
164766
164906
|
}
|
|
164767
|
-
function truncation(text, maxLength2) {
|
|
164768
|
-
if (text.length > maxLength2) {
|
|
164769
|
-
return text.substr(0, maxLength2 - "...".length) + "...";
|
|
164770
|
-
}
|
|
164771
|
-
return text;
|
|
164772
|
-
}
|
|
164773
164907
|
function printTypeInSingleLine(type) {
|
|
164774
164908
|
const flags = 70221824 /* IgnoreErrors */ | 1048576 /* AllowUniqueESSymbolType */ | 16384 /* UseAliasDefinedOutsideCurrentScope */;
|
|
164775
164909
|
const printer = createPrinterWithRemoveComments();
|
|
@@ -164800,6 +164934,13 @@ function provideInlayHints(context) {
|
|
|
164800
164934
|
}
|
|
164801
164935
|
return true;
|
|
164802
164936
|
}
|
|
164937
|
+
function getNodeDisplayPart(text, node, sourceFile) {
|
|
164938
|
+
return {
|
|
164939
|
+
text,
|
|
164940
|
+
span: createTextSpanFromNode(node, sourceFile),
|
|
164941
|
+
file: sourceFile.fileName
|
|
164942
|
+
};
|
|
164943
|
+
}
|
|
164803
164944
|
}
|
|
164804
164945
|
|
|
164805
164946
|
// src/services/_namespaces/ts.JsDoc.ts
|
|
@@ -167219,7 +167360,7 @@ function getSymbolModifiers(typeChecker, symbol) {
|
|
|
167219
167360
|
}
|
|
167220
167361
|
return modifiers.size > 0 ? arrayFrom(modifiers.values()).join(",") : "" /* none */;
|
|
167221
167362
|
}
|
|
167222
|
-
function
|
|
167363
|
+
function getSymbolDisplayPartsDocumentationAndSymbolKindWorker(typeChecker, symbol, sourceFile, enclosingDeclaration, location, type, semanticMeaning, alias) {
|
|
167223
167364
|
var _a;
|
|
167224
167365
|
const displayParts = [];
|
|
167225
167366
|
let documentation = [];
|
|
@@ -167228,7 +167369,6 @@ function getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, so
|
|
|
167228
167369
|
let symbolKind = semanticMeaning & 1 /* Value */ ? getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker, symbol, location) : "" /* unknown */;
|
|
167229
167370
|
let hasAddedSymbolInfo = false;
|
|
167230
167371
|
const isThisExpression = location.kind === 110 /* ThisKeyword */ && isInExpressionContext(location) || isThisInTypeQuery(location);
|
|
167231
|
-
let type;
|
|
167232
167372
|
let documentationFromAlias;
|
|
167233
167373
|
let tagsFromAlias;
|
|
167234
167374
|
let hasMultipleSignatures = false;
|
|
@@ -167257,7 +167397,7 @@ function getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, so
|
|
|
167257
167397
|
}
|
|
167258
167398
|
}
|
|
167259
167399
|
let signature;
|
|
167260
|
-
type = isThisExpression ? typeChecker.getTypeAtLocation(location) : typeChecker.getTypeOfSymbolAtLocation(symbol, location);
|
|
167400
|
+
type ?? (type = isThisExpression ? typeChecker.getTypeAtLocation(location) : typeChecker.getTypeOfSymbolAtLocation(symbol, location));
|
|
167261
167401
|
if (location.parent && location.parent.kind === 211 /* PropertyAccessExpression */) {
|
|
167262
167402
|
const right = location.parent.name;
|
|
167263
167403
|
if (right === location || right && right.getFullWidth() === 0) {
|
|
@@ -167472,12 +167612,13 @@ function getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, so
|
|
|
167472
167612
|
if (declarationName && !hasAddedSymbolInfo) {
|
|
167473
167613
|
const isExternalModuleDeclaration = isModuleWithStringLiteralName(resolvedNode) && hasSyntacticModifier(resolvedNode, 2 /* Ambient */);
|
|
167474
167614
|
const shouldUseAliasName = symbol.name !== "default" && !isExternalModuleDeclaration;
|
|
167475
|
-
const resolvedInfo =
|
|
167615
|
+
const resolvedInfo = getSymbolDisplayPartsDocumentationAndSymbolKindWorker(
|
|
167476
167616
|
typeChecker,
|
|
167477
167617
|
resolvedSymbol,
|
|
167478
167618
|
getSourceFileOfNode(resolvedNode),
|
|
167479
167619
|
resolvedNode,
|
|
167480
167620
|
declarationName,
|
|
167621
|
+
type,
|
|
167481
167622
|
semanticMeaning,
|
|
167482
167623
|
shouldUseAliasName ? symbol : resolvedSymbol
|
|
167483
167624
|
);
|
|
@@ -167732,6 +167873,19 @@ function getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, so
|
|
|
167732
167873
|
addRange(displayParts, typeParameterParts);
|
|
167733
167874
|
}
|
|
167734
167875
|
}
|
|
167876
|
+
function getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, sourceFile, enclosingDeclaration, location, semanticMeaning = getMeaningFromLocation(location), alias) {
|
|
167877
|
+
return getSymbolDisplayPartsDocumentationAndSymbolKindWorker(
|
|
167878
|
+
typeChecker,
|
|
167879
|
+
symbol,
|
|
167880
|
+
sourceFile,
|
|
167881
|
+
enclosingDeclaration,
|
|
167882
|
+
location,
|
|
167883
|
+
/*type*/
|
|
167884
|
+
void 0,
|
|
167885
|
+
semanticMeaning,
|
|
167886
|
+
alias
|
|
167887
|
+
);
|
|
167888
|
+
}
|
|
167735
167889
|
function isLocalVariableOrFunction(symbol) {
|
|
167736
167890
|
if (symbol.parent) {
|
|
167737
167891
|
return false;
|
|
@@ -172741,6 +172895,7 @@ __export(ts_exports2, {
|
|
|
172741
172895
|
getPropertyAssignmentAliasLikeExpression: () => getPropertyAssignmentAliasLikeExpression,
|
|
172742
172896
|
getPropertyNameForPropertyNameNode: () => getPropertyNameForPropertyNameNode,
|
|
172743
172897
|
getPropertyNameForUniqueESSymbol: () => getPropertyNameForUniqueESSymbol,
|
|
172898
|
+
getPropertyNameFromType: () => getPropertyNameFromType,
|
|
172744
172899
|
getPropertyNameOfBindingOrAssignmentElement: () => getPropertyNameOfBindingOrAssignmentElement,
|
|
172745
172900
|
getPropertySymbolFromBindingElement: () => getPropertySymbolFromBindingElement,
|
|
172746
172901
|
getPropertySymbolsFromContextualType: () => getPropertySymbolsFromContextualType,
|
|
@@ -173573,6 +173728,7 @@ __export(ts_exports2, {
|
|
|
173573
173728
|
isTypeQueryNode: () => isTypeQueryNode,
|
|
173574
173729
|
isTypeReferenceNode: () => isTypeReferenceNode,
|
|
173575
173730
|
isTypeReferenceType: () => isTypeReferenceType,
|
|
173731
|
+
isTypeUsableAsPropertyName: () => isTypeUsableAsPropertyName,
|
|
173576
173732
|
isUMDExportSymbol: () => isUMDExportSymbol,
|
|
173577
173733
|
isUnaryExpression: () => isUnaryExpression,
|
|
173578
173734
|
isUnaryExpressionWithWrite: () => isUnaryExpressionWithWrite,
|
|
@@ -183431,10 +183587,22 @@ Project '${project.projectName}' (${ProjectKind[project.projectKind]}) ${counter
|
|
|
183431
183587
|
const { file, project } = this.getFileAndProject(args);
|
|
183432
183588
|
const scriptInfo = this.projectService.getScriptInfoForNormalizedPath(file);
|
|
183433
183589
|
const hints = project.getLanguageService().provideInlayHints(file, args, this.getPreferences(file));
|
|
183434
|
-
return hints.map((hint) =>
|
|
183435
|
-
|
|
183436
|
-
|
|
183437
|
-
|
|
183590
|
+
return hints.map((hint) => {
|
|
183591
|
+
const { text, position } = hint;
|
|
183592
|
+
const hintText = typeof text === "string" ? text : text.map(({ text: text2, span, file: file2 }) => ({
|
|
183593
|
+
text: text2,
|
|
183594
|
+
span: span && {
|
|
183595
|
+
start: scriptInfo.positionToLineOffset(span.start),
|
|
183596
|
+
end: scriptInfo.positionToLineOffset(span.start + span.length),
|
|
183597
|
+
file: file2
|
|
183598
|
+
}
|
|
183599
|
+
}));
|
|
183600
|
+
return {
|
|
183601
|
+
...hint,
|
|
183602
|
+
position: scriptInfo.positionToLineOffset(position),
|
|
183603
|
+
text: hintText
|
|
183604
|
+
};
|
|
183605
|
+
});
|
|
183438
183606
|
}
|
|
183439
183607
|
setCompilerOptionsForInferredProjects(args) {
|
|
183440
183608
|
this.projectService.setCompilerOptionsForInferredProjects(args.options, args.projectRootPath);
|
|
@@ -187255,6 +187423,7 @@ start(initializeNodeSystem(), require("os").platform());
|
|
|
187255
187423
|
getPropertyAssignmentAliasLikeExpression,
|
|
187256
187424
|
getPropertyNameForPropertyNameNode,
|
|
187257
187425
|
getPropertyNameForUniqueESSymbol,
|
|
187426
|
+
getPropertyNameFromType,
|
|
187258
187427
|
getPropertyNameOfBindingOrAssignmentElement,
|
|
187259
187428
|
getPropertySymbolFromBindingElement,
|
|
187260
187429
|
getPropertySymbolsFromContextualType,
|
|
@@ -188087,6 +188256,7 @@ start(initializeNodeSystem(), require("os").platform());
|
|
|
188087
188256
|
isTypeQueryNode,
|
|
188088
188257
|
isTypeReferenceNode,
|
|
188089
188258
|
isTypeReferenceType,
|
|
188259
|
+
isTypeUsableAsPropertyName,
|
|
188090
188260
|
isUMDExportSymbol,
|
|
188091
188261
|
isUnaryExpression,
|
|
188092
188262
|
isUnaryExpressionWithWrite,
|