@typescript-deploys/pr-build 5.2.0-pr-55028-5 → 5.2.0-pr-54753-25
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 +154 -94
- package/lib/tsserver.js +318 -157
- package/lib/tsserverlibrary.d.ts +13 -2
- package/lib/tsserverlibrary.js +317 -158
- package/lib/typescript.d.ts +7 -1
- package/lib/typescript.js +299 -154
- package/lib/typingsInstaller.js +12 -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.20230726`;
|
|
2331
2333
|
var Comparison = /* @__PURE__ */ ((Comparison3) => {
|
|
2332
2334
|
Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
|
|
2333
2335
|
Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
|
|
@@ -9285,6 +9287,7 @@ var Diagnostics = {
|
|
|
9285
9287
|
Type_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method: diag(1062, 1 /* Error */, "Type_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method_1062", "Type is referenced directly or indirectly in the fulfillment callback of its own 'then' method."),
|
|
9286
9288
|
An_export_assignment_cannot_be_used_in_a_namespace: diag(1063, 1 /* Error */, "An_export_assignment_cannot_be_used_in_a_namespace_1063", "An export assignment cannot be used in a namespace."),
|
|
9287
9289
|
The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type_Did_you_mean_to_write_Promise_0: diag(1064, 1 /* Error */, "The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type_Did_you_mean_to_wri_1064", "The return type of an async function or method must be the global Promise<T> type. Did you mean to write 'Promise<{0}>'?"),
|
|
9290
|
+
The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type: diag(1065, 1 /* Error */, "The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type_1065", "The return type of an async function or method must be the global Promise<T> type."),
|
|
9288
9291
|
In_ambient_enum_declarations_member_initializer_must_be_constant_expression: diag(1066, 1 /* Error */, "In_ambient_enum_declarations_member_initializer_must_be_constant_expression_1066", "In ambient enum declarations member initializer must be constant expression."),
|
|
9289
9292
|
Unexpected_token_A_constructor_method_accessor_or_property_was_expected: diag(1068, 1 /* Error */, "Unexpected_token_A_constructor_method_accessor_or_property_was_expected_1068", "Unexpected token. A constructor, method, accessor, or property was expected."),
|
|
9290
9293
|
Unexpected_token_A_type_parameter_name_was_expected_without_curly_braces: diag(1069, 1 /* Error */, "Unexpected_token_A_type_parameter_name_was_expected_without_curly_braces_1069", "Unexpected token. A type parameter name was expected without curly braces."),
|
|
@@ -21601,6 +21604,18 @@ function getTextOfJsxNamespacedName(node) {
|
|
|
21601
21604
|
function intrinsicTagNameToString(node) {
|
|
21602
21605
|
return isIdentifier(node) ? idText(node) : getTextOfJsxNamespacedName(node);
|
|
21603
21606
|
}
|
|
21607
|
+
function isTypeUsableAsPropertyName(type) {
|
|
21608
|
+
return !!(type.flags & 8576 /* StringOrNumberLiteralOrUnique */);
|
|
21609
|
+
}
|
|
21610
|
+
function getPropertyNameFromType(type) {
|
|
21611
|
+
if (type.flags & 8192 /* UniqueESSymbol */) {
|
|
21612
|
+
return type.escapedName;
|
|
21613
|
+
}
|
|
21614
|
+
if (type.flags & (128 /* StringLiteral */ | 256 /* NumberLiteral */)) {
|
|
21615
|
+
return escapeLeadingUnderscores("" + type.value);
|
|
21616
|
+
}
|
|
21617
|
+
return Debug.fail();
|
|
21618
|
+
}
|
|
21604
21619
|
|
|
21605
21620
|
// src/compiler/factory/baseNodeFactory.ts
|
|
21606
21621
|
function createBaseNodeFactory() {
|
|
@@ -35109,10 +35124,14 @@ var Parser;
|
|
|
35109
35124
|
case 124 /* ProtectedKeyword */:
|
|
35110
35125
|
case 125 /* PublicKeyword */:
|
|
35111
35126
|
case 148 /* ReadonlyKeyword */:
|
|
35127
|
+
const previousToken = token();
|
|
35112
35128
|
nextToken();
|
|
35113
35129
|
if (scanner2.hasPrecedingLineBreak()) {
|
|
35114
35130
|
return false;
|
|
35115
35131
|
}
|
|
35132
|
+
if (previousToken === 138 /* DeclareKeyword */ && token() === 156 /* TypeKeyword */) {
|
|
35133
|
+
return true;
|
|
35134
|
+
}
|
|
35116
35135
|
continue;
|
|
35117
35136
|
case 162 /* GlobalKeyword */:
|
|
35118
35137
|
nextToken();
|
|
@@ -35477,14 +35496,14 @@ var Parser;
|
|
|
35477
35496
|
function parseObjectBindingPattern() {
|
|
35478
35497
|
const pos = getNodePos();
|
|
35479
35498
|
parseExpected(19 /* OpenBraceToken */);
|
|
35480
|
-
const elements = parseDelimitedList(9 /* ObjectBindingElements */, parseObjectBindingElement);
|
|
35499
|
+
const elements = allowInAnd(() => parseDelimitedList(9 /* ObjectBindingElements */, parseObjectBindingElement));
|
|
35481
35500
|
parseExpected(20 /* CloseBraceToken */);
|
|
35482
35501
|
return finishNode(factory2.createObjectBindingPattern(elements), pos);
|
|
35483
35502
|
}
|
|
35484
35503
|
function parseArrayBindingPattern() {
|
|
35485
35504
|
const pos = getNodePos();
|
|
35486
35505
|
parseExpected(23 /* OpenBracketToken */);
|
|
35487
|
-
const elements = parseDelimitedList(10 /* ArrayBindingElements */, parseArrayBindingElement);
|
|
35506
|
+
const elements = allowInAnd(() => parseDelimitedList(10 /* ArrayBindingElements */, parseArrayBindingElement));
|
|
35488
35507
|
parseExpected(24 /* CloseBracketToken */);
|
|
35489
35508
|
return finishNode(factory2.createArrayBindingPattern(elements), pos);
|
|
35490
35509
|
}
|
|
@@ -36002,6 +36021,9 @@ var Parser;
|
|
|
36002
36021
|
}
|
|
36003
36022
|
function parseTypeAliasDeclaration(pos, hasJSDoc, modifiers) {
|
|
36004
36023
|
parseExpected(156 /* TypeKeyword */);
|
|
36024
|
+
if (scanner2.hasPrecedingLineBreak()) {
|
|
36025
|
+
parseErrorAtCurrentToken(Diagnostics.Line_break_not_permitted_here);
|
|
36026
|
+
}
|
|
36005
36027
|
const name = parseIdentifier();
|
|
36006
36028
|
const typeParameters = parseTypeParameters();
|
|
36007
36029
|
parseExpected(64 /* EqualsToken */);
|
|
@@ -37903,7 +37925,7 @@ function getNamedArgRegEx(name) {
|
|
|
37903
37925
|
return result;
|
|
37904
37926
|
}
|
|
37905
37927
|
var tripleSlashXMLCommentStartRegEx = /^\/\/\/\s*<(\S+)\s.*?\/>/im;
|
|
37906
|
-
var singleLinePragmaRegEx = /^\/\/\/?\s*@(
|
|
37928
|
+
var singleLinePragmaRegEx = /^\/\/\/?\s*@([^\s:]+)(.*)\s*$/im;
|
|
37907
37929
|
function extractPragmas(pragmas, range, text) {
|
|
37908
37930
|
const tripleSlash = range.kind === 2 /* SingleLineCommentTrivia */ && tripleSlashXMLCommentStartRegEx.exec(text);
|
|
37909
37931
|
if (tripleSlash) {
|
|
@@ -43870,6 +43892,9 @@ function getModuleInstanceStateForAliasTarget(specifier, visited) {
|
|
|
43870
43892
|
if (found === 1 /* Instantiated */) {
|
|
43871
43893
|
return found;
|
|
43872
43894
|
}
|
|
43895
|
+
if (statement.kind === 271 /* ImportEqualsDeclaration */) {
|
|
43896
|
+
found = 1 /* Instantiated */;
|
|
43897
|
+
}
|
|
43873
43898
|
}
|
|
43874
43899
|
}
|
|
43875
43900
|
if (found !== void 0) {
|
|
@@ -47818,7 +47843,7 @@ function createTypeChecker(host) {
|
|
|
47818
47843
|
return node ? getTypeFromTypeNode(node) : errorType;
|
|
47819
47844
|
},
|
|
47820
47845
|
getParameterType: getTypeAtPosition,
|
|
47821
|
-
|
|
47846
|
+
getParameterIdentifierInfoAtPosition,
|
|
47822
47847
|
getPromisedTypeOfPromise,
|
|
47823
47848
|
getAwaitedType: (type) => getAwaitedType(type),
|
|
47824
47849
|
getReturnTypeOfSignature,
|
|
@@ -49082,7 +49107,7 @@ function createTypeChecker(host) {
|
|
|
49082
49107
|
false
|
|
49083
49108
|
);
|
|
49084
49109
|
} else if (isParameterPropertyDeclaration(declaration, declaration.parent)) {
|
|
49085
|
-
return !(useDefineForClassFields && getContainingClass(declaration) === getContainingClass(usage) && isUsedInFunctionOrInstanceProperty(usage, declaration));
|
|
49110
|
+
return !(getEmitScriptTarget(compilerOptions) === 99 /* ESNext */ && useDefineForClassFields && getContainingClass(declaration) === getContainingClass(usage) && isUsedInFunctionOrInstanceProperty(usage, declaration));
|
|
49086
49111
|
}
|
|
49087
49112
|
return true;
|
|
49088
49113
|
}
|
|
@@ -49096,7 +49121,7 @@ function createTypeChecker(host) {
|
|
|
49096
49121
|
return true;
|
|
49097
49122
|
}
|
|
49098
49123
|
if (isUsedInFunctionOrInstanceProperty(usage, declaration)) {
|
|
49099
|
-
if (useDefineForClassFields && getContainingClass(declaration) && (isPropertyDeclaration(declaration) || isParameterPropertyDeclaration(declaration, declaration.parent))) {
|
|
49124
|
+
if (getEmitScriptTarget(compilerOptions) >= 9 /* ES2022 */ && useDefineForClassFields && getContainingClass(declaration) && (isPropertyDeclaration(declaration) || isParameterPropertyDeclaration(declaration, declaration.parent))) {
|
|
49100
49125
|
return !isPropertyImmediatelyReferencedWithinDeclaration(
|
|
49101
49126
|
declaration,
|
|
49102
49127
|
usage,
|
|
@@ -49220,7 +49245,7 @@ function createTypeChecker(host) {
|
|
|
49220
49245
|
return requiresScopeChangeWorker(node.name);
|
|
49221
49246
|
case 172 /* PropertyDeclaration */:
|
|
49222
49247
|
if (hasStaticModifier(node)) {
|
|
49223
|
-
return !useDefineForClassFields;
|
|
49248
|
+
return target < 99 /* ESNext */ || !useDefineForClassFields;
|
|
49224
49249
|
}
|
|
49225
49250
|
return requiresScopeChangeWorker(node.name);
|
|
49226
49251
|
default:
|
|
@@ -49491,7 +49516,7 @@ function createTypeChecker(host) {
|
|
|
49491
49516
|
}
|
|
49492
49517
|
}
|
|
49493
49518
|
function checkAndReportErrorForInvalidInitializer() {
|
|
49494
|
-
if (propertyWithInvalidInitializer && !useDefineForClassFields) {
|
|
49519
|
+
if (propertyWithInvalidInitializer && !(useDefineForClassFields && getEmitScriptTarget(compilerOptions) >= 9 /* ES2022 */)) {
|
|
49495
49520
|
error2(
|
|
49496
49521
|
errorLocation,
|
|
49497
49522
|
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 +50900,7 @@ function createTypeChecker(host) {
|
|
|
50875
50900
|
return isStringLiteralLike(moduleReferenceExpression) ? resolveExternalModule(location, moduleReferenceExpression.text, moduleNotFoundError, moduleReferenceExpression, isForAugmentation) : void 0;
|
|
50876
50901
|
}
|
|
50877
50902
|
function resolveExternalModule(location, moduleReference, moduleNotFoundError, errorNode, isForAugmentation = false) {
|
|
50878
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
50903
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
50879
50904
|
if (startsWith(moduleReference, "@types/")) {
|
|
50880
50905
|
const diag2 = Diagnostics.Cannot_import_type_declaration_files_Consider_importing_0_instead_of_1;
|
|
50881
50906
|
const withoutAtTypePrefix = removePrefix(moduleReference, "@types/");
|
|
@@ -50910,8 +50935,11 @@ function createTypeChecker(host) {
|
|
|
50910
50935
|
);
|
|
50911
50936
|
}
|
|
50912
50937
|
} else if (resolvedModule.resolvedUsingTsExtension && !shouldAllowImportingTsExtension(compilerOptions, currentSourceFile.fileName)) {
|
|
50913
|
-
const
|
|
50914
|
-
|
|
50938
|
+
const importOrExport = ((_h = findAncestor(location, isImportDeclaration)) == null ? void 0 : _h.importClause) || findAncestor(location, or(isImportEqualsDeclaration, isExportDeclaration));
|
|
50939
|
+
if (!((importOrExport == null ? void 0 : importOrExport.isTypeOnly) || findAncestor(location, isImportTypeNode))) {
|
|
50940
|
+
const tsExtension = Debug.checkDefined(tryExtractTSExtension(moduleReference));
|
|
50941
|
+
error2(errorNode, Diagnostics.An_import_path_can_only_end_with_a_0_extension_when_allowImportingTsExtensions_is_enabled, tsExtension);
|
|
50942
|
+
}
|
|
50915
50943
|
}
|
|
50916
50944
|
if (sourceFile.symbol) {
|
|
50917
50945
|
if (resolvedModule.isExternalLibraryImport && !resolutionExtensionIsTSOrJson(resolvedModule.extension)) {
|
|
@@ -50928,7 +50956,7 @@ function createTypeChecker(host) {
|
|
|
50928
50956
|
if (moduleResolutionKind === 3 /* Node16 */ || moduleResolutionKind === 99 /* NodeNext */) {
|
|
50929
50957
|
const isSyncImport = currentSourceFile.impliedNodeFormat === 1 /* CommonJS */ && !findAncestor(location, isImportCall) || !!findAncestor(location, isImportEqualsDeclaration);
|
|
50930
50958
|
const overrideClauseHost = findAncestor(location, (l) => isImportTypeNode(l) || isExportDeclaration(l) || isImportDeclaration(l));
|
|
50931
|
-
const overrideClause = overrideClauseHost && isImportTypeNode(overrideClauseHost) ? (
|
|
50959
|
+
const overrideClause = overrideClauseHost && isImportTypeNode(overrideClauseHost) ? (_i = overrideClauseHost.assertions) == null ? void 0 : _i.assertClause : overrideClauseHost == null ? void 0 : overrideClauseHost.assertClause;
|
|
50932
50960
|
if (isSyncImport && sourceFile.impliedNodeFormat === 99 /* ESNext */ && !getResolutionModeOverrideForClause(overrideClause)) {
|
|
50933
50961
|
if (findAncestor(location, isImportEqualsDeclaration)) {
|
|
50934
50962
|
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 +51059,7 @@ function createTypeChecker(host) {
|
|
|
51031
51059
|
error2(errorNode, Diagnostics.Cannot_find_module_0_Consider_using_resolveJsonModule_to_import_module_with_json_extension, moduleReference);
|
|
51032
51060
|
} else if (mode === 99 /* ESNext */ && resolutionIsNode16OrNext && isExtensionlessRelativePathImport) {
|
|
51033
51061
|
const absoluteRef = getNormalizedAbsolutePath(moduleReference, getDirectoryPath(currentSourceFile.path));
|
|
51034
|
-
const suggestedExt = (
|
|
51062
|
+
const suggestedExt = (_j = suggestedExtensions.find(([actualExt, _importExt]) => host.fileExists(absoluteRef + actualExt))) == null ? void 0 : _j[1];
|
|
51035
51063
|
if (suggestedExt) {
|
|
51036
51064
|
error2(
|
|
51037
51065
|
errorNode,
|
|
@@ -52467,11 +52495,13 @@ function createTypeChecker(host) {
|
|
|
52467
52495
|
return !!type2.target && isMappedTypeHomomorphic(type2.target) && !isMappedTypeHomomorphic(type2);
|
|
52468
52496
|
}
|
|
52469
52497
|
function createMappedTypeNodeFromType(type2) {
|
|
52498
|
+
var _a2;
|
|
52470
52499
|
Debug.assert(!!(type2.flags & 524288 /* Object */));
|
|
52471
52500
|
const readonlyToken = type2.declaration.readonlyToken ? factory.createToken(type2.declaration.readonlyToken.kind) : void 0;
|
|
52472
52501
|
const questionToken = type2.declaration.questionToken ? factory.createToken(type2.declaration.questionToken.kind) : void 0;
|
|
52473
52502
|
let appropriateConstraintTypeNode;
|
|
52474
52503
|
let newTypeVariable;
|
|
52504
|
+
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
52505
|
if (isMappedTypeWithKeyofConstraintDeclaration(type2)) {
|
|
52476
52506
|
if (isHomomorphicMappedTypeWithNonHomomorphicInstantiation(type2) && context.flags & 4 /* GenerateNamesForShadowedTypeParams */) {
|
|
52477
52507
|
const newParam = createTypeParameter(createSymbol(262144 /* TypeParameter */, "T"));
|
|
@@ -52479,6 +52509,11 @@ function createTypeChecker(host) {
|
|
|
52479
52509
|
newTypeVariable = factory.createTypeReferenceNode(name);
|
|
52480
52510
|
}
|
|
52481
52511
|
appropriateConstraintTypeNode = factory.createTypeOperatorNode(143 /* KeyOfKeyword */, newTypeVariable || typeToTypeNodeHelper(getModifiersTypeFromMappedType(type2), context));
|
|
52512
|
+
} else if (needsModifierPreservingWrapper) {
|
|
52513
|
+
const newParam = createTypeParameter(createSymbol(262144 /* TypeParameter */, "T"));
|
|
52514
|
+
const name = typeParameterToName(newParam, context);
|
|
52515
|
+
newTypeVariable = factory.createTypeReferenceNode(name);
|
|
52516
|
+
appropriateConstraintTypeNode = newTypeVariable;
|
|
52482
52517
|
} else {
|
|
52483
52518
|
appropriateConstraintTypeNode = typeToTypeNodeHelper(getConstraintTypeFromMappedType(type2), context);
|
|
52484
52519
|
}
|
|
@@ -52509,6 +52544,18 @@ function createTypeChecker(host) {
|
|
|
52509
52544
|
result,
|
|
52510
52545
|
factory.createKeywordTypeNode(146 /* NeverKeyword */)
|
|
52511
52546
|
);
|
|
52547
|
+
} else if (needsModifierPreservingWrapper) {
|
|
52548
|
+
return factory.createConditionalTypeNode(
|
|
52549
|
+
typeToTypeNodeHelper(getConstraintTypeFromMappedType(type2), context),
|
|
52550
|
+
factory.createInferTypeNode(factory.createTypeParameterDeclaration(
|
|
52551
|
+
/*modifiers*/
|
|
52552
|
+
void 0,
|
|
52553
|
+
factory.cloneNode(newTypeVariable.typeName),
|
|
52554
|
+
factory.createTypeOperatorNode(143 /* KeyOfKeyword */, typeToTypeNodeHelper(getModifiersTypeFromMappedType(type2), context))
|
|
52555
|
+
)),
|
|
52556
|
+
result,
|
|
52557
|
+
factory.createKeywordTypeNode(146 /* NeverKeyword */)
|
|
52558
|
+
);
|
|
52512
52559
|
}
|
|
52513
52560
|
return result;
|
|
52514
52561
|
}
|
|
@@ -57560,9 +57607,6 @@ function createTypeChecker(host) {
|
|
|
57560
57607
|
}
|
|
57561
57608
|
return type;
|
|
57562
57609
|
}
|
|
57563
|
-
function isTypeUsableAsPropertyName(type) {
|
|
57564
|
-
return !!(type.flags & 8576 /* StringOrNumberLiteralOrUnique */);
|
|
57565
|
-
}
|
|
57566
57610
|
function isLateBindableName(node) {
|
|
57567
57611
|
if (!isComputedPropertyName(node) && !isElementAccessExpression(node)) {
|
|
57568
57612
|
return false;
|
|
@@ -57583,15 +57627,6 @@ function createTypeChecker(host) {
|
|
|
57583
57627
|
function isNonBindableDynamicName(node) {
|
|
57584
57628
|
return isDynamicName(node) && !isLateBindableName(node);
|
|
57585
57629
|
}
|
|
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
57630
|
function addDeclarationToLateBoundSymbol(symbol, member, symbolFlags) {
|
|
57596
57631
|
Debug.assert(!!(getCheckFlags(symbol) & 4096 /* Late */), "Expected a late-bound symbol.");
|
|
57597
57632
|
symbol.flags |= symbolFlags;
|
|
@@ -58238,20 +58273,17 @@ function createTypeChecker(host) {
|
|
|
58238
58273
|
setStructuredTypeMembers(type, members2, callSignatures, constructSignatures, indexInfos2);
|
|
58239
58274
|
return;
|
|
58240
58275
|
}
|
|
58241
|
-
let members =
|
|
58276
|
+
let members = getExportsOfSymbol(symbol);
|
|
58242
58277
|
let indexInfos;
|
|
58243
|
-
if (symbol
|
|
58244
|
-
|
|
58245
|
-
|
|
58246
|
-
|
|
58247
|
-
|
|
58248
|
-
|
|
58249
|
-
|
|
58250
|
-
|
|
58251
|
-
|
|
58252
|
-
});
|
|
58253
|
-
members = varsOnly;
|
|
58254
|
-
}
|
|
58278
|
+
if (symbol === globalThisSymbol) {
|
|
58279
|
+
const varsOnly = /* @__PURE__ */ new Map();
|
|
58280
|
+
members.forEach((p) => {
|
|
58281
|
+
var _a;
|
|
58282
|
+
if (!(p.flags & 418 /* BlockScoped */) && !(p.flags & 512 /* ValueModule */ && ((_a = p.declarations) == null ? void 0 : _a.length) && every(p.declarations, isAmbientModule))) {
|
|
58283
|
+
varsOnly.set(p.escapedName, p);
|
|
58284
|
+
}
|
|
58285
|
+
});
|
|
58286
|
+
members = varsOnly;
|
|
58255
58287
|
}
|
|
58256
58288
|
let baseConstructorIndexInfo;
|
|
58257
58289
|
setStructuredTypeMembers(type, members, emptyArray, emptyArray, emptyArray);
|
|
@@ -58591,7 +58623,12 @@ function createTypeChecker(host) {
|
|
|
58591
58623
|
for (const current of type.types) {
|
|
58592
58624
|
for (const prop of getPropertiesOfType(current)) {
|
|
58593
58625
|
if (!members.has(prop.escapedName)) {
|
|
58594
|
-
const combinedProp = getPropertyOfUnionOrIntersectionType(
|
|
58626
|
+
const combinedProp = getPropertyOfUnionOrIntersectionType(
|
|
58627
|
+
type,
|
|
58628
|
+
prop.escapedName,
|
|
58629
|
+
/*skipObjectFunctionPropertyAugment*/
|
|
58630
|
+
!!(type.flags & 2097152 /* Intersection */)
|
|
58631
|
+
);
|
|
58595
58632
|
if (combinedProp) {
|
|
58596
58633
|
members.set(prop.escapedName, combinedProp);
|
|
58597
58634
|
}
|
|
@@ -59071,13 +59108,17 @@ function createTypeChecker(host) {
|
|
|
59071
59108
|
return result;
|
|
59072
59109
|
}
|
|
59073
59110
|
function getUnionOrIntersectionProperty(type, name, skipObjectFunctionPropertyAugment) {
|
|
59074
|
-
var _a, _b;
|
|
59111
|
+
var _a, _b, _c;
|
|
59075
59112
|
let property = ((_a = type.propertyCacheWithoutObjectFunctionPropertyAugment) == null ? void 0 : _a.get(name)) || !skipObjectFunctionPropertyAugment ? (_b = type.propertyCache) == null ? void 0 : _b.get(name) : void 0;
|
|
59076
59113
|
if (!property) {
|
|
59077
59114
|
property = createUnionOrIntersectionProperty(type, name, skipObjectFunctionPropertyAugment);
|
|
59078
59115
|
if (property) {
|
|
59079
59116
|
const properties = skipObjectFunctionPropertyAugment ? type.propertyCacheWithoutObjectFunctionPropertyAugment || (type.propertyCacheWithoutObjectFunctionPropertyAugment = createSymbolTable()) : type.propertyCache || (type.propertyCache = createSymbolTable());
|
|
59080
59117
|
properties.set(name, property);
|
|
59118
|
+
if (skipObjectFunctionPropertyAugment && !((_c = type.propertyCache) == null ? void 0 : _c.get(name))) {
|
|
59119
|
+
const properties2 = type.propertyCache || (type.propertyCache = createSymbolTable());
|
|
59120
|
+
properties2.set(name, property);
|
|
59121
|
+
}
|
|
59081
59122
|
}
|
|
59082
59123
|
}
|
|
59083
59124
|
return property;
|
|
@@ -59197,7 +59238,22 @@ function createTypeChecker(host) {
|
|
|
59197
59238
|
}
|
|
59198
59239
|
return getPropertyOfObjectType(globalObjectType, name);
|
|
59199
59240
|
}
|
|
59200
|
-
if (type.flags &
|
|
59241
|
+
if (type.flags & 2097152 /* Intersection */) {
|
|
59242
|
+
const prop = getPropertyOfUnionOrIntersectionType(
|
|
59243
|
+
type,
|
|
59244
|
+
name,
|
|
59245
|
+
/*skipObjectFunctionPropertyAugment*/
|
|
59246
|
+
true
|
|
59247
|
+
);
|
|
59248
|
+
if (prop) {
|
|
59249
|
+
return prop;
|
|
59250
|
+
}
|
|
59251
|
+
if (!skipObjectFunctionPropertyAugment) {
|
|
59252
|
+
return getPropertyOfUnionOrIntersectionType(type, name, skipObjectFunctionPropertyAugment);
|
|
59253
|
+
}
|
|
59254
|
+
return void 0;
|
|
59255
|
+
}
|
|
59256
|
+
if (type.flags & 1048576 /* Union */) {
|
|
59201
59257
|
return getPropertyOfUnionOrIntersectionType(type, name, skipObjectFunctionPropertyAugment);
|
|
59202
59258
|
}
|
|
59203
59259
|
return void 0;
|
|
@@ -65836,26 +65892,6 @@ function createTypeChecker(host) {
|
|
|
65836
65892
|
)) {
|
|
65837
65893
|
return result2;
|
|
65838
65894
|
}
|
|
65839
|
-
if (sourceFlags & 8388608 /* IndexedAccess */) {
|
|
65840
|
-
const indexType = source2.indexType;
|
|
65841
|
-
if (indexType.flags & 4194304 /* Index */) {
|
|
65842
|
-
const unresolvedIndexConstraint = getBaseConstraintOfType(indexType.type);
|
|
65843
|
-
const indexConstraint = unresolvedIndexConstraint && unresolvedIndexConstraint !== noConstraintType ? getIndexType(unresolvedIndexConstraint) : keyofConstraintType;
|
|
65844
|
-
const constraint2 = getIndexedAccessType(source2.objectType, indexConstraint);
|
|
65845
|
-
if (result2 = isRelatedTo(
|
|
65846
|
-
constraint2,
|
|
65847
|
-
target2,
|
|
65848
|
-
1 /* Source */,
|
|
65849
|
-
/*reportErrors*/
|
|
65850
|
-
false,
|
|
65851
|
-
/*headMessage*/
|
|
65852
|
-
void 0,
|
|
65853
|
-
intersectionState
|
|
65854
|
-
)) {
|
|
65855
|
-
return result2;
|
|
65856
|
-
}
|
|
65857
|
-
}
|
|
65858
|
-
}
|
|
65859
65895
|
if (isMappedTypeGenericIndexedAccess(source2)) {
|
|
65860
65896
|
const indexConstraint = getConstraintOfType(source2.indexType);
|
|
65861
65897
|
if (indexConstraint) {
|
|
@@ -74069,7 +74105,7 @@ function createTypeChecker(host) {
|
|
|
74069
74105
|
}
|
|
74070
74106
|
let diagnosticMessage;
|
|
74071
74107
|
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))) {
|
|
74108
|
+
if (isInPropertyInitializerOrClassStaticBlock(node) && !isOptionalPropertyDeclaration(valueDeclaration) && !(isAccessExpression(node) && isAccessExpression(node.expression)) && !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right) && !(isMethodDeclaration(valueDeclaration) && getCombinedModifierFlagsCached(valueDeclaration) & 32 /* Static */) && (compilerOptions.useDefineForClassFields || !isPropertyDeclaredInAncestorClass(prop))) {
|
|
74073
74109
|
diagnosticMessage = error2(right, Diagnostics.Property_0_is_used_before_its_initialization, declarationName);
|
|
74074
74110
|
} else if (valueDeclaration.kind === 263 /* ClassDeclaration */ && node.parent.kind !== 183 /* TypeReference */ && !(valueDeclaration.flags & 33554432 /* Ambient */) && !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right)) {
|
|
74075
74111
|
diagnosticMessage = error2(right, Diagnostics.Class_0_used_before_its_declaration, declarationName);
|
|
@@ -76763,7 +76799,7 @@ function createTypeChecker(host) {
|
|
|
76763
76799
|
}
|
|
76764
76800
|
return restParameter.escapedName;
|
|
76765
76801
|
}
|
|
76766
|
-
function
|
|
76802
|
+
function getParameterIdentifierInfoAtPosition(signature, pos) {
|
|
76767
76803
|
var _a;
|
|
76768
76804
|
if (((_a = signature.declaration) == null ? void 0 : _a.kind) === 324 /* JSDocFunctionType */) {
|
|
76769
76805
|
return void 0;
|
|
@@ -76771,10 +76807,16 @@ function createTypeChecker(host) {
|
|
|
76771
76807
|
const paramCount = signature.parameters.length - (signatureHasRestParameter(signature) ? 1 : 0);
|
|
76772
76808
|
if (pos < paramCount) {
|
|
76773
76809
|
const param = signature.parameters[pos];
|
|
76774
|
-
|
|
76810
|
+
const paramIdent = getParameterDeclarationIdentifier(param);
|
|
76811
|
+
return paramIdent ? {
|
|
76812
|
+
parameter: paramIdent,
|
|
76813
|
+
parameterName: param.escapedName,
|
|
76814
|
+
isRestParameter: false
|
|
76815
|
+
} : void 0;
|
|
76775
76816
|
}
|
|
76776
76817
|
const restParameter = signature.parameters[paramCount] || unknownSymbol;
|
|
76777
|
-
|
|
76818
|
+
const restIdent = getParameterDeclarationIdentifier(restParameter);
|
|
76819
|
+
if (!restIdent) {
|
|
76778
76820
|
return void 0;
|
|
76779
76821
|
}
|
|
76780
76822
|
const restType = getTypeOfSymbol(restParameter);
|
|
@@ -76783,18 +76825,19 @@ function createTypeChecker(host) {
|
|
|
76783
76825
|
const index = pos - paramCount;
|
|
76784
76826
|
const associatedName = associatedNames == null ? void 0 : associatedNames[index];
|
|
76785
76827
|
const isRestTupleElement = !!(associatedName == null ? void 0 : associatedName.dotDotDotToken);
|
|
76786
|
-
|
|
76787
|
-
|
|
76788
|
-
isRestTupleElement
|
|
76789
|
-
|
|
76828
|
+
if (associatedName) {
|
|
76829
|
+
Debug.assert(isIdentifier(associatedName.name));
|
|
76830
|
+
return { parameter: associatedName.name, parameterName: associatedName.name.escapedText, isRestParameter: isRestTupleElement };
|
|
76831
|
+
}
|
|
76832
|
+
return void 0;
|
|
76790
76833
|
}
|
|
76791
76834
|
if (pos === paramCount) {
|
|
76792
|
-
return
|
|
76835
|
+
return { parameter: restIdent, parameterName: restParameter.escapedName, isRestParameter: true };
|
|
76793
76836
|
}
|
|
76794
76837
|
return void 0;
|
|
76795
76838
|
}
|
|
76796
|
-
function
|
|
76797
|
-
return symbol.valueDeclaration && isParameter(symbol.valueDeclaration) && isIdentifier(symbol.valueDeclaration.name);
|
|
76839
|
+
function getParameterDeclarationIdentifier(symbol) {
|
|
76840
|
+
return symbol.valueDeclaration && isParameter(symbol.valueDeclaration) && isIdentifier(symbol.valueDeclaration.name) && symbol.valueDeclaration.name;
|
|
76798
76841
|
}
|
|
76799
76842
|
function isValidDeclarationForTupleLabel(d) {
|
|
76800
76843
|
return d.kind === 202 /* NamedTupleMember */ || isParameter(d) && d.name && isIdentifier(d.name);
|
|
@@ -79657,7 +79700,18 @@ function createTypeChecker(host) {
|
|
|
79657
79700
|
addLazyDiagnostic(checkSignatureDeclarationDiagnostics);
|
|
79658
79701
|
function checkSignatureDeclarationDiagnostics() {
|
|
79659
79702
|
checkCollisionWithArgumentsInGeneratedCode(node);
|
|
79660
|
-
|
|
79703
|
+
let returnTypeNode = getEffectiveReturnTypeNode(node);
|
|
79704
|
+
let returnTypeErrorLocation = returnTypeNode;
|
|
79705
|
+
if (isInJSFile(node)) {
|
|
79706
|
+
const typeTag = getJSDocTypeTag(node);
|
|
79707
|
+
if (typeTag && typeTag.typeExpression && isTypeReferenceNode(typeTag.typeExpression.type)) {
|
|
79708
|
+
const signature = getSingleCallSignature(getTypeFromTypeNode(typeTag.typeExpression));
|
|
79709
|
+
if (signature && signature.declaration) {
|
|
79710
|
+
returnTypeNode = getEffectiveReturnTypeNode(signature.declaration);
|
|
79711
|
+
returnTypeErrorLocation = typeTag.typeExpression.type;
|
|
79712
|
+
}
|
|
79713
|
+
}
|
|
79714
|
+
}
|
|
79661
79715
|
if (noImplicitAny && !returnTypeNode) {
|
|
79662
79716
|
switch (node.kind) {
|
|
79663
79717
|
case 180 /* ConstructSignature */:
|
|
@@ -79668,21 +79722,21 @@ function createTypeChecker(host) {
|
|
|
79668
79722
|
break;
|
|
79669
79723
|
}
|
|
79670
79724
|
}
|
|
79671
|
-
if (returnTypeNode) {
|
|
79725
|
+
if (returnTypeNode && returnTypeErrorLocation) {
|
|
79672
79726
|
const functionFlags2 = getFunctionFlags(node);
|
|
79673
79727
|
if ((functionFlags2 & (4 /* Invalid */ | 1 /* Generator */)) === 1 /* Generator */) {
|
|
79674
79728
|
const returnType = getTypeFromTypeNode(returnTypeNode);
|
|
79675
79729
|
if (returnType === voidType) {
|
|
79676
|
-
error2(
|
|
79730
|
+
error2(returnTypeErrorLocation, Diagnostics.A_generator_cannot_have_a_void_type_annotation);
|
|
79677
79731
|
} else {
|
|
79678
79732
|
const generatorYieldType = getIterationTypeOfGeneratorFunctionReturnType(0 /* Yield */, returnType, (functionFlags2 & 2 /* Async */) !== 0) || anyType;
|
|
79679
79733
|
const generatorReturnType = getIterationTypeOfGeneratorFunctionReturnType(1 /* Return */, returnType, (functionFlags2 & 2 /* Async */) !== 0) || generatorYieldType;
|
|
79680
79734
|
const generatorNextType = getIterationTypeOfGeneratorFunctionReturnType(2 /* Next */, returnType, (functionFlags2 & 2 /* Async */) !== 0) || unknownType;
|
|
79681
79735
|
const generatorInstantiation = createGeneratorReturnType(generatorYieldType, generatorReturnType, generatorNextType, !!(functionFlags2 & 2 /* Async */));
|
|
79682
|
-
checkTypeAssignableTo(generatorInstantiation, returnType,
|
|
79736
|
+
checkTypeAssignableTo(generatorInstantiation, returnType, returnTypeErrorLocation);
|
|
79683
79737
|
}
|
|
79684
79738
|
} else if ((functionFlags2 & 3 /* AsyncGenerator */) === 2 /* Async */) {
|
|
79685
|
-
checkAsyncFunctionReturnType(node, returnTypeNode);
|
|
79739
|
+
checkAsyncFunctionReturnType(node, returnTypeNode, returnTypeErrorLocation);
|
|
79686
79740
|
}
|
|
79687
79741
|
}
|
|
79688
79742
|
if (node.kind !== 181 /* IndexSignature */ && node.kind !== 324 /* JSDocFunctionType */) {
|
|
@@ -79763,7 +79817,7 @@ function createTypeChecker(host) {
|
|
|
79763
79817
|
case "length":
|
|
79764
79818
|
case "caller":
|
|
79765
79819
|
case "arguments":
|
|
79766
|
-
if (useDefineForClassFields) {
|
|
79820
|
+
if (compilerOptions.useDefineForClassFields) {
|
|
79767
79821
|
break;
|
|
79768
79822
|
}
|
|
79769
79823
|
case "prototype":
|
|
@@ -79911,7 +79965,7 @@ function createTypeChecker(host) {
|
|
|
79911
79965
|
if (classExtendsNull) {
|
|
79912
79966
|
error2(superCall, Diagnostics.A_constructor_cannot_contain_a_super_call_when_its_class_extends_null);
|
|
79913
79967
|
}
|
|
79914
|
-
const superCallShouldBeRootLevel = !useDefineForClassFields && (some(node.parent.members, isInstancePropertyWithInitializerOrPrivateIdentifierProperty) || some(node.parameters, (p) => hasSyntacticModifier(p, 16476 /* ParameterPropertyModifier */)));
|
|
79968
|
+
const superCallShouldBeRootLevel = (getEmitScriptTarget(compilerOptions) !== 99 /* ESNext */ || !useDefineForClassFields) && (some(node.parent.members, isInstancePropertyWithInitializerOrPrivateIdentifierProperty) || some(node.parameters, (p) => hasSyntacticModifier(p, 16476 /* ParameterPropertyModifier */)));
|
|
79915
79969
|
if (superCallShouldBeRootLevel) {
|
|
79916
79970
|
if (!superCallIsRootLevelInConstructor(superCall, node.body)) {
|
|
79917
79971
|
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);
|
|
@@ -80764,7 +80818,7 @@ function createTypeChecker(host) {
|
|
|
80764
80818
|
}
|
|
80765
80819
|
return typeAsAwaitable.awaitedTypeOfType = type;
|
|
80766
80820
|
}
|
|
80767
|
-
function checkAsyncFunctionReturnType(node, returnTypeNode) {
|
|
80821
|
+
function checkAsyncFunctionReturnType(node, returnTypeNode, returnTypeErrorLocation) {
|
|
80768
80822
|
const returnType = getTypeFromTypeNode(returnTypeNode);
|
|
80769
80823
|
if (languageVersion >= 2 /* ES2015 */) {
|
|
80770
80824
|
if (isErrorType(returnType)) {
|
|
@@ -80775,7 +80829,7 @@ function createTypeChecker(host) {
|
|
|
80775
80829
|
true
|
|
80776
80830
|
);
|
|
80777
80831
|
if (globalPromiseType !== emptyGenericType && !isReferenceToType2(returnType, globalPromiseType)) {
|
|
80778
|
-
|
|
80832
|
+
reportErrorForInvalidReturnType(Diagnostics.The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type_Did_you_mean_to_write_Promise_0, returnTypeNode, returnTypeErrorLocation, typeToString(getAwaitedTypeNoAlias(returnType) || voidType));
|
|
80779
80833
|
return;
|
|
80780
80834
|
}
|
|
80781
80835
|
} else {
|
|
@@ -80785,7 +80839,7 @@ function createTypeChecker(host) {
|
|
|
80785
80839
|
}
|
|
80786
80840
|
const promiseConstructorName = getEntityNameFromTypeNode(returnTypeNode);
|
|
80787
80841
|
if (promiseConstructorName === void 0) {
|
|
80788
|
-
|
|
80842
|
+
reportErrorForInvalidReturnType(Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value, returnTypeNode, returnTypeErrorLocation, typeToString(returnType));
|
|
80789
80843
|
return;
|
|
80790
80844
|
}
|
|
80791
80845
|
const promiseConstructorSymbol = resolveEntityName(
|
|
@@ -80800,9 +80854,9 @@ function createTypeChecker(host) {
|
|
|
80800
80854
|
/*reportErrors*/
|
|
80801
80855
|
false
|
|
80802
80856
|
)) {
|
|
80803
|
-
error2(
|
|
80857
|
+
error2(returnTypeErrorLocation, Diagnostics.An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option);
|
|
80804
80858
|
} else {
|
|
80805
|
-
|
|
80859
|
+
reportErrorForInvalidReturnType(Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value, returnTypeNode, returnTypeErrorLocation, entityNameToString(promiseConstructorName));
|
|
80806
80860
|
}
|
|
80807
80861
|
return;
|
|
80808
80862
|
}
|
|
@@ -80811,15 +80865,16 @@ function createTypeChecker(host) {
|
|
|
80811
80865
|
true
|
|
80812
80866
|
);
|
|
80813
80867
|
if (globalPromiseConstructorLikeType === emptyObjectType) {
|
|
80814
|
-
|
|
80868
|
+
reportErrorForInvalidReturnType(Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value, returnTypeNode, returnTypeErrorLocation, entityNameToString(promiseConstructorName));
|
|
80815
80869
|
return;
|
|
80816
80870
|
}
|
|
80817
|
-
|
|
80818
|
-
|
|
80819
|
-
|
|
80820
|
-
|
|
80821
|
-
Diagnostics.
|
|
80822
|
-
)
|
|
80871
|
+
const headMessage = Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value;
|
|
80872
|
+
const errorInfo = () => returnTypeNode === returnTypeErrorLocation ? void 0 : chainDiagnosticMessages(
|
|
80873
|
+
/*details*/
|
|
80874
|
+
void 0,
|
|
80875
|
+
Diagnostics.The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type
|
|
80876
|
+
);
|
|
80877
|
+
if (!checkTypeAssignableTo(promiseConstructorType, globalPromiseConstructorLikeType, returnTypeErrorLocation, headMessage, errorInfo)) {
|
|
80823
80878
|
return;
|
|
80824
80879
|
}
|
|
80825
80880
|
const rootName = promiseConstructorName && getFirstIdentifier(promiseConstructorName);
|
|
@@ -80841,6 +80896,14 @@ function createTypeChecker(host) {
|
|
|
80841
80896
|
node,
|
|
80842
80897
|
Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member
|
|
80843
80898
|
);
|
|
80899
|
+
function reportErrorForInvalidReturnType(message, returnTypeNode2, returnTypeErrorLocation2, typeName) {
|
|
80900
|
+
if (returnTypeNode2 === returnTypeErrorLocation2) {
|
|
80901
|
+
error2(returnTypeErrorLocation2, message, typeName);
|
|
80902
|
+
} else {
|
|
80903
|
+
const diag2 = error2(returnTypeErrorLocation2, Diagnostics.The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type);
|
|
80904
|
+
addRelatedInfo(diag2, createDiagnosticForNode(returnTypeNode2, message, typeName));
|
|
80905
|
+
}
|
|
80906
|
+
}
|
|
80844
80907
|
}
|
|
80845
80908
|
function checkDecorator(node) {
|
|
80846
80909
|
const signature = getResolvedSignature(node);
|
|
@@ -83181,7 +83244,7 @@ function createTypeChecker(host) {
|
|
|
83181
83244
|
node
|
|
83182
83245
|
);
|
|
83183
83246
|
const willTransformPrivateElementsOrClassStaticBlocks = languageVersion <= 9 /* ES2022 */;
|
|
83184
|
-
const willTransformInitializers = !useDefineForClassFields
|
|
83247
|
+
const willTransformInitializers = !useDefineForClassFields || languageVersion < 9 /* ES2022 */;
|
|
83185
83248
|
if (willTransformStaticElementsOfDecoratedClass || willTransformPrivateElementsOrClassStaticBlocks) {
|
|
83186
83249
|
for (const member of node.members) {
|
|
83187
83250
|
if (willTransformStaticElementsOfDecoratedClass && classElementOrClassElementParameterIsDecorated(
|
|
@@ -127040,7 +127103,6 @@ function createWatchProgram(host) {
|
|
|
127040
127103
|
if (hasChangedCompilerOptions) {
|
|
127041
127104
|
newLine = updateNewLine();
|
|
127042
127105
|
if (program && changesAffectModuleResolution(program.getCompilerOptions(), compilerOptions)) {
|
|
127043
|
-
debugger;
|
|
127044
127106
|
resolutionCache.onChangesAffectModuleResolution();
|
|
127045
127107
|
}
|
|
127046
127108
|
}
|
|
@@ -136034,8 +136096,8 @@ function computeSuggestionDiagnostics(sourceFile, program, cancellationToken) {
|
|
|
136034
136096
|
diags.push(createDiagnosticForNode(init, Diagnostics.require_call_may_be_converted_to_an_import));
|
|
136035
136097
|
}
|
|
136036
136098
|
}
|
|
136037
|
-
const
|
|
136038
|
-
|
|
136099
|
+
const jsdocTypedefNodes = ts_codefix_exports.getJSDocTypedefNodes(node);
|
|
136100
|
+
for (const jsdocTypedefNode of jsdocTypedefNodes) {
|
|
136039
136101
|
diags.push(createDiagnosticForNode(jsdocTypedefNode, Diagnostics.JSDoc_typedef_may_be_converted_to_TypeScript_type));
|
|
136040
136102
|
}
|
|
136041
136103
|
if (ts_codefix_exports.parameterShouldGetTypeFromJSDoc(node)) {
|
|
@@ -146854,7 +146916,7 @@ __export(ts_codefix_exports, {
|
|
|
146854
146916
|
getFixes: () => getFixes,
|
|
146855
146917
|
getImportCompletionAction: () => getImportCompletionAction,
|
|
146856
146918
|
getImportKind: () => getImportKind,
|
|
146857
|
-
|
|
146919
|
+
getJSDocTypedefNodes: () => getJSDocTypedefNodes,
|
|
146858
146920
|
getNoopSymbolTrackerWithResolver: () => getNoopSymbolTrackerWithResolver,
|
|
146859
146921
|
getPromoteTypeOnlyCompletionAction: () => getPromoteTypeOnlyCompletionAction,
|
|
146860
146922
|
getSupportedErrorCodes: () => getSupportedErrorCodes,
|
|
@@ -149576,13 +149638,14 @@ registerCodeFix({
|
|
|
149576
149638
|
fixIds: [fixId14],
|
|
149577
149639
|
errorCodes: errorCodes15,
|
|
149578
149640
|
getCodeActions(context) {
|
|
149641
|
+
const newLineCharacter = getNewLineOrDefaultFromHost(context.host, context.formatContext.options);
|
|
149579
149642
|
const node = getTokenAtPosition(
|
|
149580
149643
|
context.sourceFile,
|
|
149581
149644
|
context.span.start
|
|
149582
149645
|
);
|
|
149583
149646
|
if (!node)
|
|
149584
149647
|
return;
|
|
149585
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange12(t, node, context.sourceFile));
|
|
149648
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange12(t, node, context.sourceFile, newLineCharacter));
|
|
149586
149649
|
if (changes.length > 0) {
|
|
149587
149650
|
return [
|
|
149588
149651
|
createCodeFixAction(
|
|
@@ -149595,29 +149658,72 @@ registerCodeFix({
|
|
|
149595
149658
|
];
|
|
149596
149659
|
}
|
|
149597
149660
|
},
|
|
149598
|
-
getAllCodeActions: (context) => codeFixAll(
|
|
149599
|
-
|
|
149600
|
-
|
|
149601
|
-
|
|
149602
|
-
|
|
149661
|
+
getAllCodeActions: (context) => codeFixAll(
|
|
149662
|
+
context,
|
|
149663
|
+
errorCodes15,
|
|
149664
|
+
(changes, diag2) => {
|
|
149665
|
+
const newLineCharacter = getNewLineOrDefaultFromHost(context.host, context.formatContext.options);
|
|
149666
|
+
const node = getTokenAtPosition(diag2.file, diag2.start);
|
|
149667
|
+
const fixAll = true;
|
|
149668
|
+
if (node)
|
|
149669
|
+
doChange12(changes, node, diag2.file, newLineCharacter, fixAll);
|
|
149670
|
+
}
|
|
149671
|
+
)
|
|
149603
149672
|
});
|
|
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)
|
|
149673
|
+
function doChange12(changes, node, sourceFile, newLine, fixAll = false) {
|
|
149674
|
+
if (!isJSDocTypedefTag(node))
|
|
149611
149675
|
return;
|
|
149612
|
-
const declaration = createDeclaration(
|
|
149676
|
+
const declaration = createDeclaration(node);
|
|
149613
149677
|
if (!declaration)
|
|
149614
149678
|
return;
|
|
149615
|
-
const
|
|
149616
|
-
|
|
149617
|
-
|
|
149618
|
-
|
|
149619
|
-
|
|
149679
|
+
const commentNode = node.parent;
|
|
149680
|
+
const { leftSibling, rightSibling } = getLeftAndRightSiblings(node);
|
|
149681
|
+
let pos = commentNode.getStart();
|
|
149682
|
+
let prefix = "";
|
|
149683
|
+
if (!leftSibling && commentNode.comment) {
|
|
149684
|
+
pos = findEndOfTextBetween(commentNode, commentNode.getStart(), node.getStart());
|
|
149685
|
+
prefix = `${newLine} */${newLine}`;
|
|
149686
|
+
}
|
|
149687
|
+
if (leftSibling) {
|
|
149688
|
+
if (fixAll && isJSDocTypedefTag(leftSibling)) {
|
|
149689
|
+
pos = node.getStart();
|
|
149690
|
+
prefix = "";
|
|
149691
|
+
} else {
|
|
149692
|
+
pos = findEndOfTextBetween(commentNode, leftSibling.getStart(), node.getStart());
|
|
149693
|
+
prefix = `${newLine} */${newLine}`;
|
|
149694
|
+
}
|
|
149695
|
+
}
|
|
149696
|
+
let end = commentNode.getEnd();
|
|
149697
|
+
let suffix = "";
|
|
149698
|
+
if (rightSibling) {
|
|
149699
|
+
if (fixAll && isJSDocTypedefTag(rightSibling)) {
|
|
149700
|
+
end = rightSibling.getStart();
|
|
149701
|
+
suffix = `${newLine}${newLine}`;
|
|
149702
|
+
} else {
|
|
149703
|
+
end = rightSibling.getStart();
|
|
149704
|
+
suffix = `${newLine}/**${newLine} * `;
|
|
149705
|
+
}
|
|
149706
|
+
}
|
|
149707
|
+
changes.replaceRange(sourceFile, { pos, end }, declaration, { prefix, suffix });
|
|
149708
|
+
}
|
|
149709
|
+
function getLeftAndRightSiblings(typedefNode) {
|
|
149710
|
+
const commentNode = typedefNode.parent;
|
|
149711
|
+
const maxChildIndex = commentNode.getChildCount() - 1;
|
|
149712
|
+
const currentNodeIndex = commentNode.getChildren().findIndex(
|
|
149713
|
+
(n) => n.getStart() === typedefNode.getStart() && n.getEnd() === typedefNode.getEnd()
|
|
149620
149714
|
);
|
|
149715
|
+
const leftSibling = currentNodeIndex > 0 ? commentNode.getChildAt(currentNodeIndex - 1) : void 0;
|
|
149716
|
+
const rightSibling = currentNodeIndex < maxChildIndex ? commentNode.getChildAt(currentNodeIndex + 1) : void 0;
|
|
149717
|
+
return { leftSibling, rightSibling };
|
|
149718
|
+
}
|
|
149719
|
+
function findEndOfTextBetween(jsDocComment, from, to) {
|
|
149720
|
+
const comment = jsDocComment.getText().substring(from - jsDocComment.getStart(), to - jsDocComment.getStart());
|
|
149721
|
+
for (let i = comment.length; i > 0; i--) {
|
|
149722
|
+
if (!/[*\/\s]/g.test(comment.substring(i - 1, i))) {
|
|
149723
|
+
return from + i;
|
|
149724
|
+
}
|
|
149725
|
+
}
|
|
149726
|
+
return to;
|
|
149621
149727
|
}
|
|
149622
149728
|
function createDeclaration(tag) {
|
|
149623
149729
|
var _a;
|
|
@@ -149638,7 +149744,7 @@ function createInterfaceForTypeLiteral(typeName, typeLiteral) {
|
|
|
149638
149744
|
const propertySignatures = createSignatureFromTypeLiteral(typeLiteral);
|
|
149639
149745
|
if (!some(propertySignatures))
|
|
149640
149746
|
return;
|
|
149641
|
-
|
|
149747
|
+
return factory.createInterfaceDeclaration(
|
|
149642
149748
|
/*modifiers*/
|
|
149643
149749
|
void 0,
|
|
149644
149750
|
typeName,
|
|
@@ -149648,13 +149754,12 @@ function createInterfaceForTypeLiteral(typeName, typeLiteral) {
|
|
|
149648
149754
|
void 0,
|
|
149649
149755
|
propertySignatures
|
|
149650
149756
|
);
|
|
149651
|
-
return interfaceDeclaration;
|
|
149652
149757
|
}
|
|
149653
149758
|
function createTypeAliasForTypeExpression(typeName, typeExpression) {
|
|
149654
149759
|
const typeReference = getSynthesizedDeepClone(typeExpression.type);
|
|
149655
149760
|
if (!typeReference)
|
|
149656
149761
|
return;
|
|
149657
|
-
|
|
149762
|
+
return factory.createTypeAliasDeclaration(
|
|
149658
149763
|
/*modifiers*/
|
|
149659
149764
|
void 0,
|
|
149660
149765
|
factory.createIdentifier(typeName),
|
|
@@ -149662,7 +149767,6 @@ function createTypeAliasForTypeExpression(typeName, typeExpression) {
|
|
|
149662
149767
|
void 0,
|
|
149663
149768
|
typeReference
|
|
149664
149769
|
);
|
|
149665
|
-
return declaration;
|
|
149666
149770
|
}
|
|
149667
149771
|
function createSignatureFromTypeLiteral(typeLiteral) {
|
|
149668
149772
|
const propertyTags = typeLiteral.jsDocPropertyTags;
|
|
@@ -149682,30 +149786,28 @@ function createSignatureFromTypeLiteral(typeLiteral) {
|
|
|
149682
149786
|
}
|
|
149683
149787
|
if (typeReference && name) {
|
|
149684
149788
|
const questionToken = isOptional ? factory.createToken(58 /* QuestionToken */) : void 0;
|
|
149685
|
-
|
|
149789
|
+
return factory.createPropertySignature(
|
|
149686
149790
|
/*modifiers*/
|
|
149687
149791
|
void 0,
|
|
149688
149792
|
name,
|
|
149689
149793
|
questionToken,
|
|
149690
149794
|
typeReference
|
|
149691
149795
|
);
|
|
149692
|
-
return prop;
|
|
149693
149796
|
}
|
|
149694
149797
|
};
|
|
149695
|
-
|
|
149696
|
-
return props;
|
|
149798
|
+
return mapDefined(propertyTags, getSignature);
|
|
149697
149799
|
}
|
|
149698
149800
|
function getPropertyName(tag) {
|
|
149699
149801
|
return tag.name.kind === 80 /* Identifier */ ? tag.name.text : tag.name.right.text;
|
|
149700
149802
|
}
|
|
149701
|
-
function
|
|
149803
|
+
function getJSDocTypedefNodes(node) {
|
|
149702
149804
|
if (hasJSDocNodes(node)) {
|
|
149703
|
-
return
|
|
149805
|
+
return flatMap(node.jsDoc, (doc) => {
|
|
149704
149806
|
var _a;
|
|
149705
|
-
return (_a =
|
|
149807
|
+
return (_a = doc.tags) == null ? void 0 : _a.filter((tag) => isJSDocTypedefTag(tag));
|
|
149706
149808
|
});
|
|
149707
149809
|
}
|
|
149708
|
-
return
|
|
149810
|
+
return [];
|
|
149709
149811
|
}
|
|
149710
149812
|
|
|
149711
149813
|
// src/services/codefixes/convertLiteralTypeToMappedType.ts
|
|
@@ -150838,6 +150940,14 @@ function promoteFromTypeOnly(changes, aliasDeclaration, compilerOptions, sourceF
|
|
|
150838
150940
|
}
|
|
150839
150941
|
function promoteImportClause(importClause) {
|
|
150840
150942
|
changes.delete(sourceFile, getTypeKeywordOfTypeOnlyImport(importClause, sourceFile));
|
|
150943
|
+
if (!compilerOptions.allowImportingTsExtensions) {
|
|
150944
|
+
const moduleSpecifier = tryGetModuleSpecifierFromDeclaration(importClause.parent);
|
|
150945
|
+
const resolvedModule = moduleSpecifier && getResolvedModule(sourceFile, moduleSpecifier.text, getModeForUsageLocation(sourceFile, moduleSpecifier));
|
|
150946
|
+
if (resolvedModule == null ? void 0 : resolvedModule.resolvedUsingTsExtension) {
|
|
150947
|
+
const changedExtension = changeAnyExtension(moduleSpecifier.text, getOutputExtension(moduleSpecifier.text, compilerOptions));
|
|
150948
|
+
changes.replaceNode(sourceFile, moduleSpecifier, factory.createStringLiteral(changedExtension));
|
|
150949
|
+
}
|
|
150950
|
+
}
|
|
150841
150951
|
if (convertExistingToTypeOnly) {
|
|
150842
150952
|
const namedImports = tryCast(importClause.namedBindings, isNamedImports);
|
|
150843
150953
|
if (namedImports && namedImports.elements.length > 1) {
|
|
@@ -151955,6 +152065,8 @@ function getInfo9(checker, sourceFile, position, errorCode) {
|
|
|
151955
152065
|
if (!declaration || !isCallExpression(declaration.parent) || !declaration.body)
|
|
151956
152066
|
return void 0;
|
|
151957
152067
|
const pos = declaration.parent.arguments.indexOf(declaration);
|
|
152068
|
+
if (pos === -1)
|
|
152069
|
+
return void 0;
|
|
151958
152070
|
const type = checker.getContextualTypeForArgumentAtIndex(declaration.parent, pos);
|
|
151959
152071
|
if (!type)
|
|
151960
152072
|
return void 0;
|
|
@@ -155122,15 +155234,11 @@ var PreserveOptionalFlags = /* @__PURE__ */ ((PreserveOptionalFlags2) => {
|
|
|
155122
155234
|
})(PreserveOptionalFlags || {});
|
|
155123
155235
|
function addNewNodeForMemberSymbol(symbol, enclosingDeclaration, sourceFile, context, preferences, importAdder, addClassElement, body, preserveOptional = 3 /* All */, isAmbient = false) {
|
|
155124
155236
|
const declarations = symbol.getDeclarations();
|
|
155125
|
-
const declaration = declarations
|
|
155237
|
+
const declaration = firstOrUndefined(declarations);
|
|
155126
155238
|
const checker = context.program.getTypeChecker();
|
|
155127
155239
|
const scriptTarget = getEmitScriptTarget(context.program.getCompilerOptions());
|
|
155128
155240
|
const kind = (declaration == null ? void 0 : declaration.kind) ?? 171 /* PropertySignature */;
|
|
155129
|
-
const declarationName =
|
|
155130
|
-
getNameOfDeclaration(declaration),
|
|
155131
|
-
/*includeTrivia*/
|
|
155132
|
-
false
|
|
155133
|
-
);
|
|
155241
|
+
const declarationName = createDeclarationName(symbol, declaration);
|
|
155134
155242
|
const effectiveModifierFlags = declaration ? getEffectiveModifierFlags(declaration) : 0 /* None */;
|
|
155135
155243
|
let modifierFlags = effectiveModifierFlags & 32 /* Static */;
|
|
155136
155244
|
modifierFlags |= effectiveModifierFlags & 4 /* Public */ ? 4 /* Public */ : effectiveModifierFlags & 16 /* Protected */ ? 16 /* Protected */ : 0 /* None */;
|
|
@@ -155281,6 +155389,19 @@ function addNewNodeForMemberSymbol(symbol, enclosingDeclaration, sourceFile, con
|
|
|
155281
155389
|
false
|
|
155282
155390
|
);
|
|
155283
155391
|
}
|
|
155392
|
+
function createDeclarationName(symbol2, declaration2) {
|
|
155393
|
+
if (getCheckFlags(symbol2) & 262144 /* Mapped */) {
|
|
155394
|
+
const nameType = symbol2.links.nameType;
|
|
155395
|
+
if (nameType && isTypeUsableAsPropertyName(nameType)) {
|
|
155396
|
+
return factory.createIdentifier(unescapeLeadingUnderscores(getPropertyNameFromType(nameType)));
|
|
155397
|
+
}
|
|
155398
|
+
}
|
|
155399
|
+
return getSynthesizedDeepClone(
|
|
155400
|
+
getNameOfDeclaration(declaration2),
|
|
155401
|
+
/*includeTrivia*/
|
|
155402
|
+
false
|
|
155403
|
+
);
|
|
155404
|
+
}
|
|
155284
155405
|
}
|
|
155285
155406
|
function createSignatureDeclarationFromSignature(kind, context, quotePreference, signature, body, name, modifiers, optional, enclosingDeclaration, importAdder) {
|
|
155286
155407
|
const program = context.program;
|
|
@@ -164498,7 +164619,7 @@ __export(ts_InlayHints_exports, {
|
|
|
164498
164619
|
});
|
|
164499
164620
|
|
|
164500
164621
|
// src/services/inlayHints.ts
|
|
164501
|
-
var
|
|
164622
|
+
var maxTypeHintLength = 30;
|
|
164502
164623
|
var leadingParameterNameCommentRegexFactory = (name) => {
|
|
164503
164624
|
return new RegExp(`^\\s?/\\*\\*?\\s?${name}\\s?\\*\\/\\s?$`);
|
|
164504
164625
|
};
|
|
@@ -164508,6 +164629,9 @@ function shouldShowParameterNameHints(preferences) {
|
|
|
164508
164629
|
function shouldShowLiteralParameterNameHintsOnly(preferences) {
|
|
164509
164630
|
return preferences.includeInlayParameterNameHints === "literals";
|
|
164510
164631
|
}
|
|
164632
|
+
function shouldUseInteractiveInlayHints(preferences) {
|
|
164633
|
+
return preferences.interactiveInlayHints === true;
|
|
164634
|
+
}
|
|
164511
164635
|
function provideInlayHints(context) {
|
|
164512
164636
|
const { file, program, span, cancellationToken, preferences } = context;
|
|
164513
164637
|
const sourceFileText = file.text;
|
|
@@ -164558,9 +164682,15 @@ function provideInlayHints(context) {
|
|
|
164558
164682
|
function isSignatureSupportingReturnAnnotation(node) {
|
|
164559
164683
|
return isArrowFunction(node) || isFunctionExpression(node) || isFunctionDeclaration(node) || isMethodDeclaration(node) || isGetAccessorDeclaration(node);
|
|
164560
164684
|
}
|
|
164561
|
-
function addParameterHints(text, position, isFirstVariadicArgument) {
|
|
164685
|
+
function addParameterHints(text, parameter, position, isFirstVariadicArgument, sourceFile) {
|
|
164686
|
+
let hintText = `${isFirstVariadicArgument ? "..." : ""}${text}`;
|
|
164687
|
+
if (shouldUseInteractiveInlayHints(preferences)) {
|
|
164688
|
+
hintText = [getNodeDisplayPart(hintText, parameter, sourceFile), { text: ":" }];
|
|
164689
|
+
} else {
|
|
164690
|
+
hintText += ":";
|
|
164691
|
+
}
|
|
164562
164692
|
result.push({
|
|
164563
|
-
text:
|
|
164693
|
+
text: hintText,
|
|
164564
164694
|
position,
|
|
164565
164695
|
kind: "Parameter" /* Parameter */,
|
|
164566
164696
|
whitespaceAfter: true
|
|
@@ -164568,7 +164698,7 @@ function provideInlayHints(context) {
|
|
|
164568
164698
|
}
|
|
164569
164699
|
function addTypeHints(text, position) {
|
|
164570
164700
|
result.push({
|
|
164571
|
-
text: `: ${
|
|
164701
|
+
text: `: ${text.length > maxTypeHintLength ? text.substr(0, maxTypeHintLength - "...".length) + "..." : text}`,
|
|
164572
164702
|
position,
|
|
164573
164703
|
kind: "Type" /* Type */,
|
|
164574
164704
|
whitespaceBefore: true
|
|
@@ -164576,7 +164706,7 @@ function provideInlayHints(context) {
|
|
|
164576
164706
|
}
|
|
164577
164707
|
function addEnumMemberValueHints(text, position) {
|
|
164578
164708
|
result.push({
|
|
164579
|
-
text: `= ${
|
|
164709
|
+
text: `= ${text}`,
|
|
164580
164710
|
position,
|
|
164581
164711
|
kind: "Enum" /* Enum */,
|
|
164582
164712
|
whitespaceBefore: true
|
|
@@ -164626,6 +164756,7 @@ function provideInlayHints(context) {
|
|
|
164626
164756
|
return;
|
|
164627
164757
|
}
|
|
164628
164758
|
let signatureParamPos = 0;
|
|
164759
|
+
const sourceFile = shouldUseInteractiveInlayHints(preferences) ? expr.getSourceFile() : void 0;
|
|
164629
164760
|
for (const originalArg of args) {
|
|
164630
164761
|
const arg = skipParentheses(originalArg);
|
|
164631
164762
|
if (shouldShowLiteralParameterNameHintsOnly(preferences) && !isHintableLiteral(arg)) {
|
|
@@ -164646,10 +164777,10 @@ function provideInlayHints(context) {
|
|
|
164646
164777
|
}
|
|
164647
164778
|
}
|
|
164648
164779
|
}
|
|
164649
|
-
const
|
|
164780
|
+
const identifierInfo = checker.getParameterIdentifierInfoAtPosition(signature, signatureParamPos);
|
|
164650
164781
|
signatureParamPos = signatureParamPos + (spreadArgs || 1);
|
|
164651
|
-
if (
|
|
164652
|
-
const
|
|
164782
|
+
if (identifierInfo) {
|
|
164783
|
+
const { parameter, parameterName, isRestParameter: isFirstVariadicArgument } = identifierInfo;
|
|
164653
164784
|
const isParameterNameNotSameAsArgument = preferences.includeInlayParameterNameHintsWhenArgumentMatchesName || !identifierOrAccessExpressionPostfixMatchesParameterName(arg, parameterName);
|
|
164654
164785
|
if (!isParameterNameNotSameAsArgument && !isFirstVariadicArgument) {
|
|
164655
164786
|
continue;
|
|
@@ -164658,7 +164789,7 @@ function provideInlayHints(context) {
|
|
|
164658
164789
|
if (leadingCommentsContainsParameterName(arg, name)) {
|
|
164659
164790
|
continue;
|
|
164660
164791
|
}
|
|
164661
|
-
addParameterHints(name, originalArg.getStart(), isFirstVariadicArgument);
|
|
164792
|
+
addParameterHints(name, parameter, originalArg.getStart(), isFirstVariadicArgument, sourceFile);
|
|
164662
164793
|
}
|
|
164663
164794
|
}
|
|
164664
164795
|
}
|
|
@@ -164764,12 +164895,6 @@ function provideInlayHints(context) {
|
|
|
164764
164895
|
}
|
|
164765
164896
|
return printTypeInSingleLine(signatureParamType);
|
|
164766
164897
|
}
|
|
164767
|
-
function truncation(text, maxLength2) {
|
|
164768
|
-
if (text.length > maxLength2) {
|
|
164769
|
-
return text.substr(0, maxLength2 - "...".length) + "...";
|
|
164770
|
-
}
|
|
164771
|
-
return text;
|
|
164772
|
-
}
|
|
164773
164898
|
function printTypeInSingleLine(type) {
|
|
164774
164899
|
const flags = 70221824 /* IgnoreErrors */ | 1048576 /* AllowUniqueESSymbolType */ | 16384 /* UseAliasDefinedOutsideCurrentScope */;
|
|
164775
164900
|
const printer = createPrinterWithRemoveComments();
|
|
@@ -164800,6 +164925,13 @@ function provideInlayHints(context) {
|
|
|
164800
164925
|
}
|
|
164801
164926
|
return true;
|
|
164802
164927
|
}
|
|
164928
|
+
function getNodeDisplayPart(text, node, sourceFile) {
|
|
164929
|
+
return {
|
|
164930
|
+
text,
|
|
164931
|
+
span: createTextSpanFromNode(node, sourceFile),
|
|
164932
|
+
file: sourceFile.fileName
|
|
164933
|
+
};
|
|
164934
|
+
}
|
|
164803
164935
|
}
|
|
164804
164936
|
|
|
164805
164937
|
// src/services/_namespaces/ts.JsDoc.ts
|
|
@@ -167219,7 +167351,7 @@ function getSymbolModifiers(typeChecker, symbol) {
|
|
|
167219
167351
|
}
|
|
167220
167352
|
return modifiers.size > 0 ? arrayFrom(modifiers.values()).join(",") : "" /* none */;
|
|
167221
167353
|
}
|
|
167222
|
-
function
|
|
167354
|
+
function getSymbolDisplayPartsDocumentationAndSymbolKindWorker(typeChecker, symbol, sourceFile, enclosingDeclaration, location, type, semanticMeaning, alias) {
|
|
167223
167355
|
var _a;
|
|
167224
167356
|
const displayParts = [];
|
|
167225
167357
|
let documentation = [];
|
|
@@ -167228,7 +167360,6 @@ function getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, so
|
|
|
167228
167360
|
let symbolKind = semanticMeaning & 1 /* Value */ ? getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker, symbol, location) : "" /* unknown */;
|
|
167229
167361
|
let hasAddedSymbolInfo = false;
|
|
167230
167362
|
const isThisExpression = location.kind === 110 /* ThisKeyword */ && isInExpressionContext(location) || isThisInTypeQuery(location);
|
|
167231
|
-
let type;
|
|
167232
167363
|
let documentationFromAlias;
|
|
167233
167364
|
let tagsFromAlias;
|
|
167234
167365
|
let hasMultipleSignatures = false;
|
|
@@ -167257,7 +167388,7 @@ function getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, so
|
|
|
167257
167388
|
}
|
|
167258
167389
|
}
|
|
167259
167390
|
let signature;
|
|
167260
|
-
type = isThisExpression ? typeChecker.getTypeAtLocation(location) : typeChecker.getTypeOfSymbolAtLocation(symbol, location);
|
|
167391
|
+
type ?? (type = isThisExpression ? typeChecker.getTypeAtLocation(location) : typeChecker.getTypeOfSymbolAtLocation(symbol, location));
|
|
167261
167392
|
if (location.parent && location.parent.kind === 211 /* PropertyAccessExpression */) {
|
|
167262
167393
|
const right = location.parent.name;
|
|
167263
167394
|
if (right === location || right && right.getFullWidth() === 0) {
|
|
@@ -167472,12 +167603,13 @@ function getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, so
|
|
|
167472
167603
|
if (declarationName && !hasAddedSymbolInfo) {
|
|
167473
167604
|
const isExternalModuleDeclaration = isModuleWithStringLiteralName(resolvedNode) && hasSyntacticModifier(resolvedNode, 2 /* Ambient */);
|
|
167474
167605
|
const shouldUseAliasName = symbol.name !== "default" && !isExternalModuleDeclaration;
|
|
167475
|
-
const resolvedInfo =
|
|
167606
|
+
const resolvedInfo = getSymbolDisplayPartsDocumentationAndSymbolKindWorker(
|
|
167476
167607
|
typeChecker,
|
|
167477
167608
|
resolvedSymbol,
|
|
167478
167609
|
getSourceFileOfNode(resolvedNode),
|
|
167479
167610
|
resolvedNode,
|
|
167480
167611
|
declarationName,
|
|
167612
|
+
type,
|
|
167481
167613
|
semanticMeaning,
|
|
167482
167614
|
shouldUseAliasName ? symbol : resolvedSymbol
|
|
167483
167615
|
);
|
|
@@ -167732,6 +167864,19 @@ function getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, so
|
|
|
167732
167864
|
addRange(displayParts, typeParameterParts);
|
|
167733
167865
|
}
|
|
167734
167866
|
}
|
|
167867
|
+
function getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, sourceFile, enclosingDeclaration, location, semanticMeaning = getMeaningFromLocation(location), alias) {
|
|
167868
|
+
return getSymbolDisplayPartsDocumentationAndSymbolKindWorker(
|
|
167869
|
+
typeChecker,
|
|
167870
|
+
symbol,
|
|
167871
|
+
sourceFile,
|
|
167872
|
+
enclosingDeclaration,
|
|
167873
|
+
location,
|
|
167874
|
+
/*type*/
|
|
167875
|
+
void 0,
|
|
167876
|
+
semanticMeaning,
|
|
167877
|
+
alias
|
|
167878
|
+
);
|
|
167879
|
+
}
|
|
167735
167880
|
function isLocalVariableOrFunction(symbol) {
|
|
167736
167881
|
if (symbol.parent) {
|
|
167737
167882
|
return false;
|
|
@@ -172741,6 +172886,7 @@ __export(ts_exports2, {
|
|
|
172741
172886
|
getPropertyAssignmentAliasLikeExpression: () => getPropertyAssignmentAliasLikeExpression,
|
|
172742
172887
|
getPropertyNameForPropertyNameNode: () => getPropertyNameForPropertyNameNode,
|
|
172743
172888
|
getPropertyNameForUniqueESSymbol: () => getPropertyNameForUniqueESSymbol,
|
|
172889
|
+
getPropertyNameFromType: () => getPropertyNameFromType,
|
|
172744
172890
|
getPropertyNameOfBindingOrAssignmentElement: () => getPropertyNameOfBindingOrAssignmentElement,
|
|
172745
172891
|
getPropertySymbolFromBindingElement: () => getPropertySymbolFromBindingElement,
|
|
172746
172892
|
getPropertySymbolsFromContextualType: () => getPropertySymbolsFromContextualType,
|
|
@@ -173573,6 +173719,7 @@ __export(ts_exports2, {
|
|
|
173573
173719
|
isTypeQueryNode: () => isTypeQueryNode,
|
|
173574
173720
|
isTypeReferenceNode: () => isTypeReferenceNode,
|
|
173575
173721
|
isTypeReferenceType: () => isTypeReferenceType,
|
|
173722
|
+
isTypeUsableAsPropertyName: () => isTypeUsableAsPropertyName,
|
|
173576
173723
|
isUMDExportSymbol: () => isUMDExportSymbol,
|
|
173577
173724
|
isUnaryExpression: () => isUnaryExpression,
|
|
173578
173725
|
isUnaryExpressionWithWrite: () => isUnaryExpressionWithWrite,
|
|
@@ -183431,10 +183578,22 @@ Project '${project.projectName}' (${ProjectKind[project.projectKind]}) ${counter
|
|
|
183431
183578
|
const { file, project } = this.getFileAndProject(args);
|
|
183432
183579
|
const scriptInfo = this.projectService.getScriptInfoForNormalizedPath(file);
|
|
183433
183580
|
const hints = project.getLanguageService().provideInlayHints(file, args, this.getPreferences(file));
|
|
183434
|
-
return hints.map((hint) =>
|
|
183435
|
-
|
|
183436
|
-
|
|
183437
|
-
|
|
183581
|
+
return hints.map((hint) => {
|
|
183582
|
+
const { text, position } = hint;
|
|
183583
|
+
const hintText = typeof text === "string" ? text : text.map(({ text: text2, span, file: file2 }) => ({
|
|
183584
|
+
text: text2,
|
|
183585
|
+
span: span && {
|
|
183586
|
+
start: scriptInfo.positionToLineOffset(span.start),
|
|
183587
|
+
end: scriptInfo.positionToLineOffset(span.start + span.length),
|
|
183588
|
+
file: file2
|
|
183589
|
+
}
|
|
183590
|
+
}));
|
|
183591
|
+
return {
|
|
183592
|
+
...hint,
|
|
183593
|
+
position: scriptInfo.positionToLineOffset(position),
|
|
183594
|
+
text: hintText
|
|
183595
|
+
};
|
|
183596
|
+
});
|
|
183438
183597
|
}
|
|
183439
183598
|
setCompilerOptionsForInferredProjects(args) {
|
|
183440
183599
|
this.projectService.setCompilerOptionsForInferredProjects(args.options, args.projectRootPath);
|
|
@@ -187255,6 +187414,7 @@ start(initializeNodeSystem(), require("os").platform());
|
|
|
187255
187414
|
getPropertyAssignmentAliasLikeExpression,
|
|
187256
187415
|
getPropertyNameForPropertyNameNode,
|
|
187257
187416
|
getPropertyNameForUniqueESSymbol,
|
|
187417
|
+
getPropertyNameFromType,
|
|
187258
187418
|
getPropertyNameOfBindingOrAssignmentElement,
|
|
187259
187419
|
getPropertySymbolFromBindingElement,
|
|
187260
187420
|
getPropertySymbolsFromContextualType,
|
|
@@ -188087,6 +188247,7 @@ start(initializeNodeSystem(), require("os").platform());
|
|
|
188087
188247
|
isTypeQueryNode,
|
|
188088
188248
|
isTypeReferenceNode,
|
|
188089
188249
|
isTypeReferenceType,
|
|
188250
|
+
isTypeUsableAsPropertyName,
|
|
188090
188251
|
isUMDExportSymbol,
|
|
188091
188252
|
isUnaryExpression,
|
|
188092
188253
|
isUnaryExpressionWithWrite,
|