@typescript-deploys/pr-build 5.5.0-pr-57717-2 → 5.5.0-pr-57749-2
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 +148 -65
- package/lib/tsserver.js +285 -147
- package/lib/typescript.js +285 -147
- package/lib/typingsInstaller.js +5 -1
- package/package.json +2 -2
package/lib/typescript.js
CHANGED
|
@@ -106,6 +106,7 @@ __export(typescript_exports, {
|
|
|
106
106
|
JsxEmit: () => JsxEmit,
|
|
107
107
|
JsxFlags: () => JsxFlags,
|
|
108
108
|
JsxReferenceKind: () => JsxReferenceKind,
|
|
109
|
+
LanguageFeatureMinimumTarget: () => LanguageFeatureMinimumTarget,
|
|
109
110
|
LanguageServiceMode: () => LanguageServiceMode,
|
|
110
111
|
LanguageVariant: () => LanguageVariant,
|
|
111
112
|
LexicalEnvironmentFlags: () => LexicalEnvironmentFlags,
|
|
@@ -2325,7 +2326,7 @@ module.exports = __toCommonJS(typescript_exports);
|
|
|
2325
2326
|
|
|
2326
2327
|
// src/compiler/corePublic.ts
|
|
2327
2328
|
var versionMajorMinor = "5.5";
|
|
2328
|
-
var version = `${versionMajorMinor}.0-insiders.
|
|
2329
|
+
var version = `${versionMajorMinor}.0-insiders.20240312`;
|
|
2329
2330
|
var Comparison = /* @__PURE__ */ ((Comparison3) => {
|
|
2330
2331
|
Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
|
|
2331
2332
|
Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
|
|
@@ -3632,7 +3633,7 @@ var createUIStringComparer = /* @__PURE__ */ (() => {
|
|
|
3632
3633
|
return value < 0 ? -1 /* LessThan */ : value > 0 ? 1 /* GreaterThan */ : 0 /* EqualTo */;
|
|
3633
3634
|
}
|
|
3634
3635
|
function createIntlCollatorStringComparer(locale) {
|
|
3635
|
-
const comparer = new Intl.Collator(locale, { usage: "sort", sensitivity: "variant" }).compare;
|
|
3636
|
+
const comparer = new Intl.Collator(locale, { usage: "sort", sensitivity: "variant", numeric: true }).compare;
|
|
3636
3637
|
return (a, b) => compareWithCallback(a, b, comparer);
|
|
3637
3638
|
}
|
|
3638
3639
|
})();
|
|
@@ -7233,6 +7234,38 @@ var InternalEmitFlags = /* @__PURE__ */ ((InternalEmitFlags3) => {
|
|
|
7233
7234
|
InternalEmitFlags3[InternalEmitFlags3["TransformPrivateStaticElements"] = 32] = "TransformPrivateStaticElements";
|
|
7234
7235
|
return InternalEmitFlags3;
|
|
7235
7236
|
})(InternalEmitFlags || {});
|
|
7237
|
+
var LanguageFeatureMinimumTarget = /* @__PURE__ */ ((LanguageFeatureMinimumTarget2) => {
|
|
7238
|
+
LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["Classes"] = 2 /* ES2015 */] = "Classes";
|
|
7239
|
+
LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["ForOf"] = 2 /* ES2015 */] = "ForOf";
|
|
7240
|
+
LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["Generators"] = 2 /* ES2015 */] = "Generators";
|
|
7241
|
+
LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["Iteration"] = 2 /* ES2015 */] = "Iteration";
|
|
7242
|
+
LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["SpreadElements"] = 2 /* ES2015 */] = "SpreadElements";
|
|
7243
|
+
LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["RestElements"] = 2 /* ES2015 */] = "RestElements";
|
|
7244
|
+
LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["TaggedTemplates"] = 2 /* ES2015 */] = "TaggedTemplates";
|
|
7245
|
+
LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["DestructuringAssignment"] = 2 /* ES2015 */] = "DestructuringAssignment";
|
|
7246
|
+
LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["BindingPatterns"] = 2 /* ES2015 */] = "BindingPatterns";
|
|
7247
|
+
LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["ArrowFunctions"] = 2 /* ES2015 */] = "ArrowFunctions";
|
|
7248
|
+
LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["BlockScopedVariables"] = 2 /* ES2015 */] = "BlockScopedVariables";
|
|
7249
|
+
LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["ObjectAssign"] = 2 /* ES2015 */] = "ObjectAssign";
|
|
7250
|
+
LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["Exponentiation"] = 3 /* ES2016 */] = "Exponentiation";
|
|
7251
|
+
LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["AsyncFunctions"] = 4 /* ES2017 */] = "AsyncFunctions";
|
|
7252
|
+
LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["ForAwaitOf"] = 5 /* ES2018 */] = "ForAwaitOf";
|
|
7253
|
+
LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["AsyncGenerators"] = 5 /* ES2018 */] = "AsyncGenerators";
|
|
7254
|
+
LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["AsyncIteration"] = 5 /* ES2018 */] = "AsyncIteration";
|
|
7255
|
+
LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["ObjectSpreadRest"] = 5 /* ES2018 */] = "ObjectSpreadRest";
|
|
7256
|
+
LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["BindinglessCatch"] = 6 /* ES2019 */] = "BindinglessCatch";
|
|
7257
|
+
LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["BigInt"] = 7 /* ES2020 */] = "BigInt";
|
|
7258
|
+
LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["NullishCoalesce"] = 7 /* ES2020 */] = "NullishCoalesce";
|
|
7259
|
+
LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["OptionalChaining"] = 7 /* ES2020 */] = "OptionalChaining";
|
|
7260
|
+
LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["LogicalAssignment"] = 8 /* ES2021 */] = "LogicalAssignment";
|
|
7261
|
+
LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["TopLevelAwait"] = 9 /* ES2022 */] = "TopLevelAwait";
|
|
7262
|
+
LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["ClassFields"] = 9 /* ES2022 */] = "ClassFields";
|
|
7263
|
+
LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["PrivateNamesAndClassStaticBlocks"] = 9 /* ES2022 */] = "PrivateNamesAndClassStaticBlocks";
|
|
7264
|
+
LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["ShebangComments"] = 99 /* ESNext */] = "ShebangComments";
|
|
7265
|
+
LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["UsingAndAwaitUsing"] = 99 /* ESNext */] = "UsingAndAwaitUsing";
|
|
7266
|
+
LanguageFeatureMinimumTarget2[LanguageFeatureMinimumTarget2["ClassAndClassElementDecorators"] = 99 /* ESNext */] = "ClassAndClassElementDecorators";
|
|
7267
|
+
return LanguageFeatureMinimumTarget2;
|
|
7268
|
+
})(LanguageFeatureMinimumTarget || {});
|
|
7236
7269
|
var ExternalEmitHelpers = /* @__PURE__ */ ((ExternalEmitHelpers2) => {
|
|
7237
7270
|
ExternalEmitHelpers2[ExternalEmitHelpers2["Extends"] = 1] = "Extends";
|
|
7238
7271
|
ExternalEmitHelpers2[ExternalEmitHelpers2["Assign"] = 2] = "Assign";
|
|
@@ -9642,6 +9675,8 @@ var Diagnostics = {
|
|
|
9642
9675
|
The_left_hand_side_of_a_for_in_statement_cannot_be_an_await_using_declaration: diag(1494, 1 /* Error */, "The_left_hand_side_of_a_for_in_statement_cannot_be_an_await_using_declaration_1494", "The left-hand side of a 'for...in' statement cannot be an 'await using' declaration."),
|
|
9643
9676
|
_0_modifier_cannot_appear_on_an_await_using_declaration: diag(1495, 1 /* Error */, "_0_modifier_cannot_appear_on_an_await_using_declaration_1495", "'{0}' modifier cannot appear on an 'await using' declaration."),
|
|
9644
9677
|
Identifier_string_literal_or_number_literal_expected: diag(1496, 1 /* Error */, "Identifier_string_literal_or_number_literal_expected_1496", "Identifier, string literal, or number literal expected."),
|
|
9678
|
+
Expression_must_be_enclosed_in_parentheses_to_be_used_as_a_decorator: diag(1497, 1 /* Error */, "Expression_must_be_enclosed_in_parentheses_to_be_used_as_a_decorator_1497", "Expression must be enclosed in parentheses to be used as a decorator."),
|
|
9679
|
+
Invalid_syntax_in_decorator: diag(1498, 1 /* Error */, "Invalid_syntax_in_decorator_1498", "Invalid syntax in decorator."),
|
|
9645
9680
|
The_types_of_0_are_incompatible_between_these_types: diag(2200, 1 /* Error */, "The_types_of_0_are_incompatible_between_these_types_2200", "The types of '{0}' are incompatible between these types."),
|
|
9646
9681
|
The_types_returned_by_0_are_incompatible_between_these_types: diag(2201, 1 /* Error */, "The_types_returned_by_0_are_incompatible_between_these_types_2201", "The types returned by '{0}' are incompatible between these types."),
|
|
9647
9682
|
Call_signature_return_types_0_and_1_are_incompatible: diag(
|
|
@@ -11289,6 +11324,8 @@ var Diagnostics = {
|
|
|
11289
11324
|
Add_optional_parameter_to_0: diag(95191, 3 /* Message */, "Add_optional_parameter_to_0_95191", "Add optional parameter to '{0}'"),
|
|
11290
11325
|
Add_optional_parameters_to_0: diag(95192, 3 /* Message */, "Add_optional_parameters_to_0_95192", "Add optional parameters to '{0}'"),
|
|
11291
11326
|
Add_all_optional_parameters: diag(95193, 3 /* Message */, "Add_all_optional_parameters_95193", "Add all optional parameters"),
|
|
11327
|
+
Wrap_in_parentheses: diag(95194, 3 /* Message */, "Wrap_in_parentheses_95194", "Wrap in parentheses"),
|
|
11328
|
+
Wrap_all_invalid_decorator_expressions_in_parentheses: diag(95195, 3 /* Message */, "Wrap_all_invalid_decorator_expressions_in_parentheses_95195", "Wrap all invalid decorator expressions in parentheses"),
|
|
11292
11329
|
No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer: diag(18004, 1 /* Error */, "No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer_18004", "No value exists in scope for the shorthand property '{0}'. Either declare one or provide an initializer."),
|
|
11293
11330
|
Classes_may_not_have_a_field_named_constructor: diag(18006, 1 /* Error */, "Classes_may_not_have_a_field_named_constructor_18006", "Classes may not have a field named 'constructor'."),
|
|
11294
11331
|
JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array: diag(18007, 1 /* Error */, "JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array_18007", "JSX expressions may not use the comma operator. Did you mean to write an array?"),
|
|
@@ -21797,7 +21834,7 @@ function hasTabstop(node) {
|
|
|
21797
21834
|
}
|
|
21798
21835
|
function isJSDocOptionalParameter(node) {
|
|
21799
21836
|
return isInJSFile(node) && // node.type should only be a JSDocOptionalType when node is a parameter of a JSDocFunctionType
|
|
21800
|
-
(node.type && node.type.kind === 316 /* JSDocOptionalType */ || getJSDocParameterTags(node).some(
|
|
21837
|
+
(node.type && node.type.kind === 316 /* JSDocOptionalType */ || getJSDocParameterTags(node).some(isOptionalJSDocPropertyLikeTag));
|
|
21801
21838
|
}
|
|
21802
21839
|
function isOptionalDeclaration(declaration) {
|
|
21803
21840
|
switch (declaration.kind) {
|
|
@@ -48898,8 +48935,6 @@ function createTypeChecker(host) {
|
|
|
48898
48935
|
var comparableRelation = /* @__PURE__ */ new Map();
|
|
48899
48936
|
var identityRelation = /* @__PURE__ */ new Map();
|
|
48900
48937
|
var enumRelation = /* @__PURE__ */ new Map();
|
|
48901
|
-
var builtinGlobals = createSymbolTable();
|
|
48902
|
-
builtinGlobals.set(undefinedSymbol.escapedName, undefinedSymbol);
|
|
48903
48938
|
var suggestedExtensions = [
|
|
48904
48939
|
[".mts", ".mjs"],
|
|
48905
48940
|
[".ts", ".js"],
|
|
@@ -49317,17 +49352,17 @@ function createTypeChecker(host) {
|
|
|
49317
49352
|
}
|
|
49318
49353
|
}
|
|
49319
49354
|
}
|
|
49320
|
-
function
|
|
49321
|
-
|
|
49322
|
-
|
|
49323
|
-
|
|
49324
|
-
|
|
49325
|
-
|
|
49326
|
-
|
|
49327
|
-
|
|
49328
|
-
|
|
49329
|
-
|
|
49330
|
-
|
|
49355
|
+
function addUndefinedToGlobalsOrErrorOnRedeclaration() {
|
|
49356
|
+
const name = undefinedSymbol.escapedName;
|
|
49357
|
+
const targetSymbol = globals.get(name);
|
|
49358
|
+
if (targetSymbol) {
|
|
49359
|
+
forEach(targetSymbol.declarations, (declaration) => {
|
|
49360
|
+
if (!isTypeDeclaration(declaration)) {
|
|
49361
|
+
diagnostics.add(createDiagnosticForNode(declaration, Diagnostics.Declaration_name_conflicts_with_built_in_global_identifier_0, unescapeLeadingUnderscores(name)));
|
|
49362
|
+
}
|
|
49363
|
+
});
|
|
49364
|
+
} else {
|
|
49365
|
+
globals.set(name, undefinedSymbol);
|
|
49331
49366
|
}
|
|
49332
49367
|
}
|
|
49333
49368
|
function getSymbolLinks(symbol) {
|
|
@@ -49397,7 +49432,14 @@ function createTypeChecker(host) {
|
|
|
49397
49432
|
} else if (declaration.kind === 260 /* VariableDeclaration */) {
|
|
49398
49433
|
return !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage);
|
|
49399
49434
|
} else if (isClassLike(declaration)) {
|
|
49400
|
-
|
|
49435
|
+
const container = findAncestor(usage, (n) => n === declaration ? "quit" : isComputedPropertyName(n) ? n.parent.parent === declaration : isDecorator(n) && (n.parent === declaration || isMethodDeclaration(n.parent) && n.parent.parent === declaration || isGetOrSetAccessorDeclaration(n.parent) && n.parent.parent === declaration || isPropertyDeclaration(n.parent) && n.parent.parent === declaration || isParameter(n.parent) && n.parent.parent.parent === declaration));
|
|
49436
|
+
if (!container) {
|
|
49437
|
+
return true;
|
|
49438
|
+
}
|
|
49439
|
+
if (isDecorator(container)) {
|
|
49440
|
+
return !!findAncestor(usage, (n) => n === container ? "quit" : isFunctionLike(n) && !getImmediatelyInvokedFunctionExpression(n));
|
|
49441
|
+
}
|
|
49442
|
+
return false;
|
|
49401
49443
|
} else if (isPropertyDeclaration(declaration)) {
|
|
49402
49444
|
return !isPropertyImmediatelyReferencedWithinDeclaration(
|
|
49403
49445
|
declaration,
|
|
@@ -58282,7 +58324,7 @@ function createTypeChecker(host) {
|
|
|
58282
58324
|
if (!lateSymbol)
|
|
58283
58325
|
lateSymbols.set(memberName, lateSymbol = createSymbol(0 /* None */, memberName, 4096 /* Late */));
|
|
58284
58326
|
const earlySymbol = earlySymbols && earlySymbols.get(memberName);
|
|
58285
|
-
if (!(parent2.flags & 32 /* Class */) && lateSymbol.flags & getExcludedSymbolFlags(symbolFlags)) {
|
|
58327
|
+
if (!(parent2.flags & 32 /* Class */) && (lateSymbol.flags & getExcludedSymbolFlags(symbolFlags) || earlySymbol)) {
|
|
58286
58328
|
const declarations = earlySymbol ? concatenate(earlySymbol.declarations, lateSymbol.declarations) : lateSymbol.declarations;
|
|
58287
58329
|
const name = !(type.flags & 8192 /* UniqueESSymbol */) && unescapeLeadingUnderscores(memberName) || declarationNameToString(declName);
|
|
58288
58330
|
forEach(declarations, (declaration) => error2(getNameOfDeclaration(declaration) || declaration, Diagnostics.Property_0_was_also_declared_here, name));
|
|
@@ -60070,10 +60112,16 @@ function createTypeChecker(host) {
|
|
|
60070
60112
|
const symbol = getSymbol2(globals, '"' + moduleName + '"', 512 /* ValueModule */);
|
|
60071
60113
|
return symbol && withAugmentations ? getMergedSymbol(symbol) : symbol;
|
|
60072
60114
|
}
|
|
60115
|
+
function hasEffectiveQuestionToken(node) {
|
|
60116
|
+
return hasQuestionToken(node) || isOptionalJSDocPropertyLikeTag(node) || isParameter(node) && isJSDocOptionalParameter(node);
|
|
60117
|
+
}
|
|
60073
60118
|
function isOptionalParameter(node) {
|
|
60074
|
-
if (
|
|
60119
|
+
if (hasEffectiveQuestionToken(node)) {
|
|
60075
60120
|
return true;
|
|
60076
60121
|
}
|
|
60122
|
+
if (!isParameter(node)) {
|
|
60123
|
+
return false;
|
|
60124
|
+
}
|
|
60077
60125
|
if (node.initializer) {
|
|
60078
60126
|
const signature = getSignatureFromDeclaration(node.parent);
|
|
60079
60127
|
const parameterIndex = node.parent.parameters.indexOf(node);
|
|
@@ -60173,7 +60221,7 @@ function createTypeChecker(host) {
|
|
|
60173
60221
|
if (type && type.kind === 201 /* LiteralType */) {
|
|
60174
60222
|
flags |= 2 /* HasLiteralTypes */;
|
|
60175
60223
|
}
|
|
60176
|
-
const isOptionalParameter2 =
|
|
60224
|
+
const isOptionalParameter2 = hasEffectiveQuestionToken(param) || isParameter(param) && param.initializer || isRestParameter(param) || iife && parameters.length > iife.arguments.length && !type;
|
|
60177
60225
|
if (!isOptionalParameter2) {
|
|
60178
60226
|
minArgumentCount = parameters.length;
|
|
60179
60227
|
}
|
|
@@ -65291,7 +65339,7 @@ function createTypeChecker(host) {
|
|
|
65291
65339
|
if (reduced !== type) {
|
|
65292
65340
|
return reduced;
|
|
65293
65341
|
}
|
|
65294
|
-
if (type.flags & 2097152 /* Intersection */ &&
|
|
65342
|
+
if (type.flags & 2097152 /* Intersection */ && shouldNormalizeIntersection(type)) {
|
|
65295
65343
|
const normalizedTypes = sameMap(type.types, (t) => getNormalizedType(t, writing));
|
|
65296
65344
|
if (normalizedTypes !== type.types) {
|
|
65297
65345
|
return getIntersectionType(normalizedTypes);
|
|
@@ -65299,6 +65347,17 @@ function createTypeChecker(host) {
|
|
|
65299
65347
|
}
|
|
65300
65348
|
return type;
|
|
65301
65349
|
}
|
|
65350
|
+
function shouldNormalizeIntersection(type) {
|
|
65351
|
+
let hasInstantiable = false;
|
|
65352
|
+
let hasNullableOrEmpty = false;
|
|
65353
|
+
for (const t of type.types) {
|
|
65354
|
+
hasInstantiable || (hasInstantiable = !!(t.flags & 465829888 /* Instantiable */));
|
|
65355
|
+
hasNullableOrEmpty || (hasNullableOrEmpty = !!(t.flags & 98304 /* Nullable */) || isEmptyAnonymousObjectType(t));
|
|
65356
|
+
if (hasInstantiable && hasNullableOrEmpty)
|
|
65357
|
+
return true;
|
|
65358
|
+
}
|
|
65359
|
+
return false;
|
|
65360
|
+
}
|
|
65302
65361
|
function getNormalizedTupleType(type, writing) {
|
|
65303
65362
|
const elements = getElementTypes(type);
|
|
65304
65363
|
const normalizedElements = sameMap(elements, (t) => t.flags & 25165824 /* Simplifiable */ ? getSimplifiedType(t, writing) : t);
|
|
@@ -70149,9 +70208,9 @@ function createTypeChecker(host) {
|
|
|
70149
70208
|
if (strictNullChecks) {
|
|
70150
70209
|
switch (facts) {
|
|
70151
70210
|
case 524288 /* NEUndefined */:
|
|
70152
|
-
return
|
|
70211
|
+
return removeNullableByIntersection(reduced, 65536 /* EQUndefined */, 131072 /* EQNull */, 33554432 /* IsNull */, nullType);
|
|
70153
70212
|
case 1048576 /* NENull */:
|
|
70154
|
-
return
|
|
70213
|
+
return removeNullableByIntersection(reduced, 131072 /* EQNull */, 65536 /* EQUndefined */, 16777216 /* IsUndefined */, undefinedType);
|
|
70155
70214
|
case 2097152 /* NEUndefinedOrNull */:
|
|
70156
70215
|
case 4194304 /* Truthy */:
|
|
70157
70216
|
return mapType(reduced, (t) => hasTypeFacts(t, 262144 /* EQUndefinedOrNull */) ? getGlobalNonNullableTypeInstantiation(t) : t);
|
|
@@ -70159,6 +70218,14 @@ function createTypeChecker(host) {
|
|
|
70159
70218
|
}
|
|
70160
70219
|
return reduced;
|
|
70161
70220
|
}
|
|
70221
|
+
function removeNullableByIntersection(type, targetFacts, otherFacts, otherIncludesFacts, otherType) {
|
|
70222
|
+
const facts = getTypeFacts(type, 65536 /* EQUndefined */ | 131072 /* EQNull */ | 16777216 /* IsUndefined */ | 33554432 /* IsNull */);
|
|
70223
|
+
if (!(facts & targetFacts)) {
|
|
70224
|
+
return type;
|
|
70225
|
+
}
|
|
70226
|
+
const emptyAndOtherUnion = getUnionType([emptyObjectType, otherType]);
|
|
70227
|
+
return mapType(type, (t) => hasTypeFacts(t, targetFacts) ? getIntersectionType([t, !(facts & otherIncludesFacts) && hasTypeFacts(t, otherFacts) ? emptyAndOtherUnion : emptyObjectType]) : t);
|
|
70228
|
+
}
|
|
70162
70229
|
function recombineUnknownType(type) {
|
|
70163
70230
|
return type === unknownUnionType ? unknownType : type;
|
|
70164
70231
|
}
|
|
@@ -73726,7 +73793,7 @@ function createTypeChecker(host) {
|
|
|
73726
73793
|
}
|
|
73727
73794
|
}
|
|
73728
73795
|
function checkSpreadExpression(node, checkMode) {
|
|
73729
|
-
if (languageVersion < 2 /*
|
|
73796
|
+
if (languageVersion < 2 /* SpreadElements */) {
|
|
73730
73797
|
checkExternalEmitHelpers(node, compilerOptions.downlevelIteration ? 1536 /* SpreadIncludes */ : 1024 /* SpreadArray */);
|
|
73731
73798
|
}
|
|
73732
73799
|
const arrayOrIterableType = checkExpression(node.expression, checkMode);
|
|
@@ -73760,7 +73827,7 @@ function createTypeChecker(host) {
|
|
|
73760
73827
|
for (let i = 0; i < elementCount; i++) {
|
|
73761
73828
|
const e = elements[i];
|
|
73762
73829
|
if (e.kind === 230 /* SpreadElement */) {
|
|
73763
|
-
if (languageVersion < 2 /*
|
|
73830
|
+
if (languageVersion < 2 /* SpreadElements */) {
|
|
73764
73831
|
checkExternalEmitHelpers(e, compilerOptions.downlevelIteration ? 1536 /* SpreadIncludes */ : 1024 /* SpreadArray */);
|
|
73765
73832
|
}
|
|
73766
73833
|
const spreadType = checkExpression(e.expression, checkMode, forceTuple);
|
|
@@ -73990,7 +74057,7 @@ function createTypeChecker(host) {
|
|
|
73990
74057
|
addIntraExpressionInferenceSite(inferenceContext, inferenceNode, type);
|
|
73991
74058
|
}
|
|
73992
74059
|
} else if (memberDecl.kind === 305 /* SpreadAssignment */) {
|
|
73993
|
-
if (languageVersion < 2 /*
|
|
74060
|
+
if (languageVersion < 2 /* ObjectAssign */) {
|
|
73994
74061
|
checkExternalEmitHelpers(memberDecl, 2 /* Assign */);
|
|
73995
74062
|
}
|
|
73996
74063
|
if (propertiesArray.length > 0) {
|
|
@@ -75015,7 +75082,7 @@ function createTypeChecker(host) {
|
|
|
75015
75082
|
const isAnyLike = isTypeAny(apparentType) || apparentType === silentNeverType;
|
|
75016
75083
|
let prop;
|
|
75017
75084
|
if (isPrivateIdentifier(right)) {
|
|
75018
|
-
if (languageVersion < 99 /*
|
|
75085
|
+
if (languageVersion < 9 /* PrivateNamesAndClassStaticBlocks */ || languageVersion < 99 /* ClassAndClassElementDecorators */ || !useDefineForClassFields) {
|
|
75019
75086
|
if (assignmentKind !== 0 /* None */) {
|
|
75020
75087
|
checkExternalEmitHelpers(node, 1048576 /* ClassPrivateFieldSet */);
|
|
75021
75088
|
}
|
|
@@ -76842,7 +76909,7 @@ function createTypeChecker(host) {
|
|
|
76842
76909
|
}
|
|
76843
76910
|
return resolveErrorCall(node);
|
|
76844
76911
|
}
|
|
76845
|
-
if (checkMode & 8 /* SkipGenericFunctions */ && !node.typeArguments && callSignatures.some(
|
|
76912
|
+
if (checkMode & 8 /* SkipGenericFunctions */ && !node.typeArguments && callSignatures.some(isGenericFunctionReturningFunction)) {
|
|
76846
76913
|
skippedGenericFunction(node, checkMode);
|
|
76847
76914
|
return resolvingSignature;
|
|
76848
76915
|
}
|
|
@@ -76852,12 +76919,8 @@ function createTypeChecker(host) {
|
|
|
76852
76919
|
}
|
|
76853
76920
|
return resolveCall(node, callSignatures, candidatesOutArray, checkMode, callChainFlags);
|
|
76854
76921
|
}
|
|
76855
|
-
function
|
|
76856
|
-
|
|
76857
|
-
return false;
|
|
76858
|
-
}
|
|
76859
|
-
const returnType = getReturnTypeOfSignature(signature);
|
|
76860
|
-
return isFunctionType(returnType) || isConstructorType(returnType);
|
|
76922
|
+
function isGenericFunctionReturningFunction(signature) {
|
|
76923
|
+
return !!(signature.typeParameters && isFunctionType(getReturnTypeOfSignature(signature)));
|
|
76861
76924
|
}
|
|
76862
76925
|
function isUntypedFunctionCall(funcType, apparentFuncType, numCallSignatures, numConstructSignatures) {
|
|
76863
76926
|
return isTypeAny(funcType) || isTypeAny(apparentFuncType) && !!(funcType.flags & 262144 /* TypeParameter */) || !numCallSignatures && !numConstructSignatures && !(apparentFuncType.flags & 1048576 /* Union */) && !(getReducedType(apparentFuncType).flags & 131072 /* Never */) && isTypeAssignableTo(funcType, globalFunctionType);
|
|
@@ -77628,7 +77691,7 @@ function createTypeChecker(host) {
|
|
|
77628
77691
|
function checkTaggedTemplateExpression(node) {
|
|
77629
77692
|
if (!checkGrammarTaggedTemplateChain(node))
|
|
77630
77693
|
checkGrammarTypeArguments(node, node.typeArguments);
|
|
77631
|
-
if (languageVersion < 2 /*
|
|
77694
|
+
if (languageVersion < 2 /* TaggedTemplates */) {
|
|
77632
77695
|
checkExternalEmitHelpers(node, 262144 /* MakeTemplateObject */);
|
|
77633
77696
|
}
|
|
77634
77697
|
const signature = getResolvedSignature(node);
|
|
@@ -79275,7 +79338,7 @@ function createTypeChecker(host) {
|
|
|
79275
79338
|
return silentNeverType;
|
|
79276
79339
|
}
|
|
79277
79340
|
if (isPrivateIdentifier(left)) {
|
|
79278
|
-
if (languageVersion < 99 /*
|
|
79341
|
+
if (languageVersion < 9 /* PrivateNamesAndClassStaticBlocks */ || languageVersion < 99 /* ClassAndClassElementDecorators */ || !useDefineForClassFields) {
|
|
79279
79342
|
checkExternalEmitHelpers(left, 2097152 /* ClassPrivateFieldIn */);
|
|
79280
79343
|
}
|
|
79281
79344
|
if (!getNodeLinks(left).resolvedSymbol && getContainingClass(left)) {
|
|
@@ -79336,7 +79399,7 @@ function createTypeChecker(host) {
|
|
|
79336
79399
|
if (propertyIndex < properties.length - 1) {
|
|
79337
79400
|
error2(property, Diagnostics.A_rest_element_must_be_last_in_a_destructuring_pattern);
|
|
79338
79401
|
} else {
|
|
79339
|
-
if (languageVersion <
|
|
79402
|
+
if (languageVersion < 5 /* ObjectSpreadRest */) {
|
|
79340
79403
|
checkExternalEmitHelpers(property, 4 /* Rest */);
|
|
79341
79404
|
}
|
|
79342
79405
|
const nonRestNames = [];
|
|
@@ -79357,7 +79420,7 @@ function createTypeChecker(host) {
|
|
|
79357
79420
|
}
|
|
79358
79421
|
function checkArrayLiteralAssignment(node, sourceType, checkMode) {
|
|
79359
79422
|
const elements = node.elements;
|
|
79360
|
-
if (languageVersion < 2 /*
|
|
79423
|
+
if (languageVersion < 2 /* DestructuringAssignment */ && compilerOptions.downlevelIteration) {
|
|
79361
79424
|
checkExternalEmitHelpers(node, 512 /* Read */);
|
|
79362
79425
|
}
|
|
79363
79426
|
const possiblyOutOfBoundsType = checkIteratedTypeOrElementType(65 /* Destructuring */ | 128 /* PossiblyOutOfBounds */, sourceType, undefinedType, node) || errorType;
|
|
@@ -80059,10 +80122,10 @@ function createTypeChecker(host) {
|
|
|
80059
80122
|
}
|
|
80060
80123
|
const isAsync = (functionFlags & 2 /* Async */) !== 0;
|
|
80061
80124
|
if (node.asteriskToken) {
|
|
80062
|
-
if (isAsync && languageVersion <
|
|
80125
|
+
if (isAsync && languageVersion < 5 /* AsyncGenerators */) {
|
|
80063
80126
|
checkExternalEmitHelpers(node, 26624 /* AsyncDelegatorIncludes */);
|
|
80064
80127
|
}
|
|
80065
|
-
if (!isAsync && languageVersion < 2 /*
|
|
80128
|
+
if (!isAsync && languageVersion < 2 /* Generators */ && compilerOptions.downlevelIteration) {
|
|
80066
80129
|
checkExternalEmitHelpers(node, 256 /* Values */);
|
|
80067
80130
|
}
|
|
80068
80131
|
}
|
|
@@ -80834,13 +80897,13 @@ function createTypeChecker(host) {
|
|
|
80834
80897
|
}
|
|
80835
80898
|
const functionFlags = getFunctionFlags(node);
|
|
80836
80899
|
if (!(functionFlags & 4 /* Invalid */)) {
|
|
80837
|
-
if ((functionFlags & 3 /* AsyncGenerator */) === 3 /* AsyncGenerator */ && languageVersion <
|
|
80900
|
+
if ((functionFlags & 3 /* AsyncGenerator */) === 3 /* AsyncGenerator */ && languageVersion < 5 /* AsyncGenerators */) {
|
|
80838
80901
|
checkExternalEmitHelpers(node, 6144 /* AsyncGeneratorIncludes */);
|
|
80839
80902
|
}
|
|
80840
|
-
if ((functionFlags & 3 /* AsyncGenerator */) === 2 /* Async */ && languageVersion < 4 /*
|
|
80903
|
+
if ((functionFlags & 3 /* AsyncGenerator */) === 2 /* Async */ && languageVersion < 4 /* AsyncFunctions */) {
|
|
80841
80904
|
checkExternalEmitHelpers(node, 64 /* Awaiter */);
|
|
80842
80905
|
}
|
|
80843
|
-
if ((functionFlags & 3 /* AsyncGenerator */) !== 0 /* Normal */ && languageVersion < 2 /*
|
|
80906
|
+
if ((functionFlags & 3 /* AsyncGenerator */) !== 0 /* Normal */ && languageVersion < 2 /* Generators */) {
|
|
80844
80907
|
checkExternalEmitHelpers(node, 128 /* Generator */);
|
|
80845
80908
|
}
|
|
80846
80909
|
}
|
|
@@ -81073,15 +81136,17 @@ function createTypeChecker(host) {
|
|
|
81073
81136
|
setNodeLinksForPrivateIdentifierScope(node);
|
|
81074
81137
|
}
|
|
81075
81138
|
function setNodeLinksForPrivateIdentifierScope(node) {
|
|
81076
|
-
if (isPrivateIdentifier(node.name)
|
|
81077
|
-
|
|
81078
|
-
|
|
81079
|
-
|
|
81080
|
-
|
|
81081
|
-
|
|
81082
|
-
|
|
81083
|
-
|
|
81084
|
-
|
|
81139
|
+
if (isPrivateIdentifier(node.name)) {
|
|
81140
|
+
if (languageVersion < 9 /* PrivateNamesAndClassStaticBlocks */ || languageVersion < 99 /* ClassAndClassElementDecorators */ || !useDefineForClassFields) {
|
|
81141
|
+
for (let lexicalScope = getEnclosingBlockScopeContainer(node); !!lexicalScope; lexicalScope = getEnclosingBlockScopeContainer(lexicalScope)) {
|
|
81142
|
+
getNodeLinks(lexicalScope).flags |= 1048576 /* ContainsClassWithPrivateIdentifiers */;
|
|
81143
|
+
}
|
|
81144
|
+
if (isClassExpression(node.parent)) {
|
|
81145
|
+
const enclosingIterationStatement = getEnclosingIterationStatement(node.parent);
|
|
81146
|
+
if (enclosingIterationStatement) {
|
|
81147
|
+
getNodeLinks(node.name).flags |= 32768 /* BlockScopedBindingInLoop */;
|
|
81148
|
+
getNodeLinks(enclosingIterationStatement).flags |= 4096 /* LoopWithCapturedBlockScopedBinding */;
|
|
81149
|
+
}
|
|
81085
81150
|
}
|
|
81086
81151
|
}
|
|
81087
81152
|
}
|
|
@@ -82033,7 +82098,56 @@ function createTypeChecker(host) {
|
|
|
82033
82098
|
}
|
|
82034
82099
|
}
|
|
82035
82100
|
}
|
|
82101
|
+
function checkGrammarDecorator(decorator) {
|
|
82102
|
+
const sourceFile = getSourceFileOfNode(decorator);
|
|
82103
|
+
if (!hasParseDiagnostics(sourceFile)) {
|
|
82104
|
+
let node = decorator.expression;
|
|
82105
|
+
if (isParenthesizedExpression(node)) {
|
|
82106
|
+
return false;
|
|
82107
|
+
}
|
|
82108
|
+
let canHaveCallExpression = true;
|
|
82109
|
+
let errorNode;
|
|
82110
|
+
while (true) {
|
|
82111
|
+
if (isExpressionWithTypeArguments(node) || isNonNullExpression(node)) {
|
|
82112
|
+
node = node.expression;
|
|
82113
|
+
continue;
|
|
82114
|
+
}
|
|
82115
|
+
if (isCallExpression(node)) {
|
|
82116
|
+
if (!canHaveCallExpression) {
|
|
82117
|
+
errorNode = node;
|
|
82118
|
+
}
|
|
82119
|
+
if (node.questionDotToken) {
|
|
82120
|
+
errorNode = node.questionDotToken;
|
|
82121
|
+
}
|
|
82122
|
+
node = node.expression;
|
|
82123
|
+
canHaveCallExpression = false;
|
|
82124
|
+
continue;
|
|
82125
|
+
}
|
|
82126
|
+
if (isPropertyAccessExpression(node)) {
|
|
82127
|
+
if (node.questionDotToken) {
|
|
82128
|
+
errorNode = node.questionDotToken;
|
|
82129
|
+
}
|
|
82130
|
+
node = node.expression;
|
|
82131
|
+
canHaveCallExpression = false;
|
|
82132
|
+
continue;
|
|
82133
|
+
}
|
|
82134
|
+
if (!isIdentifier(node)) {
|
|
82135
|
+
errorNode = node;
|
|
82136
|
+
}
|
|
82137
|
+
break;
|
|
82138
|
+
}
|
|
82139
|
+
if (errorNode) {
|
|
82140
|
+
addRelatedInfo(
|
|
82141
|
+
error2(decorator.expression, Diagnostics.Expression_must_be_enclosed_in_parentheses_to_be_used_as_a_decorator),
|
|
82142
|
+
createDiagnosticForNode(errorNode, Diagnostics.Invalid_syntax_in_decorator)
|
|
82143
|
+
);
|
|
82144
|
+
return true;
|
|
82145
|
+
}
|
|
82146
|
+
}
|
|
82147
|
+
return false;
|
|
82148
|
+
}
|
|
82036
82149
|
function checkDecorator(node) {
|
|
82150
|
+
checkGrammarDecorator(node);
|
|
82037
82151
|
const signature = getResolvedSignature(node);
|
|
82038
82152
|
checkDeprecatedSignature(signature, node);
|
|
82039
82153
|
const returnType = getReturnTypeOfSignature(signature);
|
|
@@ -82206,7 +82320,7 @@ function createTypeChecker(host) {
|
|
|
82206
82320
|
if (node.kind === 169 /* Parameter */) {
|
|
82207
82321
|
checkExternalEmitHelpers(firstDecorator, 32 /* Param */);
|
|
82208
82322
|
}
|
|
82209
|
-
} else if (languageVersion < 99 /*
|
|
82323
|
+
} else if (languageVersion < 99 /* ClassAndClassElementDecorators */) {
|
|
82210
82324
|
checkExternalEmitHelpers(firstDecorator, 8 /* ESDecorateAndRunInitializers */);
|
|
82211
82325
|
if (isClassDeclaration(node)) {
|
|
82212
82326
|
if (!node.name) {
|
|
@@ -82911,7 +83025,7 @@ function createTypeChecker(host) {
|
|
|
82911
83025
|
potentialUnusedRenamedBindingElementsInTypes.push(node);
|
|
82912
83026
|
return;
|
|
82913
83027
|
}
|
|
82914
|
-
if (isObjectBindingPattern(node.parent) && node.dotDotDotToken && languageVersion < 5 /*
|
|
83028
|
+
if (isObjectBindingPattern(node.parent) && node.dotDotDotToken && languageVersion < 5 /* ObjectSpreadRest */) {
|
|
82915
83029
|
checkExternalEmitHelpers(node, 4 /* Rest */);
|
|
82916
83030
|
}
|
|
82917
83031
|
if (node.propertyName && node.propertyName.kind === 167 /* ComputedPropertyName */) {
|
|
@@ -82947,7 +83061,7 @@ function createTypeChecker(host) {
|
|
|
82947
83061
|
}
|
|
82948
83062
|
}
|
|
82949
83063
|
if (isBindingPattern(node.name)) {
|
|
82950
|
-
if (node.name.kind === 207 /* ArrayBindingPattern */ && languageVersion < 2 /*
|
|
83064
|
+
if (node.name.kind === 207 /* ArrayBindingPattern */ && languageVersion < 2 /* BindingPatterns */ && compilerOptions.downlevelIteration) {
|
|
82951
83065
|
checkExternalEmitHelpers(node, 512 /* Read */);
|
|
82952
83066
|
}
|
|
82953
83067
|
forEach(node.name.elements, checkSourceElement);
|
|
@@ -83098,7 +83212,7 @@ function createTypeChecker(host) {
|
|
|
83098
83212
|
}
|
|
83099
83213
|
function checkVariableDeclarationList(node) {
|
|
83100
83214
|
const blockScopeKind = getCombinedNodeFlags(node) & 7 /* BlockScoped */;
|
|
83101
|
-
if (blockScopeKind === 4 /* Using */ || blockScopeKind === 6 /* AwaitUsing */) {
|
|
83215
|
+
if ((blockScopeKind === 4 /* Using */ || blockScopeKind === 6 /* AwaitUsing */) && languageVersion < 99 /* UsingAndAwaitUsing */) {
|
|
83102
83216
|
checkExternalEmitHelpers(node, 16777216 /* AddDisposableResourceAndDisposeResources */);
|
|
83103
83217
|
}
|
|
83104
83218
|
forEach(node.declarations, checkSourceElement);
|
|
@@ -83271,11 +83385,11 @@ function createTypeChecker(host) {
|
|
|
83271
83385
|
grammarErrorOnNode(node.awaitModifier, Diagnostics.for_await_loops_cannot_be_used_inside_a_class_static_block);
|
|
83272
83386
|
} else {
|
|
83273
83387
|
const functionFlags = getFunctionFlags(container);
|
|
83274
|
-
if ((functionFlags & (4 /* Invalid */ | 2 /* Async */)) === 2 /* Async */ && languageVersion <
|
|
83388
|
+
if ((functionFlags & (4 /* Invalid */ | 2 /* Async */)) === 2 /* Async */ && languageVersion < 5 /* ForAwaitOf */) {
|
|
83275
83389
|
checkExternalEmitHelpers(node, 16384 /* ForAwaitOfIncludes */);
|
|
83276
83390
|
}
|
|
83277
83391
|
}
|
|
83278
|
-
} else if (compilerOptions.downlevelIteration && languageVersion < 2 /*
|
|
83392
|
+
} else if (compilerOptions.downlevelIteration && languageVersion < 2 /* ForOf */) {
|
|
83279
83393
|
checkExternalEmitHelpers(node, 256 /* ForOfIncludes */);
|
|
83280
83394
|
}
|
|
83281
83395
|
if (node.initializer.kind === 261 /* VariableDeclarationList */) {
|
|
@@ -84199,6 +84313,7 @@ function createTypeChecker(host) {
|
|
|
84199
84313
|
case "symbol":
|
|
84200
84314
|
case "void":
|
|
84201
84315
|
case "object":
|
|
84316
|
+
case "undefined":
|
|
84202
84317
|
error2(name, message, name.escapedText);
|
|
84203
84318
|
}
|
|
84204
84319
|
}
|
|
@@ -84338,12 +84453,12 @@ function createTypeChecker(host) {
|
|
|
84338
84453
|
return true;
|
|
84339
84454
|
}
|
|
84340
84455
|
function getFirstTransformableStaticClassElement(node) {
|
|
84341
|
-
const willTransformStaticElementsOfDecoratedClass = !legacyDecorators && languageVersion < 99 /*
|
|
84456
|
+
const willTransformStaticElementsOfDecoratedClass = !legacyDecorators && languageVersion < 99 /* ClassAndClassElementDecorators */ && classOrConstructorParameterIsDecorated(
|
|
84342
84457
|
/*useLegacyDecorators*/
|
|
84343
84458
|
false,
|
|
84344
84459
|
node
|
|
84345
84460
|
);
|
|
84346
|
-
const willTransformPrivateElementsOrClassStaticBlocks = languageVersion
|
|
84461
|
+
const willTransformPrivateElementsOrClassStaticBlocks = languageVersion < 9 /* PrivateNamesAndClassStaticBlocks */ || languageVersion < 99 /* ClassAndClassElementDecorators */;
|
|
84347
84462
|
const willTransformInitializers = !emitStandardClassFields;
|
|
84348
84463
|
if (willTransformStaticElementsOfDecoratedClass || willTransformPrivateElementsOrClassStaticBlocks) {
|
|
84349
84464
|
for (const member of node.members) {
|
|
@@ -84372,7 +84487,7 @@ function createTypeChecker(host) {
|
|
|
84372
84487
|
const parent2 = walkUpOuterExpressions(node);
|
|
84373
84488
|
if (!isNamedEvaluationSource(parent2))
|
|
84374
84489
|
return;
|
|
84375
|
-
const willTransformESDecorators = !legacyDecorators && languageVersion < 99 /*
|
|
84490
|
+
const willTransformESDecorators = !legacyDecorators && languageVersion < 99 /* ClassAndClassElementDecorators */;
|
|
84376
84491
|
let location;
|
|
84377
84492
|
if (willTransformESDecorators && classOrConstructorParameterIsDecorated(
|
|
84378
84493
|
/*useLegacyDecorators*/
|
|
@@ -84432,7 +84547,7 @@ function createTypeChecker(host) {
|
|
|
84432
84547
|
const baseTypeNode = getEffectiveBaseTypeNode(node);
|
|
84433
84548
|
if (baseTypeNode) {
|
|
84434
84549
|
forEach(baseTypeNode.typeArguments, checkSourceElement);
|
|
84435
|
-
if (languageVersion < 2 /*
|
|
84550
|
+
if (languageVersion < 2 /* Classes */) {
|
|
84436
84551
|
checkExternalEmitHelpers(baseTypeNode.parent, 1 /* Extends */);
|
|
84437
84552
|
}
|
|
84438
84553
|
const extendsNode = getClassExtendsHeritageElement(node);
|
|
@@ -87901,7 +88016,7 @@ function createTypeChecker(host) {
|
|
|
87901
88016
|
}
|
|
87902
88017
|
}
|
|
87903
88018
|
}
|
|
87904
|
-
|
|
88019
|
+
addUndefinedToGlobalsOrErrorOnRedeclaration();
|
|
87905
88020
|
getSymbolLinks(undefinedSymbol).type = undefinedWideningType;
|
|
87906
88021
|
getSymbolLinks(argumentsSymbol).type = getGlobalType(
|
|
87907
88022
|
"IArguments",
|
|
@@ -88555,7 +88670,7 @@ function createTypeChecker(host) {
|
|
|
88555
88670
|
if (parameter.initializer) {
|
|
88556
88671
|
return grammarErrorOnNode(parameter.name, Diagnostics.A_rest_parameter_cannot_have_an_initializer);
|
|
88557
88672
|
}
|
|
88558
|
-
} else if (
|
|
88673
|
+
} else if (hasEffectiveQuestionToken(parameter)) {
|
|
88559
88674
|
seenOptionalParameter = true;
|
|
88560
88675
|
if (parameter.questionToken && parameter.initializer) {
|
|
88561
88676
|
return grammarErrorOnNode(parameter.name, Diagnostics.Parameter_cannot_have_question_mark_and_initializer);
|
|
@@ -91666,12 +91781,12 @@ function getOriginalNodeId(node) {
|
|
|
91666
91781
|
function containsDefaultReference(node) {
|
|
91667
91782
|
if (!node)
|
|
91668
91783
|
return false;
|
|
91669
|
-
if (!isNamedImports(node))
|
|
91784
|
+
if (!isNamedImports(node) && !isNamedExports(node))
|
|
91670
91785
|
return false;
|
|
91671
91786
|
return some(node.elements, isNamedDefaultReference);
|
|
91672
91787
|
}
|
|
91673
91788
|
function isNamedDefaultReference(e) {
|
|
91674
|
-
return e.propertyName !== void 0
|
|
91789
|
+
return e.propertyName !== void 0 ? e.propertyName.escapedText === "default" /* Default */ : e.name.escapedText === "default" /* Default */;
|
|
91675
91790
|
}
|
|
91676
91791
|
function chainBundle(context, transformSourceFile) {
|
|
91677
91792
|
return transformSourceFileOrBundle;
|
|
@@ -91745,6 +91860,7 @@ function collectExternalModuleInfo(context, sourceFile) {
|
|
|
91745
91860
|
externalImports.push(node);
|
|
91746
91861
|
if (isNamedExports(node.exportClause)) {
|
|
91747
91862
|
addExportedNamesForExportDeclaration(node);
|
|
91863
|
+
hasImportDefault || (hasImportDefault = containsDefaultReference(node.exportClause));
|
|
91748
91864
|
} else {
|
|
91749
91865
|
const name = node.exportClause.name;
|
|
91750
91866
|
if (!uniqueExports.get(idText(name))) {
|
|
@@ -145569,22 +145685,22 @@ function createLanguageService(host, documentRegistry = createDocumentRegistry(h
|
|
|
145569
145685
|
}
|
|
145570
145686
|
return [];
|
|
145571
145687
|
}
|
|
145572
|
-
function getCodeFixesAtPosition(fileName, start, end,
|
|
145688
|
+
function getCodeFixesAtPosition(fileName, start, end, errorCodes66, formatOptions, preferences = emptyOptions) {
|
|
145573
145689
|
synchronizeHostData();
|
|
145574
145690
|
const sourceFile = getValidSourceFile(fileName);
|
|
145575
145691
|
const span = createTextSpanFromBounds(start, end);
|
|
145576
145692
|
const formatContext = ts_formatting_exports.getFormatContext(formatOptions, host);
|
|
145577
|
-
return flatMap(deduplicate(
|
|
145693
|
+
return flatMap(deduplicate(errorCodes66, equateValues, compareValues), (errorCode) => {
|
|
145578
145694
|
cancellationToken.throwIfCancellationRequested();
|
|
145579
145695
|
return ts_codefix_exports.getFixes({ errorCode, sourceFile, span, program, host, cancellationToken, formatContext, preferences });
|
|
145580
145696
|
});
|
|
145581
145697
|
}
|
|
145582
|
-
function getCombinedCodeFix(scope,
|
|
145698
|
+
function getCombinedCodeFix(scope, fixId53, formatOptions, preferences = emptyOptions) {
|
|
145583
145699
|
synchronizeHostData();
|
|
145584
145700
|
Debug.assert(scope.type === "file");
|
|
145585
145701
|
const sourceFile = getValidSourceFile(scope.fileName);
|
|
145586
145702
|
const formatContext = ts_formatting_exports.getFormatContext(formatOptions, host);
|
|
145587
|
-
return ts_codefix_exports.getAllFixes({ fixId:
|
|
145703
|
+
return ts_codefix_exports.getAllFixes({ fixId: fixId53, sourceFile, program, host, cancellationToken, formatContext, preferences });
|
|
145588
145704
|
}
|
|
145589
145705
|
function organizeImports2(args, formatOptions, preferences = emptyOptions) {
|
|
145590
145706
|
synchronizeHostData();
|
|
@@ -147263,14 +147379,14 @@ function createCodeFixActionWithoutFixAll(fixName8, changes, description3) {
|
|
|
147263
147379
|
void 0
|
|
147264
147380
|
);
|
|
147265
147381
|
}
|
|
147266
|
-
function createCodeFixAction(fixName8, changes, description3,
|
|
147267
|
-
return createCodeFixActionWorker(fixName8, diagnosticToString(description3), changes,
|
|
147382
|
+
function createCodeFixAction(fixName8, changes, description3, fixId53, fixAllDescription, command) {
|
|
147383
|
+
return createCodeFixActionWorker(fixName8, diagnosticToString(description3), changes, fixId53, diagnosticToString(fixAllDescription), command);
|
|
147268
147384
|
}
|
|
147269
|
-
function createCodeFixActionMaybeFixAll(fixName8, changes, description3,
|
|
147270
|
-
return createCodeFixActionWorker(fixName8, diagnosticToString(description3), changes,
|
|
147385
|
+
function createCodeFixActionMaybeFixAll(fixName8, changes, description3, fixId53, fixAllDescription, command) {
|
|
147386
|
+
return createCodeFixActionWorker(fixName8, diagnosticToString(description3), changes, fixId53, fixAllDescription && diagnosticToString(fixAllDescription), command);
|
|
147271
147387
|
}
|
|
147272
|
-
function createCodeFixActionWorker(fixName8, description3, changes,
|
|
147273
|
-
return { fixName: fixName8, description: description3, changes, fixId:
|
|
147388
|
+
function createCodeFixActionWorker(fixName8, description3, changes, fixId53, fixAllDescription, command) {
|
|
147389
|
+
return { fixName: fixName8, description: description3, changes, fixId: fixId53, fixAllDescription, commands: command ? [command] : void 0 };
|
|
147274
147390
|
}
|
|
147275
147391
|
function registerCodeFix(reg) {
|
|
147276
147392
|
for (const error2 of reg.errorCodes) {
|
|
@@ -147278,9 +147394,9 @@ function registerCodeFix(reg) {
|
|
|
147278
147394
|
errorCodeToFixes.add(String(error2), reg);
|
|
147279
147395
|
}
|
|
147280
147396
|
if (reg.fixIds) {
|
|
147281
|
-
for (const
|
|
147282
|
-
Debug.assert(!fixIdToRegistration.has(
|
|
147283
|
-
fixIdToRegistration.set(
|
|
147397
|
+
for (const fixId53 of reg.fixIds) {
|
|
147398
|
+
Debug.assert(!fixIdToRegistration.has(fixId53));
|
|
147399
|
+
fixIdToRegistration.set(fixId53, reg);
|
|
147284
147400
|
}
|
|
147285
147401
|
}
|
|
147286
147402
|
}
|
|
@@ -147289,17 +147405,17 @@ function getSupportedErrorCodes() {
|
|
|
147289
147405
|
return errorCodeToFixesArray ?? (errorCodeToFixesArray = arrayFrom(errorCodeToFixes.keys()));
|
|
147290
147406
|
}
|
|
147291
147407
|
function removeFixIdIfFixAllUnavailable(registration, diagnostics) {
|
|
147292
|
-
const { errorCodes:
|
|
147408
|
+
const { errorCodes: errorCodes66 } = registration;
|
|
147293
147409
|
let maybeFixableDiagnostics = 0;
|
|
147294
147410
|
for (const diag2 of diagnostics) {
|
|
147295
|
-
if (contains(
|
|
147411
|
+
if (contains(errorCodes66, diag2.code))
|
|
147296
147412
|
maybeFixableDiagnostics++;
|
|
147297
147413
|
if (maybeFixableDiagnostics > 1)
|
|
147298
147414
|
break;
|
|
147299
147415
|
}
|
|
147300
147416
|
const fixAllUnavailable = maybeFixableDiagnostics < 2;
|
|
147301
|
-
return ({ fixId:
|
|
147302
|
-
return fixAllUnavailable ? action : { ...action, fixId:
|
|
147417
|
+
return ({ fixId: fixId53, fixAllDescription, ...action }) => {
|
|
147418
|
+
return fixAllUnavailable ? action : { ...action, fixId: fixId53, fixAllDescription };
|
|
147303
147419
|
};
|
|
147304
147420
|
}
|
|
147305
147421
|
function getFixes(context) {
|
|
@@ -147316,14 +147432,14 @@ function createCombinedCodeActions(changes, commands) {
|
|
|
147316
147432
|
function createFileTextChanges(fileName, textChanges2) {
|
|
147317
147433
|
return { fileName, textChanges: textChanges2 };
|
|
147318
147434
|
}
|
|
147319
|
-
function codeFixAll(context,
|
|
147435
|
+
function codeFixAll(context, errorCodes66, use) {
|
|
147320
147436
|
const commands = [];
|
|
147321
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => eachDiagnostic(context,
|
|
147437
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => eachDiagnostic(context, errorCodes66, (diag2) => use(t, diag2, commands)));
|
|
147322
147438
|
return createCombinedCodeActions(changes, commands.length === 0 ? void 0 : commands);
|
|
147323
147439
|
}
|
|
147324
|
-
function eachDiagnostic(context,
|
|
147440
|
+
function eachDiagnostic(context, errorCodes66, cb) {
|
|
147325
147441
|
for (const diag2 of getDiagnostics(context)) {
|
|
147326
|
-
if (contains(
|
|
147442
|
+
if (contains(errorCodes66, diag2.code)) {
|
|
147327
147443
|
cb(diag2);
|
|
147328
147444
|
}
|
|
147329
147445
|
}
|
|
@@ -151734,10 +151850,10 @@ registerCodeFix({
|
|
|
151734
151850
|
const info = errorCodeFixIdMap[errorCode];
|
|
151735
151851
|
if (!info)
|
|
151736
151852
|
return emptyArray;
|
|
151737
|
-
const { descriptions, fixId:
|
|
151853
|
+
const { descriptions, fixId: fixId53, fixAllDescriptions } = info;
|
|
151738
151854
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (changes2) => dispatchChanges(changes2, context, errorCode, span.start));
|
|
151739
151855
|
return [
|
|
151740
|
-
createCodeFixActionMaybeFixAll(fixName, changes, descriptions,
|
|
151856
|
+
createCodeFixActionMaybeFixAll(fixName, changes, descriptions, fixId53, fixAllDescriptions)
|
|
151741
151857
|
];
|
|
151742
151858
|
},
|
|
151743
151859
|
fixIds: [fixName, fixAddOverrideId, fixRemoveOverrideId],
|
|
@@ -152542,7 +152658,7 @@ registerCodeFix({
|
|
|
152542
152658
|
},
|
|
152543
152659
|
fixIds: [fixMissingMember, fixMissingFunctionDeclaration, fixMissingProperties, fixMissingAttributes],
|
|
152544
152660
|
getAllCodeActions: (context) => {
|
|
152545
|
-
const { program, fixId:
|
|
152661
|
+
const { program, fixId: fixId53 } = context;
|
|
152546
152662
|
const checker = program.getTypeChecker();
|
|
152547
152663
|
const seen = /* @__PURE__ */ new Map();
|
|
152548
152664
|
const typeDeclToMembers = /* @__PURE__ */ new Map();
|
|
@@ -152552,11 +152668,11 @@ registerCodeFix({
|
|
|
152552
152668
|
if (!info || !addToSeen(seen, getNodeId(info.parentDeclaration) + "#" + (info.kind === 3 /* ObjectLiteral */ ? info.identifier : info.token.text))) {
|
|
152553
152669
|
return;
|
|
152554
152670
|
}
|
|
152555
|
-
if (
|
|
152671
|
+
if (fixId53 === fixMissingFunctionDeclaration && (info.kind === 2 /* Function */ || info.kind === 5 /* Signature */)) {
|
|
152556
152672
|
addFunctionDeclaration(changes, context, info);
|
|
152557
|
-
} else if (
|
|
152673
|
+
} else if (fixId53 === fixMissingProperties && info.kind === 3 /* ObjectLiteral */) {
|
|
152558
152674
|
addObjectLiteralProperties(changes, context, info);
|
|
152559
|
-
} else if (
|
|
152675
|
+
} else if (fixId53 === fixMissingAttributes && info.kind === 4 /* JsxAttributes */) {
|
|
152560
152676
|
addJsxAttributes(changes, context, info);
|
|
152561
152677
|
} else {
|
|
152562
152678
|
if (info.kind === 1 /* Enum */) {
|
|
@@ -154450,21 +154566,21 @@ registerCodeFix({
|
|
|
154450
154566
|
actions2.push(fix(type, fixIdNullable, Diagnostics.Change_all_jsdoc_style_types_to_TypeScript_and_add_undefined_to_nullable_types));
|
|
154451
154567
|
}
|
|
154452
154568
|
return actions2;
|
|
154453
|
-
function fix(type2,
|
|
154569
|
+
function fix(type2, fixId53, fixAllDescription) {
|
|
154454
154570
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange29(t, sourceFile, typeNode, type2, checker));
|
|
154455
|
-
return createCodeFixAction("jdocTypes", changes, [Diagnostics.Change_0_to_1, original, checker.typeToString(type2)],
|
|
154571
|
+
return createCodeFixAction("jdocTypes", changes, [Diagnostics.Change_0_to_1, original, checker.typeToString(type2)], fixId53, fixAllDescription);
|
|
154456
154572
|
}
|
|
154457
154573
|
},
|
|
154458
154574
|
fixIds: [fixIdPlain, fixIdNullable],
|
|
154459
154575
|
getAllCodeActions(context) {
|
|
154460
|
-
const { fixId:
|
|
154576
|
+
const { fixId: fixId53, program, sourceFile } = context;
|
|
154461
154577
|
const checker = program.getTypeChecker();
|
|
154462
154578
|
return codeFixAll(context, errorCodes45, (changes, err) => {
|
|
154463
154579
|
const info = getInfo15(err.file, err.start, checker);
|
|
154464
154580
|
if (!info)
|
|
154465
154581
|
return;
|
|
154466
154582
|
const { typeNode, type } = info;
|
|
154467
|
-
const fixedType = typeNode.kind === 314 /* JSDocNullableType */ &&
|
|
154583
|
+
const fixedType = typeNode.kind === 314 /* JSDocNullableType */ && fixId53 === fixIdNullable ? checker.getNullableType(type, 32768 /* Undefined */) : type;
|
|
154468
154584
|
doChange29(changes, sourceFile, typeNode, fixedType, checker);
|
|
154469
154585
|
});
|
|
154470
154586
|
}
|
|
@@ -157172,11 +157288,31 @@ function flattenInvalidBinaryExpr(node) {
|
|
|
157172
157288
|
}
|
|
157173
157289
|
}
|
|
157174
157290
|
|
|
157175
|
-
// src/services/codefixes/
|
|
157176
|
-
var fixId45 = "
|
|
157177
|
-
var errorCodes58 = [Diagnostics.
|
|
157291
|
+
// src/services/codefixes/wrapDecoratorInParentheses.ts
|
|
157292
|
+
var fixId45 = "wrapDecoratorInParentheses";
|
|
157293
|
+
var errorCodes58 = [Diagnostics.Expression_must_be_enclosed_in_parentheses_to_be_used_as_a_decorator.code];
|
|
157178
157294
|
registerCodeFix({
|
|
157179
157295
|
errorCodes: errorCodes58,
|
|
157296
|
+
getCodeActions: function getCodeActionsToWrapDecoratorExpressionInParentheses(context) {
|
|
157297
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => makeChange10(t, context.sourceFile, context.span.start));
|
|
157298
|
+
return [createCodeFixAction(fixId45, changes, Diagnostics.Wrap_in_parentheses, fixId45, Diagnostics.Wrap_all_invalid_decorator_expressions_in_parentheses)];
|
|
157299
|
+
},
|
|
157300
|
+
fixIds: [fixId45],
|
|
157301
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes58, (changes, diag2) => makeChange10(changes, diag2.file, diag2.start))
|
|
157302
|
+
});
|
|
157303
|
+
function makeChange10(changeTracker, sourceFile, pos) {
|
|
157304
|
+
const token = getTokenAtPosition(sourceFile, pos);
|
|
157305
|
+
const decorator = findAncestor(token, isDecorator);
|
|
157306
|
+
Debug.assert(!!decorator, "Expected position to be owned by a decorator.");
|
|
157307
|
+
const replacement = factory.createParenthesizedExpression(decorator.expression);
|
|
157308
|
+
changeTracker.replaceNode(sourceFile, decorator.expression, replacement);
|
|
157309
|
+
}
|
|
157310
|
+
|
|
157311
|
+
// src/services/codefixes/convertToMappedObjectType.ts
|
|
157312
|
+
var fixId46 = "fixConvertToMappedObjectType";
|
|
157313
|
+
var errorCodes59 = [Diagnostics.An_index_signature_parameter_type_cannot_be_a_literal_type_or_generic_type_Consider_using_a_mapped_object_type_instead.code];
|
|
157314
|
+
registerCodeFix({
|
|
157315
|
+
errorCodes: errorCodes59,
|
|
157180
157316
|
getCodeActions: function getCodeActionsToConvertToMappedTypeObject(context) {
|
|
157181
157317
|
const { sourceFile, span } = context;
|
|
157182
157318
|
const info = getInfo20(sourceFile, span.start);
|
|
@@ -157184,10 +157320,10 @@ registerCodeFix({
|
|
|
157184
157320
|
return void 0;
|
|
157185
157321
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange39(t, sourceFile, info));
|
|
157186
157322
|
const name = idText(info.container.name);
|
|
157187
|
-
return [createCodeFixAction(
|
|
157323
|
+
return [createCodeFixAction(fixId46, changes, [Diagnostics.Convert_0_to_mapped_object_type, name], fixId46, [Diagnostics.Convert_0_to_mapped_object_type, name])];
|
|
157188
157324
|
},
|
|
157189
|
-
fixIds: [
|
|
157190
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
157325
|
+
fixIds: [fixId46],
|
|
157326
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes59, (changes, diag2) => {
|
|
157191
157327
|
const info = getInfo20(diag2.file, diag2.start);
|
|
157192
157328
|
if (info)
|
|
157193
157329
|
doChange39(changes, diag2.file, info);
|
|
@@ -157235,12 +157371,12 @@ function doChange39(changes, sourceFile, { indexSignature, container }) {
|
|
|
157235
157371
|
}
|
|
157236
157372
|
|
|
157237
157373
|
// src/services/codefixes/removeAccidentalCallParentheses.ts
|
|
157238
|
-
var
|
|
157239
|
-
var
|
|
157374
|
+
var fixId47 = "removeAccidentalCallParentheses";
|
|
157375
|
+
var errorCodes60 = [
|
|
157240
157376
|
Diagnostics.This_expression_is_not_callable_because_it_is_a_get_accessor_Did_you_mean_to_use_it_without.code
|
|
157241
157377
|
];
|
|
157242
157378
|
registerCodeFix({
|
|
157243
|
-
errorCodes:
|
|
157379
|
+
errorCodes: errorCodes60,
|
|
157244
157380
|
getCodeActions(context) {
|
|
157245
157381
|
const callExpression = findAncestor(getTokenAtPosition(context.sourceFile, context.span.start), isCallExpression);
|
|
157246
157382
|
if (!callExpression) {
|
|
@@ -157249,30 +157385,30 @@ registerCodeFix({
|
|
|
157249
157385
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => {
|
|
157250
157386
|
t.deleteRange(context.sourceFile, { pos: callExpression.expression.end, end: callExpression.end });
|
|
157251
157387
|
});
|
|
157252
|
-
return [createCodeFixActionWithoutFixAll(
|
|
157388
|
+
return [createCodeFixActionWithoutFixAll(fixId47, changes, Diagnostics.Remove_parentheses)];
|
|
157253
157389
|
},
|
|
157254
|
-
fixIds: [
|
|
157390
|
+
fixIds: [fixId47]
|
|
157255
157391
|
});
|
|
157256
157392
|
|
|
157257
157393
|
// src/services/codefixes/removeUnnecessaryAwait.ts
|
|
157258
|
-
var
|
|
157259
|
-
var
|
|
157394
|
+
var fixId48 = "removeUnnecessaryAwait";
|
|
157395
|
+
var errorCodes61 = [
|
|
157260
157396
|
Diagnostics.await_has_no_effect_on_the_type_of_this_expression.code
|
|
157261
157397
|
];
|
|
157262
157398
|
registerCodeFix({
|
|
157263
|
-
errorCodes:
|
|
157399
|
+
errorCodes: errorCodes61,
|
|
157264
157400
|
getCodeActions: function getCodeActionsToRemoveUnnecessaryAwait(context) {
|
|
157265
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
157401
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => makeChange11(t, context.sourceFile, context.span));
|
|
157266
157402
|
if (changes.length > 0) {
|
|
157267
|
-
return [createCodeFixAction(
|
|
157403
|
+
return [createCodeFixAction(fixId48, changes, Diagnostics.Remove_unnecessary_await, fixId48, Diagnostics.Remove_all_unnecessary_uses_of_await)];
|
|
157268
157404
|
}
|
|
157269
157405
|
},
|
|
157270
|
-
fixIds: [
|
|
157406
|
+
fixIds: [fixId48],
|
|
157271
157407
|
getAllCodeActions: (context) => {
|
|
157272
|
-
return codeFixAll(context,
|
|
157408
|
+
return codeFixAll(context, errorCodes61, (changes, diag2) => makeChange11(changes, diag2.file, diag2));
|
|
157273
157409
|
}
|
|
157274
157410
|
});
|
|
157275
|
-
function
|
|
157411
|
+
function makeChange11(changeTracker, sourceFile, span) {
|
|
157276
157412
|
const awaitKeyword = tryCast(getTokenAtPosition(sourceFile, span.start), (node) => node.kind === 135 /* AwaitKeyword */);
|
|
157277
157413
|
const awaitExpression = awaitKeyword && tryCast(awaitKeyword.parent, isAwaitExpression);
|
|
157278
157414
|
if (!awaitExpression) {
|
|
@@ -157297,20 +157433,20 @@ function makeChange10(changeTracker, sourceFile, span) {
|
|
|
157297
157433
|
}
|
|
157298
157434
|
|
|
157299
157435
|
// src/services/codefixes/splitTypeOnlyImport.ts
|
|
157300
|
-
var
|
|
157301
|
-
var
|
|
157436
|
+
var errorCodes62 = [Diagnostics.A_type_only_import_can_specify_a_default_import_or_named_bindings_but_not_both.code];
|
|
157437
|
+
var fixId49 = "splitTypeOnlyImport";
|
|
157302
157438
|
registerCodeFix({
|
|
157303
|
-
errorCodes:
|
|
157304
|
-
fixIds: [
|
|
157439
|
+
errorCodes: errorCodes62,
|
|
157440
|
+
fixIds: [fixId49],
|
|
157305
157441
|
getCodeActions: function getCodeActionsToSplitTypeOnlyImport(context) {
|
|
157306
157442
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => {
|
|
157307
157443
|
return splitTypeOnlyImport(t, getImportDeclaration2(context.sourceFile, context.span), context);
|
|
157308
157444
|
});
|
|
157309
157445
|
if (changes.length) {
|
|
157310
|
-
return [createCodeFixAction(
|
|
157446
|
+
return [createCodeFixAction(fixId49, changes, Diagnostics.Split_into_two_separate_import_declarations, fixId49, Diagnostics.Split_all_invalid_type_only_imports)];
|
|
157311
157447
|
}
|
|
157312
157448
|
},
|
|
157313
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
157449
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes62, (changes, error2) => {
|
|
157314
157450
|
splitTypeOnlyImport(changes, getImportDeclaration2(context.sourceFile, error2), context);
|
|
157315
157451
|
})
|
|
157316
157452
|
});
|
|
@@ -157359,23 +157495,23 @@ function splitTypeOnlyImport(changes, importDeclaration, context) {
|
|
|
157359
157495
|
}
|
|
157360
157496
|
|
|
157361
157497
|
// src/services/codefixes/convertConstToLet.ts
|
|
157362
|
-
var
|
|
157363
|
-
var
|
|
157498
|
+
var fixId50 = "fixConvertConstToLet";
|
|
157499
|
+
var errorCodes63 = [Diagnostics.Cannot_assign_to_0_because_it_is_a_constant.code];
|
|
157364
157500
|
registerCodeFix({
|
|
157365
|
-
errorCodes:
|
|
157501
|
+
errorCodes: errorCodes63,
|
|
157366
157502
|
getCodeActions: function getCodeActionsToConvertConstToLet(context) {
|
|
157367
157503
|
const { sourceFile, span, program } = context;
|
|
157368
157504
|
const info = getInfo21(sourceFile, span.start, program);
|
|
157369
157505
|
if (info === void 0)
|
|
157370
157506
|
return;
|
|
157371
157507
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange40(t, sourceFile, info.token));
|
|
157372
|
-
return [createCodeFixActionMaybeFixAll(
|
|
157508
|
+
return [createCodeFixActionMaybeFixAll(fixId50, changes, Diagnostics.Convert_const_to_let, fixId50, Diagnostics.Convert_all_const_to_let)];
|
|
157373
157509
|
},
|
|
157374
157510
|
getAllCodeActions: (context) => {
|
|
157375
157511
|
const { program } = context;
|
|
157376
157512
|
const seen = /* @__PURE__ */ new Map();
|
|
157377
157513
|
return createCombinedCodeActions(ts_textChanges_exports.ChangeTracker.with(context, (changes) => {
|
|
157378
|
-
eachDiagnostic(context,
|
|
157514
|
+
eachDiagnostic(context, errorCodes63, (diag2) => {
|
|
157379
157515
|
const info = getInfo21(diag2.file, diag2.start, program);
|
|
157380
157516
|
if (info) {
|
|
157381
157517
|
if (addToSeen(seen, getSymbolId(info.symbol))) {
|
|
@@ -157386,7 +157522,7 @@ registerCodeFix({
|
|
|
157386
157522
|
});
|
|
157387
157523
|
}));
|
|
157388
157524
|
},
|
|
157389
|
-
fixIds: [
|
|
157525
|
+
fixIds: [fixId50]
|
|
157390
157526
|
});
|
|
157391
157527
|
function getInfo21(sourceFile, pos, program) {
|
|
157392
157528
|
var _a;
|
|
@@ -157407,11 +157543,11 @@ function doChange40(changes, sourceFile, token) {
|
|
|
157407
157543
|
}
|
|
157408
157544
|
|
|
157409
157545
|
// src/services/codefixes/fixExpectedComma.ts
|
|
157410
|
-
var
|
|
157546
|
+
var fixId51 = "fixExpectedComma";
|
|
157411
157547
|
var expectedErrorCode = Diagnostics._0_expected.code;
|
|
157412
|
-
var
|
|
157548
|
+
var errorCodes64 = [expectedErrorCode];
|
|
157413
157549
|
registerCodeFix({
|
|
157414
|
-
errorCodes:
|
|
157550
|
+
errorCodes: errorCodes64,
|
|
157415
157551
|
getCodeActions(context) {
|
|
157416
157552
|
const { sourceFile } = context;
|
|
157417
157553
|
const info = getInfo22(sourceFile, context.span.start, context.errorCode);
|
|
@@ -157419,15 +157555,15 @@ registerCodeFix({
|
|
|
157419
157555
|
return void 0;
|
|
157420
157556
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange41(t, sourceFile, info));
|
|
157421
157557
|
return [createCodeFixAction(
|
|
157422
|
-
|
|
157558
|
+
fixId51,
|
|
157423
157559
|
changes,
|
|
157424
157560
|
[Diagnostics.Change_0_to_1, ";", ","],
|
|
157425
|
-
|
|
157561
|
+
fixId51,
|
|
157426
157562
|
[Diagnostics.Change_0_to_1, ";", ","]
|
|
157427
157563
|
)];
|
|
157428
157564
|
},
|
|
157429
|
-
fixIds: [
|
|
157430
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
157565
|
+
fixIds: [fixId51],
|
|
157566
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes64, (changes, diag2) => {
|
|
157431
157567
|
const info = getInfo22(diag2.file, diag2.start, diag2.code);
|
|
157432
157568
|
if (info)
|
|
157433
157569
|
doChange41(changes, context.sourceFile, info);
|
|
@@ -157444,25 +157580,25 @@ function doChange41(changes, sourceFile, { node }) {
|
|
|
157444
157580
|
|
|
157445
157581
|
// src/services/codefixes/fixAddVoidToPromise.ts
|
|
157446
157582
|
var fixName7 = "addVoidToPromise";
|
|
157447
|
-
var
|
|
157448
|
-
var
|
|
157583
|
+
var fixId52 = "addVoidToPromise";
|
|
157584
|
+
var errorCodes65 = [
|
|
157449
157585
|
Diagnostics.Expected_1_argument_but_got_0_new_Promise_needs_a_JSDoc_hint_to_produce_a_resolve_that_can_be_called_without_arguments.code,
|
|
157450
157586
|
Diagnostics.Expected_0_arguments_but_got_1_Did_you_forget_to_include_void_in_your_type_argument_to_Promise.code
|
|
157451
157587
|
];
|
|
157452
157588
|
registerCodeFix({
|
|
157453
|
-
errorCodes:
|
|
157454
|
-
fixIds: [
|
|
157589
|
+
errorCodes: errorCodes65,
|
|
157590
|
+
fixIds: [fixId52],
|
|
157455
157591
|
getCodeActions(context) {
|
|
157456
|
-
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) =>
|
|
157592
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => makeChange12(t, context.sourceFile, context.span, context.program));
|
|
157457
157593
|
if (changes.length > 0) {
|
|
157458
|
-
return [createCodeFixAction(fixName7, changes, Diagnostics.Add_void_to_Promise_resolved_without_a_value,
|
|
157594
|
+
return [createCodeFixAction(fixName7, changes, Diagnostics.Add_void_to_Promise_resolved_without_a_value, fixId52, Diagnostics.Add_void_to_all_Promises_resolved_without_a_value)];
|
|
157459
157595
|
}
|
|
157460
157596
|
},
|
|
157461
157597
|
getAllCodeActions(context) {
|
|
157462
|
-
return codeFixAll(context,
|
|
157598
|
+
return codeFixAll(context, errorCodes65, (changes, diag2) => makeChange12(changes, diag2.file, diag2, context.program, /* @__PURE__ */ new Set()));
|
|
157463
157599
|
}
|
|
157464
157600
|
});
|
|
157465
|
-
function
|
|
157601
|
+
function makeChange12(changes, sourceFile, span, program, seen) {
|
|
157466
157602
|
const node = getTokenAtPosition(sourceFile, span.start);
|
|
157467
157603
|
if (!isIdentifier(node) || !isCallExpression(node.parent) || node.parent.expression !== node || node.parent.arguments.length !== 0)
|
|
157468
157604
|
return;
|
|
@@ -173293,6 +173429,7 @@ __export(ts_exports2, {
|
|
|
173293
173429
|
JsxEmit: () => JsxEmit,
|
|
173294
173430
|
JsxFlags: () => JsxFlags,
|
|
173295
173431
|
JsxReferenceKind: () => JsxReferenceKind,
|
|
173432
|
+
LanguageFeatureMinimumTarget: () => LanguageFeatureMinimumTarget,
|
|
173296
173433
|
LanguageServiceMode: () => LanguageServiceMode,
|
|
173297
173434
|
LanguageVariant: () => LanguageVariant,
|
|
173298
173435
|
LexicalEnvironmentFlags: () => LexicalEnvironmentFlags,
|
|
@@ -185949,10 +186086,10 @@ ${e.message}`;
|
|
|
185949
186086
|
}
|
|
185950
186087
|
return simplifiedResult ? codeActions.map((codeAction) => this.mapCodeFixAction(codeAction)) : codeActions;
|
|
185951
186088
|
}
|
|
185952
|
-
getCombinedCodeFix({ scope, fixId:
|
|
186089
|
+
getCombinedCodeFix({ scope, fixId: fixId53 }, simplifiedResult) {
|
|
185953
186090
|
Debug.assert(scope.type === "file");
|
|
185954
186091
|
const { file, project } = this.getFileAndProject(scope.args);
|
|
185955
|
-
const res = project.getLanguageService().getCombinedCodeFix({ type: "file", fileName: file },
|
|
186092
|
+
const res = project.getLanguageService().getCombinedCodeFix({ type: "file", fileName: file }, fixId53, this.getFormatOptions(file), this.getPreferences(file));
|
|
185956
186093
|
if (simplifiedResult) {
|
|
185957
186094
|
return { changes: this.mapTextChangesToCodeEdits(res.changes), commands: res.commands };
|
|
185958
186095
|
} else {
|
|
@@ -185991,8 +186128,8 @@ ${e.message}`;
|
|
|
185991
186128
|
mapCodeAction({ description: description3, changes, commands }) {
|
|
185992
186129
|
return { description: description3, changes: this.mapTextChangesToCodeEdits(changes), commands };
|
|
185993
186130
|
}
|
|
185994
|
-
mapCodeFixAction({ fixName: fixName8, description: description3, changes, commands, fixId:
|
|
185995
|
-
return { fixName: fixName8, description: description3, changes: this.mapTextChangesToCodeEdits(changes), commands, fixId:
|
|
186131
|
+
mapCodeFixAction({ fixName: fixName8, description: description3, changes, commands, fixId: fixId53, fixAllDescription }) {
|
|
186132
|
+
return { fixName: fixName8, description: description3, changes: this.mapTextChangesToCodeEdits(changes), commands, fixId: fixId53, fixAllDescription };
|
|
185996
186133
|
}
|
|
185997
186134
|
mapTextChangesToCodeEdits(textChanges2) {
|
|
185998
186135
|
return textChanges2.map((change) => this.mapTextChangeToCodeEdit(change));
|
|
@@ -187493,6 +187630,7 @@ if (typeof console !== "undefined") {
|
|
|
187493
187630
|
JsxEmit,
|
|
187494
187631
|
JsxFlags,
|
|
187495
187632
|
JsxReferenceKind,
|
|
187633
|
+
LanguageFeatureMinimumTarget,
|
|
187496
187634
|
LanguageServiceMode,
|
|
187497
187635
|
LanguageVariant,
|
|
187498
187636
|
LexicalEnvironmentFlags,
|