typescript 4.8.0-dev.20220508 → 4.8.0-dev.20220511
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/cs/diagnosticMessages.generated.json +1 -0
- package/lib/de/diagnosticMessages.generated.json +1 -0
- package/lib/es/diagnosticMessages.generated.json +1 -0
- package/lib/it/diagnosticMessages.generated.json +13 -11
- package/lib/ja/diagnosticMessages.generated.json +1 -0
- package/lib/ko/diagnosticMessages.generated.json +1 -0
- package/lib/lib.es2020.intl.d.ts +29 -5
- package/lib/lib.es2021.intl.d.ts +7 -3
- package/lib/lib.esnext.intl.d.ts +5 -1
- package/lib/pl/diagnosticMessages.generated.json +1 -0
- package/lib/pt-br/diagnosticMessages.generated.json +1 -0
- package/lib/ru/diagnosticMessages.generated.json +1 -0
- package/lib/tr/diagnosticMessages.generated.json +12 -11
- package/lib/tsc.js +107 -28
- package/lib/tsserver.js +137 -42
- package/lib/tsserverlibrary.d.ts +2 -0
- package/lib/tsserverlibrary.js +137 -42
- package/lib/typescript.d.ts +2 -0
- package/lib/typescript.js +137 -42
- package/lib/typescriptServices.d.ts +2 -0
- package/lib/typescriptServices.js +137 -42
- package/lib/typingsInstaller.js +114 -30
- package/lib/zh-tw/diagnosticMessages.generated.json +12 -11
- package/package.json +1 -1
package/lib/tsserver.js
CHANGED
|
@@ -100,7 +100,7 @@ var ts;
|
|
|
100
100
|
// The following is baselined as a literal template type without intervention
|
|
101
101
|
/** The version of the TypeScript compiler release */
|
|
102
102
|
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
103
|
-
ts.version = ts.versionMajorMinor + ".0-dev.
|
|
103
|
+
ts.version = ts.versionMajorMinor + ".0-dev.20220511";
|
|
104
104
|
/* @internal */
|
|
105
105
|
var Comparison;
|
|
106
106
|
(function (Comparison) {
|
|
@@ -8394,6 +8394,7 @@ var ts;
|
|
|
8394
8394
|
resolution_mode_can_only_be_set_for_type_only_imports: diag(1454, ts.DiagnosticCategory.Error, "resolution_mode_can_only_be_set_for_type_only_imports_1454", "`resolution-mode` can only be set for type-only imports."),
|
|
8395
8395
|
resolution_mode_is_the_only_valid_key_for_type_import_assertions: diag(1455, ts.DiagnosticCategory.Error, "resolution_mode_is_the_only_valid_key_for_type_import_assertions_1455", "`resolution-mode` is the only valid key for type import assertions."),
|
|
8396
8396
|
Type_import_assertions_should_have_exactly_one_key_resolution_mode_with_value_import_or_require: diag(1456, ts.DiagnosticCategory.Error, "Type_import_assertions_should_have_exactly_one_key_resolution_mode_with_value_import_or_require_1456", "Type import assertions should have exactly one key - `resolution-mode` - with value `import` or `require`."),
|
|
8397
|
+
Matched_by_default_include_pattern_Asterisk_Asterisk_Slash_Asterisk: diag(1457, ts.DiagnosticCategory.Message, "Matched_by_default_include_pattern_Asterisk_Asterisk_Slash_Asterisk_1457", "Matched by default include pattern '**/*'"),
|
|
8397
8398
|
The_import_meta_meta_property_is_not_allowed_in_files_which_will_build_into_CommonJS_output: diag(1470, ts.DiagnosticCategory.Error, "The_import_meta_meta_property_is_not_allowed_in_files_which_will_build_into_CommonJS_output_1470", "The 'import.meta' meta-property is not allowed in files which will build into CommonJS output."),
|
|
8398
8399
|
Module_0_cannot_be_imported_using_this_construct_The_specifier_only_resolves_to_an_ES_module_which_cannot_be_imported_synchronously_Use_dynamic_import_instead: diag(1471, ts.DiagnosticCategory.Error, "Module_0_cannot_be_imported_using_this_construct_The_specifier_only_resolves_to_an_ES_module_which_c_1471", "Module '{0}' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead."),
|
|
8399
8400
|
catch_or_finally_expected: diag(1472, ts.DiagnosticCategory.Error, "catch_or_finally_expected_1472", "'catch' or 'finally' expected."),
|
|
@@ -14073,6 +14074,16 @@ var ts;
|
|
|
14073
14074
|
return node.kind === 324 /* JSDocLink */ || node.kind === 325 /* JSDocLinkCode */ || node.kind === 326 /* JSDocLinkPlain */;
|
|
14074
14075
|
}
|
|
14075
14076
|
ts.isJSDocLinkLike = isJSDocLinkLike;
|
|
14077
|
+
function hasRestParameter(s) {
|
|
14078
|
+
var last = ts.lastOrUndefined(s.parameters);
|
|
14079
|
+
return !!last && isRestParameter(last);
|
|
14080
|
+
}
|
|
14081
|
+
ts.hasRestParameter = hasRestParameter;
|
|
14082
|
+
function isRestParameter(node) {
|
|
14083
|
+
var type = ts.isJSDocParameterTag(node) ? (node.typeExpression && node.typeExpression.type) : node.type;
|
|
14084
|
+
return node.dotDotDotToken !== undefined || !!type && type.kind === 318 /* JSDocVariadicType */;
|
|
14085
|
+
}
|
|
14086
|
+
ts.isRestParameter = isRestParameter;
|
|
14076
14087
|
// #endregion
|
|
14077
14088
|
})(ts || (ts = {}));
|
|
14078
14089
|
/* @internal */
|
|
@@ -16843,16 +16854,6 @@ var ts;
|
|
|
16843
16854
|
return typeParameters && ts.find(typeParameters, function (p) { return p.name.escapedText === name; });
|
|
16844
16855
|
}
|
|
16845
16856
|
ts.getTypeParameterFromJsDoc = getTypeParameterFromJsDoc;
|
|
16846
|
-
function hasRestParameter(s) {
|
|
16847
|
-
var last = ts.lastOrUndefined(s.parameters);
|
|
16848
|
-
return !!last && isRestParameter(last);
|
|
16849
|
-
}
|
|
16850
|
-
ts.hasRestParameter = hasRestParameter;
|
|
16851
|
-
function isRestParameter(node) {
|
|
16852
|
-
var type = ts.isJSDocParameterTag(node) ? (node.typeExpression && node.typeExpression.type) : node.type;
|
|
16853
|
-
return node.dotDotDotToken !== undefined || !!type && type.kind === 318 /* JSDocVariadicType */;
|
|
16854
|
-
}
|
|
16855
|
-
ts.isRestParameter = isRestParameter;
|
|
16856
16857
|
function hasTypeArguments(node) {
|
|
16857
16858
|
return !!node.typeArguments;
|
|
16858
16859
|
}
|
|
@@ -34382,6 +34383,10 @@ var ts;
|
|
|
34382
34383
|
// isn't actually allowed, but we want to treat it as a lambda so we can provide
|
|
34383
34384
|
// a good error message.
|
|
34384
34385
|
if (ts.isModifierKind(second) && second !== 131 /* AsyncKeyword */ && lookAhead(nextTokenIsIdentifier)) {
|
|
34386
|
+
if (nextToken() === 127 /* AsKeyword */) {
|
|
34387
|
+
// https://github.com/microsoft/TypeScript/issues/44466
|
|
34388
|
+
return 0 /* False */;
|
|
34389
|
+
}
|
|
34385
34390
|
return 1 /* True */;
|
|
34386
34391
|
}
|
|
34387
34392
|
// If we had "(" followed by something that's not an identifier,
|
|
@@ -40971,7 +40976,7 @@ var ts;
|
|
|
40971
40976
|
return undefined;
|
|
40972
40977
|
if (ts.length(specs) !== 1)
|
|
40973
40978
|
return specs;
|
|
40974
|
-
if (specs[0] ===
|
|
40979
|
+
if (specs[0] === ts.defaultIncludeSpec)
|
|
40975
40980
|
return undefined;
|
|
40976
40981
|
return specs;
|
|
40977
40982
|
}
|
|
@@ -41249,6 +41254,8 @@ var ts;
|
|
|
41249
41254
|
// until consistent casing errors are reported
|
|
41250
41255
|
return ts.getDirectoryPath(ts.getNormalizedAbsolutePath(fileName, basePath));
|
|
41251
41256
|
}
|
|
41257
|
+
/*@internal*/
|
|
41258
|
+
ts.defaultIncludeSpec = "**/*";
|
|
41252
41259
|
/**
|
|
41253
41260
|
* Parse the contents of a config file from json or json source file (tsconfig.json).
|
|
41254
41261
|
* @param json The contents of the config file to parse
|
|
@@ -41314,6 +41321,7 @@ var ts;
|
|
|
41314
41321
|
}
|
|
41315
41322
|
var includeSpecs = toPropValue(getSpecsFromRaw("include"));
|
|
41316
41323
|
var excludeOfRaw = getSpecsFromRaw("exclude");
|
|
41324
|
+
var isDefaultIncludeSpec = false;
|
|
41317
41325
|
var excludeSpecs = toPropValue(excludeOfRaw);
|
|
41318
41326
|
if (excludeOfRaw === "no-prop" && raw.compilerOptions) {
|
|
41319
41327
|
var outDir = raw.compilerOptions.outDir;
|
|
@@ -41323,7 +41331,8 @@ var ts;
|
|
|
41323
41331
|
}
|
|
41324
41332
|
}
|
|
41325
41333
|
if (filesSpecs === undefined && includeSpecs === undefined) {
|
|
41326
|
-
includeSpecs = [
|
|
41334
|
+
includeSpecs = [ts.defaultIncludeSpec];
|
|
41335
|
+
isDefaultIncludeSpec = true;
|
|
41327
41336
|
}
|
|
41328
41337
|
var validatedIncludeSpecs, validatedExcludeSpecs;
|
|
41329
41338
|
// The exclude spec list is converted into a regular expression, which allows us to quickly
|
|
@@ -41342,7 +41351,8 @@ var ts;
|
|
|
41342
41351
|
validatedFilesSpec: ts.filter(filesSpecs, ts.isString),
|
|
41343
41352
|
validatedIncludeSpecs: validatedIncludeSpecs,
|
|
41344
41353
|
validatedExcludeSpecs: validatedExcludeSpecs,
|
|
41345
|
-
pathPatterns: undefined,
|
|
41354
|
+
pathPatterns: undefined,
|
|
41355
|
+
isDefaultIncludeSpec: isDefaultIncludeSpec,
|
|
41346
41356
|
};
|
|
41347
41357
|
}
|
|
41348
41358
|
function getFileNames(basePath) {
|
|
@@ -65465,6 +65475,20 @@ var ts;
|
|
|
65465
65475
|
}
|
|
65466
65476
|
}
|
|
65467
65477
|
}
|
|
65478
|
+
if (relation === comparableRelation && sourceFlags & 262144 /* TypeParameter */) {
|
|
65479
|
+
// This is a carve-out in comparability to essentially forbid comparing a type parameter
|
|
65480
|
+
// with another type parameter unless one extends the other. (Remember: comparability is mostly bidirectional!)
|
|
65481
|
+
var constraint = getConstraintOfTypeParameter(source);
|
|
65482
|
+
if (constraint && hasNonCircularBaseConstraint(source)) {
|
|
65483
|
+
while (constraint && constraint.flags & 262144 /* TypeParameter */) {
|
|
65484
|
+
if (result = isRelatedTo(constraint, target, 1 /* Source */, /*reportErrors*/ false)) {
|
|
65485
|
+
return result;
|
|
65486
|
+
}
|
|
65487
|
+
constraint = getConstraintOfTypeParameter(constraint);
|
|
65488
|
+
}
|
|
65489
|
+
}
|
|
65490
|
+
return 0 /* False */;
|
|
65491
|
+
}
|
|
65468
65492
|
}
|
|
65469
65493
|
else if (targetFlags & 4194304 /* Index */) {
|
|
65470
65494
|
var targetType_1 = target.type;
|
|
@@ -65668,8 +65692,8 @@ var ts;
|
|
|
65668
65692
|
if (sourceFlags & 8650752 /* TypeVariable */) {
|
|
65669
65693
|
// IndexedAccess comparisons are handled above in the `targetFlags & TypeFlage.IndexedAccess` branch
|
|
65670
65694
|
if (!(sourceFlags & 8388608 /* IndexedAccess */ && targetFlags & 8388608 /* IndexedAccess */)) {
|
|
65671
|
-
var constraint = getConstraintOfType(source);
|
|
65672
|
-
if (!
|
|
65695
|
+
var constraint = getConstraintOfType(source) || unknownType;
|
|
65696
|
+
if (!getConstraintOfType(source) || (sourceFlags & 262144 /* TypeParameter */ && constraint.flags & 1 /* Any */)) {
|
|
65673
65697
|
// A type variable with no constraint is not related to the non-primitive object type.
|
|
65674
65698
|
if (result = isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~67108864 /* NonPrimitive */), 3 /* Both */)) {
|
|
65675
65699
|
resetErrorInfo(saveErrorInfo);
|
|
@@ -65677,12 +65701,12 @@ var ts;
|
|
|
65677
65701
|
}
|
|
65678
65702
|
}
|
|
65679
65703
|
// hi-speed no-this-instantiation check (less accurate, but avoids costly `this`-instantiation when the constraint will suffice), see #28231 for report on why this is needed
|
|
65680
|
-
|
|
65704
|
+
if (result = isRelatedTo(constraint, target, 1 /* Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState)) {
|
|
65681
65705
|
resetErrorInfo(saveErrorInfo);
|
|
65682
65706
|
return result;
|
|
65683
65707
|
}
|
|
65684
65708
|
// slower, fuller, this-instantiated check (necessary when comparing raw `this` types from base classes), see `subclassWithPolymorphicThisIsAssignable.ts` test for example
|
|
65685
|
-
else if (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, 1 /* Source */, reportErrors && !(targetFlags & sourceFlags & 262144 /* TypeParameter */), /*headMessage*/ undefined, intersectionState)) {
|
|
65709
|
+
else if (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, 1 /* Source */, reportErrors && constraint !== unknownType && !(targetFlags & sourceFlags & 262144 /* TypeParameter */), /*headMessage*/ undefined, intersectionState)) {
|
|
65686
65710
|
resetErrorInfo(saveErrorInfo);
|
|
65687
65711
|
return result;
|
|
65688
65712
|
}
|
|
@@ -72519,7 +72543,25 @@ var ts;
|
|
|
72519
72543
|
}
|
|
72520
72544
|
function getTypeOfPropertyOfContextualType(type, name, nameType) {
|
|
72521
72545
|
return mapType(type, function (t) {
|
|
72522
|
-
|
|
72546
|
+
if (t.flags & 2097152 /* Intersection */) {
|
|
72547
|
+
var intersection = t;
|
|
72548
|
+
var newTypes = ts.mapDefined(intersection.types, getTypeOfConcretePropertyOfContextualType);
|
|
72549
|
+
if (newTypes.length > 0) {
|
|
72550
|
+
return getIntersectionType(newTypes);
|
|
72551
|
+
}
|
|
72552
|
+
newTypes = ts.mapDefined(intersection.types, getTypeOfApplicableIndexInfoOfContextualType);
|
|
72553
|
+
if (newTypes.length > 0) {
|
|
72554
|
+
return getIntersectionType(newTypes);
|
|
72555
|
+
}
|
|
72556
|
+
return undefined;
|
|
72557
|
+
}
|
|
72558
|
+
var concretePropertyType = getTypeOfConcretePropertyOfContextualType(t);
|
|
72559
|
+
if (concretePropertyType) {
|
|
72560
|
+
return concretePropertyType;
|
|
72561
|
+
}
|
|
72562
|
+
return getTypeOfApplicableIndexInfoOfContextualType(t);
|
|
72563
|
+
}, /*noReductions*/ true);
|
|
72564
|
+
function getTypeOfConcretePropertyOfContextualType(t) {
|
|
72523
72565
|
if (isGenericMappedType(t) && !t.declaration.nameType) {
|
|
72524
72566
|
var constraint = getConstraintTypeFromMappedType(t);
|
|
72525
72567
|
var constraintOfConstraint = getBaseConstraintOfType(constraint) || constraint;
|
|
@@ -72527,8 +72569,9 @@ var ts;
|
|
|
72527
72569
|
if (isTypeAssignableTo(propertyNameType, constraintOfConstraint)) {
|
|
72528
72570
|
return substituteIndexedMappedType(t, propertyNameType);
|
|
72529
72571
|
}
|
|
72572
|
+
return undefined;
|
|
72530
72573
|
}
|
|
72531
|
-
|
|
72574
|
+
if (t.flags & 3670016 /* StructuredType */) {
|
|
72532
72575
|
var prop = getPropertyOfType(t, name);
|
|
72533
72576
|
if (prop) {
|
|
72534
72577
|
return isCircularMappedProperty(prop) ? undefined : getTypeOfSymbol(prop);
|
|
@@ -72539,10 +72582,16 @@ var ts;
|
|
|
72539
72582
|
return restType;
|
|
72540
72583
|
}
|
|
72541
72584
|
}
|
|
72542
|
-
return (_a = findApplicableIndexInfo(getIndexInfosOfStructuredType(t), nameType || getStringLiteralType(ts.unescapeLeadingUnderscores(name)))) === null || _a === void 0 ? void 0 : _a.type;
|
|
72543
72585
|
}
|
|
72544
72586
|
return undefined;
|
|
72545
|
-
}
|
|
72587
|
+
}
|
|
72588
|
+
function getTypeOfApplicableIndexInfoOfContextualType(t) {
|
|
72589
|
+
var _a;
|
|
72590
|
+
if (!(t.flags & 3670016 /* StructuredType */)) {
|
|
72591
|
+
return undefined;
|
|
72592
|
+
}
|
|
72593
|
+
return (_a = findApplicableIndexInfo(getIndexInfosOfStructuredType(t), nameType || getStringLiteralType(ts.unescapeLeadingUnderscores(name)))) === null || _a === void 0 ? void 0 : _a.type;
|
|
72594
|
+
}
|
|
72546
72595
|
}
|
|
72547
72596
|
// In an object literal contextually typed by a type T, the contextual type of a property assignment is the type of
|
|
72548
72597
|
// the matching property in T, if one exists. Otherwise, it is the type of the numeric index signature in T, if one
|
|
@@ -81016,7 +81065,7 @@ var ts;
|
|
|
81016
81065
|
* @param type The type of the promise.
|
|
81017
81066
|
* @remarks The "promised type" of a type is the type of the "value" parameter of the "onfulfilled" callback.
|
|
81018
81067
|
*/
|
|
81019
|
-
function getPromisedTypeOfPromise(type, errorNode) {
|
|
81068
|
+
function getPromisedTypeOfPromise(type, errorNode, thisTypeForErrorOut) {
|
|
81020
81069
|
//
|
|
81021
81070
|
// { // type
|
|
81022
81071
|
// then( // thenFunction
|
|
@@ -81051,7 +81100,29 @@ var ts;
|
|
|
81051
81100
|
}
|
|
81052
81101
|
return undefined;
|
|
81053
81102
|
}
|
|
81054
|
-
var
|
|
81103
|
+
var thisTypeForError;
|
|
81104
|
+
var candidates;
|
|
81105
|
+
for (var _i = 0, thenSignatures_1 = thenSignatures; _i < thenSignatures_1.length; _i++) {
|
|
81106
|
+
var thenSignature = thenSignatures_1[_i];
|
|
81107
|
+
var thisType = getThisTypeOfSignature(thenSignature);
|
|
81108
|
+
if (thisType && thisType !== voidType && !isTypeRelatedTo(type, thisType, subtypeRelation)) {
|
|
81109
|
+
thisTypeForError = thisType;
|
|
81110
|
+
}
|
|
81111
|
+
else {
|
|
81112
|
+
candidates = ts.append(candidates, thenSignature);
|
|
81113
|
+
}
|
|
81114
|
+
}
|
|
81115
|
+
if (!candidates) {
|
|
81116
|
+
ts.Debug.assertIsDefined(thisTypeForError);
|
|
81117
|
+
if (thisTypeForErrorOut) {
|
|
81118
|
+
thisTypeForErrorOut.value = thisTypeForError;
|
|
81119
|
+
}
|
|
81120
|
+
if (errorNode) {
|
|
81121
|
+
error(errorNode, ts.Diagnostics.The_this_context_of_type_0_is_not_assignable_to_method_s_this_of_type_1, typeToString(type), typeToString(thisTypeForError));
|
|
81122
|
+
}
|
|
81123
|
+
return undefined;
|
|
81124
|
+
}
|
|
81125
|
+
var onfulfilledParameterType = getTypeWithFacts(getUnionType(ts.map(candidates, getTypeOfFirstParameterOfSignature)), 2097152 /* NEUndefinedOrNull */);
|
|
81055
81126
|
if (isTypeAny(onfulfilledParameterType)) {
|
|
81056
81127
|
return undefined;
|
|
81057
81128
|
}
|
|
@@ -81175,7 +81246,8 @@ var ts;
|
|
|
81175
81246
|
var mapper = errorNode ? function (constituentType) { return getAwaitedTypeNoAlias(constituentType, errorNode, diagnosticMessage, arg0); } : getAwaitedTypeNoAlias;
|
|
81176
81247
|
return typeAsAwaitable.awaitedTypeOfType = mapType(type, mapper);
|
|
81177
81248
|
}
|
|
81178
|
-
var
|
|
81249
|
+
var thisTypeForErrorOut = { value: undefined };
|
|
81250
|
+
var promisedType = getPromisedTypeOfPromise(type, /*errorNode*/ undefined, thisTypeForErrorOut);
|
|
81179
81251
|
if (promisedType) {
|
|
81180
81252
|
if (type.id === promisedType.id || awaitedTypeStack.lastIndexOf(promisedType.id) >= 0) {
|
|
81181
81253
|
// Verify that we don't have a bad actor in the form of a promise whose
|
|
@@ -81244,7 +81316,12 @@ var ts;
|
|
|
81244
81316
|
if (isThenableType(type)) {
|
|
81245
81317
|
if (errorNode) {
|
|
81246
81318
|
ts.Debug.assertIsDefined(diagnosticMessage);
|
|
81247
|
-
|
|
81319
|
+
var chain = void 0;
|
|
81320
|
+
if (thisTypeForErrorOut.value) {
|
|
81321
|
+
chain = ts.chainDiagnosticMessages(chain, ts.Diagnostics.The_this_context_of_type_0_is_not_assignable_to_method_s_this_of_type_1, typeToString(type), typeToString(thisTypeForErrorOut.value));
|
|
81322
|
+
}
|
|
81323
|
+
chain = ts.chainDiagnosticMessages(chain, diagnosticMessage, arg0);
|
|
81324
|
+
diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(errorNode, chain));
|
|
81248
81325
|
}
|
|
81249
81326
|
return undefined;
|
|
81250
81327
|
}
|
|
@@ -118762,7 +118839,7 @@ var ts;
|
|
|
118762
118839
|
}
|
|
118763
118840
|
var matchedByInclude = ts.getMatchedIncludeSpec(program, fileName);
|
|
118764
118841
|
// Could be additional files specified as roots
|
|
118765
|
-
if (!matchedByInclude)
|
|
118842
|
+
if (!matchedByInclude || !ts.isString(matchedByInclude))
|
|
118766
118843
|
return undefined;
|
|
118767
118844
|
configFileNode = ts.getTsConfigPropArrayElementValue(options.configFile, "include", matchedByInclude);
|
|
118768
118845
|
message = ts.Diagnostics.File_is_matched_by_include_pattern_specified_here;
|
|
@@ -122360,6 +122437,8 @@ var ts;
|
|
|
122360
122437
|
if (ts.fileExtensionIsOneOf(fileName, [".json" /* Json */, ".mjs" /* Mjs */, ".cjs" /* Cjs */]))
|
|
122361
122438
|
return fileName;
|
|
122362
122439
|
var noExtension = ts.removeFileExtension(fileName);
|
|
122440
|
+
if (fileName === noExtension)
|
|
122441
|
+
return fileName;
|
|
122363
122442
|
if (ts.fileExtensionIsOneOf(fileName, [".d.mts" /* Dmts */, ".mts" /* Mts */, ".d.cts" /* Dcts */, ".cts" /* Cts */]))
|
|
122364
122443
|
return noExtension + getJSExtensionForFile(fileName, options);
|
|
122365
122444
|
switch (ending) {
|
|
@@ -122648,6 +122727,9 @@ var ts;
|
|
|
122648
122727
|
var configFile = program.getCompilerOptions().configFile;
|
|
122649
122728
|
if (!((_a = configFile === null || configFile === void 0 ? void 0 : configFile.configFileSpecs) === null || _a === void 0 ? void 0 : _a.validatedIncludeSpecs))
|
|
122650
122729
|
return undefined;
|
|
122730
|
+
// Return true if its default include spec
|
|
122731
|
+
if (configFile.configFileSpecs.isDefaultIncludeSpec)
|
|
122732
|
+
return true;
|
|
122651
122733
|
var isJsonFile = ts.fileExtensionIs(fileName, ".json" /* Json */);
|
|
122652
122734
|
var basePath = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(configFile.fileName, program.getCurrentDirectory()));
|
|
122653
122735
|
var useCaseSensitiveFileNames = program.useCaseSensitiveFileNames();
|
|
@@ -122713,11 +122795,13 @@ var ts;
|
|
|
122713
122795
|
if (matchedByFiles)
|
|
122714
122796
|
return ts.chainDiagnosticMessages(/*details*/ undefined, ts.Diagnostics.Part_of_files_list_in_tsconfig_json);
|
|
122715
122797
|
var matchedByInclude = getMatchedIncludeSpec(program, fileName);
|
|
122716
|
-
return matchedByInclude ?
|
|
122798
|
+
return ts.isString(matchedByInclude) ?
|
|
122717
122799
|
ts.chainDiagnosticMessages(
|
|
122718
122800
|
/*details*/ undefined, ts.Diagnostics.Matched_by_include_pattern_0_in_1, matchedByInclude, toFileName(options.configFile, fileNameConvertor)) :
|
|
122719
|
-
// Could be additional files specified as roots
|
|
122720
|
-
ts.chainDiagnosticMessages(/*details*/ undefined,
|
|
122801
|
+
// Could be additional files specified as roots or matched by default include
|
|
122802
|
+
ts.chainDiagnosticMessages(/*details*/ undefined, matchedByInclude ?
|
|
122803
|
+
ts.Diagnostics.Matched_by_default_include_pattern_Asterisk_Asterisk_Slash_Asterisk :
|
|
122804
|
+
ts.Diagnostics.Root_file_specified_for_compilation);
|
|
122721
122805
|
case ts.FileIncludeKind.SourceFromProjectReference:
|
|
122722
122806
|
case ts.FileIncludeKind.OutputFromProjectReference:
|
|
122723
122807
|
var isOutput = reason.kind === ts.FileIncludeKind.OutputFromProjectReference;
|
|
@@ -126434,6 +126518,8 @@ var ts;
|
|
|
126434
126518
|
case 256 /* FunctionDeclaration */:
|
|
126435
126519
|
case 213 /* FunctionExpression */:
|
|
126436
126520
|
return getAdjustedLocationForFunction(node);
|
|
126521
|
+
case 171 /* Constructor */:
|
|
126522
|
+
return node;
|
|
126437
126523
|
}
|
|
126438
126524
|
}
|
|
126439
126525
|
if (ts.isNamedDeclaration(node)) {
|
|
@@ -139532,11 +139618,12 @@ var ts;
|
|
|
139532
139618
|
ts.forEachUnique(declarations, function (declaration) {
|
|
139533
139619
|
for (var _i = 0, _a = getCommentHavingNodes(declaration); _i < _a.length; _i++) {
|
|
139534
139620
|
var jsdoc = _a[_i];
|
|
139621
|
+
var inheritDoc = ts.isJSDoc(jsdoc) && jsdoc.tags && ts.find(jsdoc.tags, function (t) { return t.kind === 327 /* JSDocTag */ && (t.tagName.escapedText === "inheritDoc" || t.tagName.escapedText === "inheritdoc"); });
|
|
139535
139622
|
// skip comments containing @typedefs since they're not associated with particular declarations
|
|
139536
139623
|
// Exceptions:
|
|
139537
139624
|
// - @typedefs are themselves declarations with associated comments
|
|
139538
139625
|
// - @param or @return indicate that the author thinks of it as a 'local' @typedef that's part of the function documentation
|
|
139539
|
-
if (jsdoc.comment === undefined
|
|
139626
|
+
if (jsdoc.comment === undefined && !inheritDoc
|
|
139540
139627
|
|| ts.isJSDoc(jsdoc)
|
|
139541
139628
|
&& declaration.kind !== 345 /* JSDocTypedefTag */ && declaration.kind !== 338 /* JSDocCallbackTag */
|
|
139542
139629
|
&& jsdoc.tags
|
|
@@ -139544,7 +139631,10 @@ var ts;
|
|
|
139544
139631
|
&& !jsdoc.tags.some(function (t) { return t.kind === 340 /* JSDocParameterTag */ || t.kind === 341 /* JSDocReturnTag */; })) {
|
|
139545
139632
|
continue;
|
|
139546
139633
|
}
|
|
139547
|
-
var newparts = getDisplayPartsFromComment(jsdoc.comment, checker);
|
|
139634
|
+
var newparts = jsdoc.comment ? getDisplayPartsFromComment(jsdoc.comment, checker) : [];
|
|
139635
|
+
if (inheritDoc && inheritDoc.comment) {
|
|
139636
|
+
newparts = newparts.concat(getDisplayPartsFromComment(inheritDoc.comment, checker));
|
|
139637
|
+
}
|
|
139548
139638
|
if (!ts.contains(parts, newparts, isIdenticalListOfDisplayParts)) {
|
|
139549
139639
|
parts.push(newparts);
|
|
139550
139640
|
}
|
|
@@ -154300,6 +154390,7 @@ var ts;
|
|
|
154300
154390
|
var importAdder = codefix.createImportAdder(context.sourceFile, context.program, context.preferences, context.host);
|
|
154301
154391
|
var functionDeclaration = codefix.createSignatureDeclarationFromCallExpression(256 /* FunctionDeclaration */, context, importAdder, info.call, ts.idText(info.token), info.modifierFlags, info.parentDeclaration);
|
|
154302
154392
|
changes.insertNodeAtEndOfScope(info.sourceFile, info.parentDeclaration, functionDeclaration);
|
|
154393
|
+
importAdder.writeFixes(changes);
|
|
154303
154394
|
}
|
|
154304
154395
|
function addJsxAttributes(changes, context, info) {
|
|
154305
154396
|
var importAdder = codefix.createImportAdder(context.sourceFile, context.program, context.preferences, context.host);
|
|
@@ -154308,7 +154399,7 @@ var ts;
|
|
|
154308
154399
|
var jsxAttributesNode = info.parentDeclaration.attributes;
|
|
154309
154400
|
var hasSpreadAttribute = ts.some(jsxAttributesNode.properties, ts.isJsxSpreadAttribute);
|
|
154310
154401
|
var attrs = ts.map(info.attributes, function (attr) {
|
|
154311
|
-
var value = tryGetValueFromType(context, checker, importAdder, quotePreference, checker.getTypeOfSymbol(attr));
|
|
154402
|
+
var value = tryGetValueFromType(context, checker, importAdder, quotePreference, checker.getTypeOfSymbol(attr), info.parentDeclaration);
|
|
154312
154403
|
var name = ts.factory.createIdentifier(attr.name);
|
|
154313
154404
|
var jsxAttribute = ts.factory.createJsxAttribute(name, ts.factory.createJsxExpression(/*dotDotDotToken*/ undefined, value));
|
|
154314
154405
|
// formattingScanner requires the Identifier to have a context for scanning attributes with "-" (data-foo).
|
|
@@ -154318,6 +154409,7 @@ var ts;
|
|
|
154318
154409
|
var jsxAttributes = ts.factory.createJsxAttributes(hasSpreadAttribute ? __spreadArray(__spreadArray([], attrs, true), jsxAttributesNode.properties, true) : __spreadArray(__spreadArray([], jsxAttributesNode.properties, true), attrs, true));
|
|
154319
154410
|
var options = { prefix: jsxAttributesNode.pos === jsxAttributesNode.end ? " " : undefined };
|
|
154320
154411
|
changes.replaceNode(context.sourceFile, jsxAttributesNode, jsxAttributes, options);
|
|
154412
|
+
importAdder.writeFixes(changes);
|
|
154321
154413
|
}
|
|
154322
154414
|
function addObjectLiteralProperties(changes, context, info) {
|
|
154323
154415
|
var importAdder = codefix.createImportAdder(context.sourceFile, context.program, context.preferences, context.host);
|
|
@@ -154325,7 +154417,7 @@ var ts;
|
|
|
154325
154417
|
var target = ts.getEmitScriptTarget(context.program.getCompilerOptions());
|
|
154326
154418
|
var checker = context.program.getTypeChecker();
|
|
154327
154419
|
var props = ts.map(info.properties, function (prop) {
|
|
154328
|
-
var initializer = tryGetValueFromType(context, checker, importAdder, quotePreference, checker.getTypeOfSymbol(prop));
|
|
154420
|
+
var initializer = tryGetValueFromType(context, checker, importAdder, quotePreference, checker.getTypeOfSymbol(prop), info.parentDeclaration);
|
|
154329
154421
|
return ts.factory.createPropertyAssignment(ts.createPropertyNameNodeForIdentifierOrLiteral(prop.name, target, quotePreference === 0 /* Single */), initializer);
|
|
154330
154422
|
});
|
|
154331
154423
|
var options = {
|
|
@@ -154334,8 +154426,9 @@ var ts;
|
|
|
154334
154426
|
indentation: info.indentation
|
|
154335
154427
|
};
|
|
154336
154428
|
changes.replaceNode(context.sourceFile, info.parentDeclaration, ts.factory.createObjectLiteralExpression(__spreadArray(__spreadArray([], info.parentDeclaration.properties, true), props, true), /*multiLine*/ true), options);
|
|
154429
|
+
importAdder.writeFixes(changes);
|
|
154337
154430
|
}
|
|
154338
|
-
function tryGetValueFromType(context, checker, importAdder, quotePreference, type) {
|
|
154431
|
+
function tryGetValueFromType(context, checker, importAdder, quotePreference, type, enclosingDeclaration) {
|
|
154339
154432
|
if (type.flags & 3 /* AnyOrUnknown */) {
|
|
154340
154433
|
return createUndefined();
|
|
154341
154434
|
}
|
|
@@ -154372,7 +154465,7 @@ var ts;
|
|
|
154372
154465
|
return ts.factory.createNull();
|
|
154373
154466
|
}
|
|
154374
154467
|
if (type.flags & 1048576 /* Union */) {
|
|
154375
|
-
var expression = ts.firstDefined(type.types, function (t) { return tryGetValueFromType(context, checker, importAdder, quotePreference, t); });
|
|
154468
|
+
var expression = ts.firstDefined(type.types, function (t) { return tryGetValueFromType(context, checker, importAdder, quotePreference, t, enclosingDeclaration); });
|
|
154376
154469
|
return expression !== null && expression !== void 0 ? expression : createUndefined();
|
|
154377
154470
|
}
|
|
154378
154471
|
if (checker.isArrayLikeType(type)) {
|
|
@@ -154380,7 +154473,7 @@ var ts;
|
|
|
154380
154473
|
}
|
|
154381
154474
|
if (isObjectLiteralType(type)) {
|
|
154382
154475
|
var props = ts.map(checker.getPropertiesOfType(type), function (prop) {
|
|
154383
|
-
var initializer = prop.valueDeclaration ? tryGetValueFromType(context, checker, importAdder, quotePreference, checker.getTypeAtLocation(prop.valueDeclaration)) : createUndefined();
|
|
154476
|
+
var initializer = prop.valueDeclaration ? tryGetValueFromType(context, checker, importAdder, quotePreference, checker.getTypeAtLocation(prop.valueDeclaration), enclosingDeclaration) : createUndefined();
|
|
154384
154477
|
return ts.factory.createPropertyAssignment(prop.name, initializer);
|
|
154385
154478
|
});
|
|
154386
154479
|
return ts.factory.createObjectLiteralExpression(props, /*multiLine*/ true);
|
|
@@ -154392,7 +154485,7 @@ var ts;
|
|
|
154392
154485
|
var signature = checker.getSignaturesOfType(type, 0 /* Call */);
|
|
154393
154486
|
if (signature === undefined)
|
|
154394
154487
|
return createUndefined();
|
|
154395
|
-
var func = codefix.createSignatureDeclarationFromSignature(213 /* FunctionExpression */, context, quotePreference, signature[0], codefix.createStubbedBody(ts.Diagnostics.Function_not_implemented.message, quotePreference), /*name*/ undefined, /*modifiers*/ undefined, /*optional*/ undefined, /*enclosingDeclaration*/
|
|
154488
|
+
var func = codefix.createSignatureDeclarationFromSignature(213 /* FunctionExpression */, context, quotePreference, signature[0], codefix.createStubbedBody(ts.Diagnostics.Function_not_implemented.message, quotePreference), /*name*/ undefined, /*modifiers*/ undefined, /*optional*/ undefined, /*enclosingDeclaration*/ enclosingDeclaration, importAdder);
|
|
154396
154489
|
return func !== null && func !== void 0 ? func : createUndefined();
|
|
154397
154490
|
}
|
|
154398
154491
|
if (ts.getObjectFlags(type) & 1 /* Class */) {
|
|
@@ -163679,7 +163772,7 @@ var ts;
|
|
|
163679
163772
|
* @returns `true` if `node` has a JSDoc "inheritDoc" tag on it, otherwise `false`.
|
|
163680
163773
|
*/
|
|
163681
163774
|
function hasJSDocInheritDocTag(node) {
|
|
163682
|
-
return ts.getJSDocTags(node).some(function (tag) { return tag.tagName.text === "inheritDoc"; });
|
|
163775
|
+
return ts.getJSDocTags(node).some(function (tag) { return tag.tagName.text === "inheritDoc" || tag.tagName.text === "inheritdoc"; });
|
|
163683
163776
|
}
|
|
163684
163777
|
function getJsDocTagsOfDeclarations(declarations, checker) {
|
|
163685
163778
|
if (!declarations)
|
|
@@ -163738,13 +163831,15 @@ var ts;
|
|
|
163738
163831
|
}
|
|
163739
163832
|
function findBaseOfDeclaration(checker, declaration, cb) {
|
|
163740
163833
|
var _a;
|
|
163741
|
-
if (ts.hasStaticModifier(declaration))
|
|
163742
|
-
return;
|
|
163743
163834
|
var classOrInterfaceDeclaration = ((_a = declaration.parent) === null || _a === void 0 ? void 0 : _a.kind) === 171 /* Constructor */ ? declaration.parent.parent : declaration.parent;
|
|
163744
163835
|
if (!classOrInterfaceDeclaration)
|
|
163745
163836
|
return;
|
|
163837
|
+
var isStaticMember = ts.hasStaticModifier(declaration);
|
|
163746
163838
|
return ts.firstDefined(ts.getAllSuperTypeNodes(classOrInterfaceDeclaration), function (superTypeNode) {
|
|
163747
|
-
var
|
|
163839
|
+
var baseType = checker.getTypeAtLocation(superTypeNode);
|
|
163840
|
+
var symbol = isStaticMember
|
|
163841
|
+
? ts.find(checker.getExportsOfModule(baseType.symbol), function (s) { return s.escapedName === declaration.symbol.name; })
|
|
163842
|
+
: checker.getPropertyOfType(baseType, declaration.symbol.name);
|
|
163748
163843
|
return symbol ? cb(symbol) : undefined;
|
|
163749
163844
|
});
|
|
163750
163845
|
}
|
package/lib/tsserverlibrary.d.ts
CHANGED
|
@@ -4510,6 +4510,8 @@ declare namespace ts {
|
|
|
4510
4510
|
function isObjectLiteralElement(node: Node): node is ObjectLiteralElement;
|
|
4511
4511
|
function isStringLiteralLike(node: Node): node is StringLiteralLike;
|
|
4512
4512
|
function isJSDocLinkLike(node: Node): node is JSDocLink | JSDocLinkCode | JSDocLinkPlain;
|
|
4513
|
+
function hasRestParameter(s: SignatureDeclaration | JSDocSignature): boolean;
|
|
4514
|
+
function isRestParameter(node: ParameterDeclaration | JSDocParameterTag): boolean;
|
|
4513
4515
|
}
|
|
4514
4516
|
declare namespace ts {
|
|
4515
4517
|
const factory: NodeFactory;
|