@typescript-deploys/pr-build 5.5.0-pr-57267-12 → 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 +147 -64
- package/lib/tsserver.js +601 -428
- package/lib/typescript.d.ts +1 -2
- package/lib/typescript.js +601 -428
- package/lib/typingsInstaller.js +5 -1
- package/package.json +2 -2
package/lib/tsserver.js
CHANGED
|
@@ -106,6 +106,7 @@ __export(server_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,
|
|
@@ -161,6 +162,7 @@ __export(server_exports, {
|
|
|
161
162
|
SignatureKind: () => SignatureKind,
|
|
162
163
|
SmartSelectionRange: () => ts_SmartSelectionRange_exports,
|
|
163
164
|
SnippetKind: () => SnippetKind,
|
|
165
|
+
SortKind: () => SortKind,
|
|
164
166
|
StructureIsReused: () => StructureIsReused,
|
|
165
167
|
SymbolAccessibility: () => SymbolAccessibility,
|
|
166
168
|
SymbolDisplay: () => ts_SymbolDisplay_exports,
|
|
@@ -495,6 +497,7 @@ __export(server_exports, {
|
|
|
495
497
|
defaultIncludeSpec: () => defaultIncludeSpec,
|
|
496
498
|
defaultInitCompilerOptions: () => defaultInitCompilerOptions,
|
|
497
499
|
defaultMaximumTruncationLength: () => defaultMaximumTruncationLength,
|
|
500
|
+
detectSortCaseSensitivity: () => detectSortCaseSensitivity,
|
|
498
501
|
diagnosticCategoryName: () => diagnosticCategoryName,
|
|
499
502
|
diagnosticToString: () => diagnosticToString,
|
|
500
503
|
directoryProbablyExists: () => directoryProbablyExists,
|
|
@@ -2323,7 +2326,7 @@ module.exports = __toCommonJS(server_exports);
|
|
|
2323
2326
|
|
|
2324
2327
|
// src/compiler/corePublic.ts
|
|
2325
2328
|
var versionMajorMinor = "5.5";
|
|
2326
|
-
var version = `${versionMajorMinor}.0-insiders.
|
|
2329
|
+
var version = `${versionMajorMinor}.0-insiders.20240312`;
|
|
2327
2330
|
var Comparison = /* @__PURE__ */ ((Comparison3) => {
|
|
2328
2331
|
Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
|
|
2329
2332
|
Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
|
|
@@ -2872,6 +2875,30 @@ function arrayIsSorted(array, comparer) {
|
|
|
2872
2875
|
}
|
|
2873
2876
|
return true;
|
|
2874
2877
|
}
|
|
2878
|
+
var SortKind = /* @__PURE__ */ ((SortKind2) => {
|
|
2879
|
+
SortKind2[SortKind2["None"] = 0] = "None";
|
|
2880
|
+
SortKind2[SortKind2["CaseSensitive"] = 1] = "CaseSensitive";
|
|
2881
|
+
SortKind2[SortKind2["CaseInsensitive"] = 2] = "CaseInsensitive";
|
|
2882
|
+
SortKind2[SortKind2["Both"] = 3] = "Both";
|
|
2883
|
+
return SortKind2;
|
|
2884
|
+
})(SortKind || {});
|
|
2885
|
+
function detectSortCaseSensitivity(array, getString, compareStringsCaseSensitive2, compareStringsCaseInsensitive2) {
|
|
2886
|
+
let kind = 3 /* Both */;
|
|
2887
|
+
if (array.length < 2)
|
|
2888
|
+
return kind;
|
|
2889
|
+
let prevElement = getString(array[0]);
|
|
2890
|
+
for (let i = 1, len = array.length; i < len && kind !== 0 /* None */; i++) {
|
|
2891
|
+
const element = getString(array[i]);
|
|
2892
|
+
if (kind & 1 /* CaseSensitive */ && compareStringsCaseSensitive2(prevElement, element) > 0) {
|
|
2893
|
+
kind &= ~1 /* CaseSensitive */;
|
|
2894
|
+
}
|
|
2895
|
+
if (kind & 2 /* CaseInsensitive */ && compareStringsCaseInsensitive2(prevElement, element) > 0) {
|
|
2896
|
+
kind &= ~2 /* CaseInsensitive */;
|
|
2897
|
+
}
|
|
2898
|
+
prevElement = element;
|
|
2899
|
+
}
|
|
2900
|
+
return kind;
|
|
2901
|
+
}
|
|
2875
2902
|
function arrayIsEqualTo(array1, array2, equalityComparer = equateValues) {
|
|
2876
2903
|
if (!array1 || !array2) {
|
|
2877
2904
|
return array1 === array2;
|
|
@@ -3606,7 +3633,7 @@ var createUIStringComparer = /* @__PURE__ */ (() => {
|
|
|
3606
3633
|
return value < 0 ? -1 /* LessThan */ : value > 0 ? 1 /* GreaterThan */ : 0 /* EqualTo */;
|
|
3607
3634
|
}
|
|
3608
3635
|
function createIntlCollatorStringComparer(locale) {
|
|
3609
|
-
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;
|
|
3610
3637
|
return (a, b) => compareWithCallback(a, b, comparer);
|
|
3611
3638
|
}
|
|
3612
3639
|
})();
|
|
@@ -7207,6 +7234,38 @@ var InternalEmitFlags = /* @__PURE__ */ ((InternalEmitFlags3) => {
|
|
|
7207
7234
|
InternalEmitFlags3[InternalEmitFlags3["TransformPrivateStaticElements"] = 32] = "TransformPrivateStaticElements";
|
|
7208
7235
|
return InternalEmitFlags3;
|
|
7209
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 || {});
|
|
7210
7269
|
var ExternalEmitHelpers = /* @__PURE__ */ ((ExternalEmitHelpers2) => {
|
|
7211
7270
|
ExternalEmitHelpers2[ExternalEmitHelpers2["Extends"] = 1] = "Extends";
|
|
7212
7271
|
ExternalEmitHelpers2[ExternalEmitHelpers2["Assign"] = 2] = "Assign";
|
|
@@ -9616,6 +9675,8 @@ var Diagnostics = {
|
|
|
9616
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."),
|
|
9617
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."),
|
|
9618
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."),
|
|
9619
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."),
|
|
9620
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."),
|
|
9621
9682
|
Call_signature_return_types_0_and_1_are_incompatible: diag(
|
|
@@ -11263,6 +11324,8 @@ var Diagnostics = {
|
|
|
11263
11324
|
Add_optional_parameter_to_0: diag(95191, 3 /* Message */, "Add_optional_parameter_to_0_95191", "Add optional parameter to '{0}'"),
|
|
11264
11325
|
Add_optional_parameters_to_0: diag(95192, 3 /* Message */, "Add_optional_parameters_to_0_95192", "Add optional parameters to '{0}'"),
|
|
11265
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"),
|
|
11266
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."),
|
|
11267
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'."),
|
|
11268
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?"),
|
|
@@ -21771,7 +21834,7 @@ function hasTabstop(node) {
|
|
|
21771
21834
|
}
|
|
21772
21835
|
function isJSDocOptionalParameter(node) {
|
|
21773
21836
|
return isInJSFile(node) && // node.type should only be a JSDocOptionalType when node is a parameter of a JSDocFunctionType
|
|
21774
|
-
(node.type && node.type.kind === 316 /* JSDocOptionalType */ || getJSDocParameterTags(node).some(
|
|
21837
|
+
(node.type && node.type.kind === 316 /* JSDocOptionalType */ || getJSDocParameterTags(node).some(isOptionalJSDocPropertyLikeTag));
|
|
21775
21838
|
}
|
|
21776
21839
|
function isOptionalDeclaration(declaration) {
|
|
21777
21840
|
switch (declaration.kind) {
|
|
@@ -48872,8 +48935,6 @@ function createTypeChecker(host) {
|
|
|
48872
48935
|
var comparableRelation = /* @__PURE__ */ new Map();
|
|
48873
48936
|
var identityRelation = /* @__PURE__ */ new Map();
|
|
48874
48937
|
var enumRelation = /* @__PURE__ */ new Map();
|
|
48875
|
-
var builtinGlobals = createSymbolTable();
|
|
48876
|
-
builtinGlobals.set(undefinedSymbol.escapedName, undefinedSymbol);
|
|
48877
48938
|
var suggestedExtensions = [
|
|
48878
48939
|
[".mts", ".mjs"],
|
|
48879
48940
|
[".ts", ".js"],
|
|
@@ -49291,17 +49352,17 @@ function createTypeChecker(host) {
|
|
|
49291
49352
|
}
|
|
49292
49353
|
}
|
|
49293
49354
|
}
|
|
49294
|
-
function
|
|
49295
|
-
|
|
49296
|
-
|
|
49297
|
-
|
|
49298
|
-
|
|
49299
|
-
|
|
49300
|
-
|
|
49301
|
-
|
|
49302
|
-
|
|
49303
|
-
|
|
49304
|
-
|
|
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);
|
|
49305
49366
|
}
|
|
49306
49367
|
}
|
|
49307
49368
|
function getSymbolLinks(symbol) {
|
|
@@ -49371,7 +49432,14 @@ function createTypeChecker(host) {
|
|
|
49371
49432
|
} else if (declaration.kind === 260 /* VariableDeclaration */) {
|
|
49372
49433
|
return !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage);
|
|
49373
49434
|
} else if (isClassLike(declaration)) {
|
|
49374
|
-
|
|
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;
|
|
49375
49443
|
} else if (isPropertyDeclaration(declaration)) {
|
|
49376
49444
|
return !isPropertyImmediatelyReferencedWithinDeclaration(
|
|
49377
49445
|
declaration,
|
|
@@ -60044,10 +60112,16 @@ function createTypeChecker(host) {
|
|
|
60044
60112
|
const symbol = getSymbol2(globals, '"' + moduleName + '"', 512 /* ValueModule */);
|
|
60045
60113
|
return symbol && withAugmentations ? getMergedSymbol(symbol) : symbol;
|
|
60046
60114
|
}
|
|
60115
|
+
function hasEffectiveQuestionToken(node) {
|
|
60116
|
+
return hasQuestionToken(node) || isOptionalJSDocPropertyLikeTag(node) || isParameter(node) && isJSDocOptionalParameter(node);
|
|
60117
|
+
}
|
|
60047
60118
|
function isOptionalParameter(node) {
|
|
60048
|
-
if (
|
|
60119
|
+
if (hasEffectiveQuestionToken(node)) {
|
|
60049
60120
|
return true;
|
|
60050
60121
|
}
|
|
60122
|
+
if (!isParameter(node)) {
|
|
60123
|
+
return false;
|
|
60124
|
+
}
|
|
60051
60125
|
if (node.initializer) {
|
|
60052
60126
|
const signature = getSignatureFromDeclaration(node.parent);
|
|
60053
60127
|
const parameterIndex = node.parent.parameters.indexOf(node);
|
|
@@ -60147,7 +60221,7 @@ function createTypeChecker(host) {
|
|
|
60147
60221
|
if (type && type.kind === 201 /* LiteralType */) {
|
|
60148
60222
|
flags |= 2 /* HasLiteralTypes */;
|
|
60149
60223
|
}
|
|
60150
|
-
const isOptionalParameter2 =
|
|
60224
|
+
const isOptionalParameter2 = hasEffectiveQuestionToken(param) || isParameter(param) && param.initializer || isRestParameter(param) || iife && parameters.length > iife.arguments.length && !type;
|
|
60151
60225
|
if (!isOptionalParameter2) {
|
|
60152
60226
|
minArgumentCount = parameters.length;
|
|
60153
60227
|
}
|
|
@@ -65265,7 +65339,7 @@ function createTypeChecker(host) {
|
|
|
65265
65339
|
if (reduced !== type) {
|
|
65266
65340
|
return reduced;
|
|
65267
65341
|
}
|
|
65268
|
-
if (type.flags & 2097152 /* Intersection */ &&
|
|
65342
|
+
if (type.flags & 2097152 /* Intersection */ && shouldNormalizeIntersection(type)) {
|
|
65269
65343
|
const normalizedTypes = sameMap(type.types, (t) => getNormalizedType(t, writing));
|
|
65270
65344
|
if (normalizedTypes !== type.types) {
|
|
65271
65345
|
return getIntersectionType(normalizedTypes);
|
|
@@ -65273,6 +65347,17 @@ function createTypeChecker(host) {
|
|
|
65273
65347
|
}
|
|
65274
65348
|
return type;
|
|
65275
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
|
+
}
|
|
65276
65361
|
function getNormalizedTupleType(type, writing) {
|
|
65277
65362
|
const elements = getElementTypes(type);
|
|
65278
65363
|
const normalizedElements = sameMap(elements, (t) => t.flags & 25165824 /* Simplifiable */ ? getSimplifiedType(t, writing) : t);
|
|
@@ -70123,9 +70208,9 @@ function createTypeChecker(host) {
|
|
|
70123
70208
|
if (strictNullChecks) {
|
|
70124
70209
|
switch (facts) {
|
|
70125
70210
|
case 524288 /* NEUndefined */:
|
|
70126
|
-
return
|
|
70211
|
+
return removeNullableByIntersection(reduced, 65536 /* EQUndefined */, 131072 /* EQNull */, 33554432 /* IsNull */, nullType);
|
|
70127
70212
|
case 1048576 /* NENull */:
|
|
70128
|
-
return
|
|
70213
|
+
return removeNullableByIntersection(reduced, 131072 /* EQNull */, 65536 /* EQUndefined */, 16777216 /* IsUndefined */, undefinedType);
|
|
70129
70214
|
case 2097152 /* NEUndefinedOrNull */:
|
|
70130
70215
|
case 4194304 /* Truthy */:
|
|
70131
70216
|
return mapType(reduced, (t) => hasTypeFacts(t, 262144 /* EQUndefinedOrNull */) ? getGlobalNonNullableTypeInstantiation(t) : t);
|
|
@@ -70133,6 +70218,14 @@ function createTypeChecker(host) {
|
|
|
70133
70218
|
}
|
|
70134
70219
|
return reduced;
|
|
70135
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
|
+
}
|
|
70136
70229
|
function recombineUnknownType(type) {
|
|
70137
70230
|
return type === unknownUnionType ? unknownType : type;
|
|
70138
70231
|
}
|
|
@@ -73700,7 +73793,7 @@ function createTypeChecker(host) {
|
|
|
73700
73793
|
}
|
|
73701
73794
|
}
|
|
73702
73795
|
function checkSpreadExpression(node, checkMode) {
|
|
73703
|
-
if (languageVersion < 2 /*
|
|
73796
|
+
if (languageVersion < 2 /* SpreadElements */) {
|
|
73704
73797
|
checkExternalEmitHelpers(node, compilerOptions.downlevelIteration ? 1536 /* SpreadIncludes */ : 1024 /* SpreadArray */);
|
|
73705
73798
|
}
|
|
73706
73799
|
const arrayOrIterableType = checkExpression(node.expression, checkMode);
|
|
@@ -73734,7 +73827,7 @@ function createTypeChecker(host) {
|
|
|
73734
73827
|
for (let i = 0; i < elementCount; i++) {
|
|
73735
73828
|
const e = elements[i];
|
|
73736
73829
|
if (e.kind === 230 /* SpreadElement */) {
|
|
73737
|
-
if (languageVersion < 2 /*
|
|
73830
|
+
if (languageVersion < 2 /* SpreadElements */) {
|
|
73738
73831
|
checkExternalEmitHelpers(e, compilerOptions.downlevelIteration ? 1536 /* SpreadIncludes */ : 1024 /* SpreadArray */);
|
|
73739
73832
|
}
|
|
73740
73833
|
const spreadType = checkExpression(e.expression, checkMode, forceTuple);
|
|
@@ -73964,7 +74057,7 @@ function createTypeChecker(host) {
|
|
|
73964
74057
|
addIntraExpressionInferenceSite(inferenceContext, inferenceNode, type);
|
|
73965
74058
|
}
|
|
73966
74059
|
} else if (memberDecl.kind === 305 /* SpreadAssignment */) {
|
|
73967
|
-
if (languageVersion < 2 /*
|
|
74060
|
+
if (languageVersion < 2 /* ObjectAssign */) {
|
|
73968
74061
|
checkExternalEmitHelpers(memberDecl, 2 /* Assign */);
|
|
73969
74062
|
}
|
|
73970
74063
|
if (propertiesArray.length > 0) {
|
|
@@ -74989,7 +75082,7 @@ function createTypeChecker(host) {
|
|
|
74989
75082
|
const isAnyLike = isTypeAny(apparentType) || apparentType === silentNeverType;
|
|
74990
75083
|
let prop;
|
|
74991
75084
|
if (isPrivateIdentifier(right)) {
|
|
74992
|
-
if (languageVersion < 99 /*
|
|
75085
|
+
if (languageVersion < 9 /* PrivateNamesAndClassStaticBlocks */ || languageVersion < 99 /* ClassAndClassElementDecorators */ || !useDefineForClassFields) {
|
|
74993
75086
|
if (assignmentKind !== 0 /* None */) {
|
|
74994
75087
|
checkExternalEmitHelpers(node, 1048576 /* ClassPrivateFieldSet */);
|
|
74995
75088
|
}
|
|
@@ -76816,7 +76909,7 @@ function createTypeChecker(host) {
|
|
|
76816
76909
|
}
|
|
76817
76910
|
return resolveErrorCall(node);
|
|
76818
76911
|
}
|
|
76819
|
-
if (checkMode & 8 /* SkipGenericFunctions */ && !node.typeArguments && callSignatures.some(
|
|
76912
|
+
if (checkMode & 8 /* SkipGenericFunctions */ && !node.typeArguments && callSignatures.some(isGenericFunctionReturningFunction)) {
|
|
76820
76913
|
skippedGenericFunction(node, checkMode);
|
|
76821
76914
|
return resolvingSignature;
|
|
76822
76915
|
}
|
|
@@ -76826,12 +76919,8 @@ function createTypeChecker(host) {
|
|
|
76826
76919
|
}
|
|
76827
76920
|
return resolveCall(node, callSignatures, candidatesOutArray, checkMode, callChainFlags);
|
|
76828
76921
|
}
|
|
76829
|
-
function
|
|
76830
|
-
|
|
76831
|
-
return false;
|
|
76832
|
-
}
|
|
76833
|
-
const returnType = getReturnTypeOfSignature(signature);
|
|
76834
|
-
return isFunctionType(returnType) || isConstructorType(returnType);
|
|
76922
|
+
function isGenericFunctionReturningFunction(signature) {
|
|
76923
|
+
return !!(signature.typeParameters && isFunctionType(getReturnTypeOfSignature(signature)));
|
|
76835
76924
|
}
|
|
76836
76925
|
function isUntypedFunctionCall(funcType, apparentFuncType, numCallSignatures, numConstructSignatures) {
|
|
76837
76926
|
return isTypeAny(funcType) || isTypeAny(apparentFuncType) && !!(funcType.flags & 262144 /* TypeParameter */) || !numCallSignatures && !numConstructSignatures && !(apparentFuncType.flags & 1048576 /* Union */) && !(getReducedType(apparentFuncType).flags & 131072 /* Never */) && isTypeAssignableTo(funcType, globalFunctionType);
|
|
@@ -77602,7 +77691,7 @@ function createTypeChecker(host) {
|
|
|
77602
77691
|
function checkTaggedTemplateExpression(node) {
|
|
77603
77692
|
if (!checkGrammarTaggedTemplateChain(node))
|
|
77604
77693
|
checkGrammarTypeArguments(node, node.typeArguments);
|
|
77605
|
-
if (languageVersion < 2 /*
|
|
77694
|
+
if (languageVersion < 2 /* TaggedTemplates */) {
|
|
77606
77695
|
checkExternalEmitHelpers(node, 262144 /* MakeTemplateObject */);
|
|
77607
77696
|
}
|
|
77608
77697
|
const signature = getResolvedSignature(node);
|
|
@@ -79249,7 +79338,7 @@ function createTypeChecker(host) {
|
|
|
79249
79338
|
return silentNeverType;
|
|
79250
79339
|
}
|
|
79251
79340
|
if (isPrivateIdentifier(left)) {
|
|
79252
|
-
if (languageVersion < 99 /*
|
|
79341
|
+
if (languageVersion < 9 /* PrivateNamesAndClassStaticBlocks */ || languageVersion < 99 /* ClassAndClassElementDecorators */ || !useDefineForClassFields) {
|
|
79253
79342
|
checkExternalEmitHelpers(left, 2097152 /* ClassPrivateFieldIn */);
|
|
79254
79343
|
}
|
|
79255
79344
|
if (!getNodeLinks(left).resolvedSymbol && getContainingClass(left)) {
|
|
@@ -79310,7 +79399,7 @@ function createTypeChecker(host) {
|
|
|
79310
79399
|
if (propertyIndex < properties.length - 1) {
|
|
79311
79400
|
error2(property, Diagnostics.A_rest_element_must_be_last_in_a_destructuring_pattern);
|
|
79312
79401
|
} else {
|
|
79313
|
-
if (languageVersion <
|
|
79402
|
+
if (languageVersion < 5 /* ObjectSpreadRest */) {
|
|
79314
79403
|
checkExternalEmitHelpers(property, 4 /* Rest */);
|
|
79315
79404
|
}
|
|
79316
79405
|
const nonRestNames = [];
|
|
@@ -79331,7 +79420,7 @@ function createTypeChecker(host) {
|
|
|
79331
79420
|
}
|
|
79332
79421
|
function checkArrayLiteralAssignment(node, sourceType, checkMode) {
|
|
79333
79422
|
const elements = node.elements;
|
|
79334
|
-
if (languageVersion < 2 /*
|
|
79423
|
+
if (languageVersion < 2 /* DestructuringAssignment */ && compilerOptions.downlevelIteration) {
|
|
79335
79424
|
checkExternalEmitHelpers(node, 512 /* Read */);
|
|
79336
79425
|
}
|
|
79337
79426
|
const possiblyOutOfBoundsType = checkIteratedTypeOrElementType(65 /* Destructuring */ | 128 /* PossiblyOutOfBounds */, sourceType, undefinedType, node) || errorType;
|
|
@@ -80033,10 +80122,10 @@ function createTypeChecker(host) {
|
|
|
80033
80122
|
}
|
|
80034
80123
|
const isAsync = (functionFlags & 2 /* Async */) !== 0;
|
|
80035
80124
|
if (node.asteriskToken) {
|
|
80036
|
-
if (isAsync && languageVersion <
|
|
80125
|
+
if (isAsync && languageVersion < 5 /* AsyncGenerators */) {
|
|
80037
80126
|
checkExternalEmitHelpers(node, 26624 /* AsyncDelegatorIncludes */);
|
|
80038
80127
|
}
|
|
80039
|
-
if (!isAsync && languageVersion < 2 /*
|
|
80128
|
+
if (!isAsync && languageVersion < 2 /* Generators */ && compilerOptions.downlevelIteration) {
|
|
80040
80129
|
checkExternalEmitHelpers(node, 256 /* Values */);
|
|
80041
80130
|
}
|
|
80042
80131
|
}
|
|
@@ -80808,13 +80897,13 @@ function createTypeChecker(host) {
|
|
|
80808
80897
|
}
|
|
80809
80898
|
const functionFlags = getFunctionFlags(node);
|
|
80810
80899
|
if (!(functionFlags & 4 /* Invalid */)) {
|
|
80811
|
-
if ((functionFlags & 3 /* AsyncGenerator */) === 3 /* AsyncGenerator */ && languageVersion <
|
|
80900
|
+
if ((functionFlags & 3 /* AsyncGenerator */) === 3 /* AsyncGenerator */ && languageVersion < 5 /* AsyncGenerators */) {
|
|
80812
80901
|
checkExternalEmitHelpers(node, 6144 /* AsyncGeneratorIncludes */);
|
|
80813
80902
|
}
|
|
80814
|
-
if ((functionFlags & 3 /* AsyncGenerator */) === 2 /* Async */ && languageVersion < 4 /*
|
|
80903
|
+
if ((functionFlags & 3 /* AsyncGenerator */) === 2 /* Async */ && languageVersion < 4 /* AsyncFunctions */) {
|
|
80815
80904
|
checkExternalEmitHelpers(node, 64 /* Awaiter */);
|
|
80816
80905
|
}
|
|
80817
|
-
if ((functionFlags & 3 /* AsyncGenerator */) !== 0 /* Normal */ && languageVersion < 2 /*
|
|
80906
|
+
if ((functionFlags & 3 /* AsyncGenerator */) !== 0 /* Normal */ && languageVersion < 2 /* Generators */) {
|
|
80818
80907
|
checkExternalEmitHelpers(node, 128 /* Generator */);
|
|
80819
80908
|
}
|
|
80820
80909
|
}
|
|
@@ -81047,15 +81136,17 @@ function createTypeChecker(host) {
|
|
|
81047
81136
|
setNodeLinksForPrivateIdentifierScope(node);
|
|
81048
81137
|
}
|
|
81049
81138
|
function setNodeLinksForPrivateIdentifierScope(node) {
|
|
81050
|
-
if (isPrivateIdentifier(node.name)
|
|
81051
|
-
|
|
81052
|
-
|
|
81053
|
-
|
|
81054
|
-
|
|
81055
|
-
|
|
81056
|
-
|
|
81057
|
-
|
|
81058
|
-
|
|
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
|
+
}
|
|
81059
81150
|
}
|
|
81060
81151
|
}
|
|
81061
81152
|
}
|
|
@@ -82007,7 +82098,56 @@ function createTypeChecker(host) {
|
|
|
82007
82098
|
}
|
|
82008
82099
|
}
|
|
82009
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
|
+
}
|
|
82010
82149
|
function checkDecorator(node) {
|
|
82150
|
+
checkGrammarDecorator(node);
|
|
82011
82151
|
const signature = getResolvedSignature(node);
|
|
82012
82152
|
checkDeprecatedSignature(signature, node);
|
|
82013
82153
|
const returnType = getReturnTypeOfSignature(signature);
|
|
@@ -82180,7 +82320,7 @@ function createTypeChecker(host) {
|
|
|
82180
82320
|
if (node.kind === 169 /* Parameter */) {
|
|
82181
82321
|
checkExternalEmitHelpers(firstDecorator, 32 /* Param */);
|
|
82182
82322
|
}
|
|
82183
|
-
} else if (languageVersion < 99 /*
|
|
82323
|
+
} else if (languageVersion < 99 /* ClassAndClassElementDecorators */) {
|
|
82184
82324
|
checkExternalEmitHelpers(firstDecorator, 8 /* ESDecorateAndRunInitializers */);
|
|
82185
82325
|
if (isClassDeclaration(node)) {
|
|
82186
82326
|
if (!node.name) {
|
|
@@ -82885,7 +83025,7 @@ function createTypeChecker(host) {
|
|
|
82885
83025
|
potentialUnusedRenamedBindingElementsInTypes.push(node);
|
|
82886
83026
|
return;
|
|
82887
83027
|
}
|
|
82888
|
-
if (isObjectBindingPattern(node.parent) && node.dotDotDotToken && languageVersion < 5 /*
|
|
83028
|
+
if (isObjectBindingPattern(node.parent) && node.dotDotDotToken && languageVersion < 5 /* ObjectSpreadRest */) {
|
|
82889
83029
|
checkExternalEmitHelpers(node, 4 /* Rest */);
|
|
82890
83030
|
}
|
|
82891
83031
|
if (node.propertyName && node.propertyName.kind === 167 /* ComputedPropertyName */) {
|
|
@@ -82921,7 +83061,7 @@ function createTypeChecker(host) {
|
|
|
82921
83061
|
}
|
|
82922
83062
|
}
|
|
82923
83063
|
if (isBindingPattern(node.name)) {
|
|
82924
|
-
if (node.name.kind === 207 /* ArrayBindingPattern */ && languageVersion < 2 /*
|
|
83064
|
+
if (node.name.kind === 207 /* ArrayBindingPattern */ && languageVersion < 2 /* BindingPatterns */ && compilerOptions.downlevelIteration) {
|
|
82925
83065
|
checkExternalEmitHelpers(node, 512 /* Read */);
|
|
82926
83066
|
}
|
|
82927
83067
|
forEach(node.name.elements, checkSourceElement);
|
|
@@ -83072,7 +83212,7 @@ function createTypeChecker(host) {
|
|
|
83072
83212
|
}
|
|
83073
83213
|
function checkVariableDeclarationList(node) {
|
|
83074
83214
|
const blockScopeKind = getCombinedNodeFlags(node) & 7 /* BlockScoped */;
|
|
83075
|
-
if (blockScopeKind === 4 /* Using */ || blockScopeKind === 6 /* AwaitUsing */) {
|
|
83215
|
+
if ((blockScopeKind === 4 /* Using */ || blockScopeKind === 6 /* AwaitUsing */) && languageVersion < 99 /* UsingAndAwaitUsing */) {
|
|
83076
83216
|
checkExternalEmitHelpers(node, 16777216 /* AddDisposableResourceAndDisposeResources */);
|
|
83077
83217
|
}
|
|
83078
83218
|
forEach(node.declarations, checkSourceElement);
|
|
@@ -83245,11 +83385,11 @@ function createTypeChecker(host) {
|
|
|
83245
83385
|
grammarErrorOnNode(node.awaitModifier, Diagnostics.for_await_loops_cannot_be_used_inside_a_class_static_block);
|
|
83246
83386
|
} else {
|
|
83247
83387
|
const functionFlags = getFunctionFlags(container);
|
|
83248
|
-
if ((functionFlags & (4 /* Invalid */ | 2 /* Async */)) === 2 /* Async */ && languageVersion <
|
|
83388
|
+
if ((functionFlags & (4 /* Invalid */ | 2 /* Async */)) === 2 /* Async */ && languageVersion < 5 /* ForAwaitOf */) {
|
|
83249
83389
|
checkExternalEmitHelpers(node, 16384 /* ForAwaitOfIncludes */);
|
|
83250
83390
|
}
|
|
83251
83391
|
}
|
|
83252
|
-
} else if (compilerOptions.downlevelIteration && languageVersion < 2 /*
|
|
83392
|
+
} else if (compilerOptions.downlevelIteration && languageVersion < 2 /* ForOf */) {
|
|
83253
83393
|
checkExternalEmitHelpers(node, 256 /* ForOfIncludes */);
|
|
83254
83394
|
}
|
|
83255
83395
|
if (node.initializer.kind === 261 /* VariableDeclarationList */) {
|
|
@@ -84173,6 +84313,7 @@ function createTypeChecker(host) {
|
|
|
84173
84313
|
case "symbol":
|
|
84174
84314
|
case "void":
|
|
84175
84315
|
case "object":
|
|
84316
|
+
case "undefined":
|
|
84176
84317
|
error2(name, message, name.escapedText);
|
|
84177
84318
|
}
|
|
84178
84319
|
}
|
|
@@ -84312,12 +84453,12 @@ function createTypeChecker(host) {
|
|
|
84312
84453
|
return true;
|
|
84313
84454
|
}
|
|
84314
84455
|
function getFirstTransformableStaticClassElement(node) {
|
|
84315
|
-
const willTransformStaticElementsOfDecoratedClass = !legacyDecorators && languageVersion < 99 /*
|
|
84456
|
+
const willTransformStaticElementsOfDecoratedClass = !legacyDecorators && languageVersion < 99 /* ClassAndClassElementDecorators */ && classOrConstructorParameterIsDecorated(
|
|
84316
84457
|
/*useLegacyDecorators*/
|
|
84317
84458
|
false,
|
|
84318
84459
|
node
|
|
84319
84460
|
);
|
|
84320
|
-
const willTransformPrivateElementsOrClassStaticBlocks = languageVersion
|
|
84461
|
+
const willTransformPrivateElementsOrClassStaticBlocks = languageVersion < 9 /* PrivateNamesAndClassStaticBlocks */ || languageVersion < 99 /* ClassAndClassElementDecorators */;
|
|
84321
84462
|
const willTransformInitializers = !emitStandardClassFields;
|
|
84322
84463
|
if (willTransformStaticElementsOfDecoratedClass || willTransformPrivateElementsOrClassStaticBlocks) {
|
|
84323
84464
|
for (const member of node.members) {
|
|
@@ -84346,7 +84487,7 @@ function createTypeChecker(host) {
|
|
|
84346
84487
|
const parent2 = walkUpOuterExpressions(node);
|
|
84347
84488
|
if (!isNamedEvaluationSource(parent2))
|
|
84348
84489
|
return;
|
|
84349
|
-
const willTransformESDecorators = !legacyDecorators && languageVersion < 99 /*
|
|
84490
|
+
const willTransformESDecorators = !legacyDecorators && languageVersion < 99 /* ClassAndClassElementDecorators */;
|
|
84350
84491
|
let location;
|
|
84351
84492
|
if (willTransformESDecorators && classOrConstructorParameterIsDecorated(
|
|
84352
84493
|
/*useLegacyDecorators*/
|
|
@@ -84406,7 +84547,7 @@ function createTypeChecker(host) {
|
|
|
84406
84547
|
const baseTypeNode = getEffectiveBaseTypeNode(node);
|
|
84407
84548
|
if (baseTypeNode) {
|
|
84408
84549
|
forEach(baseTypeNode.typeArguments, checkSourceElement);
|
|
84409
|
-
if (languageVersion < 2 /*
|
|
84550
|
+
if (languageVersion < 2 /* Classes */) {
|
|
84410
84551
|
checkExternalEmitHelpers(baseTypeNode.parent, 1 /* Extends */);
|
|
84411
84552
|
}
|
|
84412
84553
|
const extendsNode = getClassExtendsHeritageElement(node);
|
|
@@ -87875,7 +88016,7 @@ function createTypeChecker(host) {
|
|
|
87875
88016
|
}
|
|
87876
88017
|
}
|
|
87877
88018
|
}
|
|
87878
|
-
|
|
88019
|
+
addUndefinedToGlobalsOrErrorOnRedeclaration();
|
|
87879
88020
|
getSymbolLinks(undefinedSymbol).type = undefinedWideningType;
|
|
87880
88021
|
getSymbolLinks(argumentsSymbol).type = getGlobalType(
|
|
87881
88022
|
"IArguments",
|
|
@@ -88529,7 +88670,7 @@ function createTypeChecker(host) {
|
|
|
88529
88670
|
if (parameter.initializer) {
|
|
88530
88671
|
return grammarErrorOnNode(parameter.name, Diagnostics.A_rest_parameter_cannot_have_an_initializer);
|
|
88531
88672
|
}
|
|
88532
|
-
} else if (
|
|
88673
|
+
} else if (hasEffectiveQuestionToken(parameter)) {
|
|
88533
88674
|
seenOptionalParameter = true;
|
|
88534
88675
|
if (parameter.questionToken && parameter.initializer) {
|
|
88535
88676
|
return grammarErrorOnNode(parameter.name, Diagnostics.Parameter_cannot_have_question_mark_and_initializer);
|
|
@@ -91640,12 +91781,12 @@ function getOriginalNodeId(node) {
|
|
|
91640
91781
|
function containsDefaultReference(node) {
|
|
91641
91782
|
if (!node)
|
|
91642
91783
|
return false;
|
|
91643
|
-
if (!isNamedImports(node))
|
|
91784
|
+
if (!isNamedImports(node) && !isNamedExports(node))
|
|
91644
91785
|
return false;
|
|
91645
91786
|
return some(node.elements, isNamedDefaultReference);
|
|
91646
91787
|
}
|
|
91647
91788
|
function isNamedDefaultReference(e) {
|
|
91648
|
-
return e.propertyName !== void 0
|
|
91789
|
+
return e.propertyName !== void 0 ? e.propertyName.escapedText === "default" /* Default */ : e.name.escapedText === "default" /* Default */;
|
|
91649
91790
|
}
|
|
91650
91791
|
function chainBundle(context, transformSourceFile) {
|
|
91651
91792
|
return transformSourceFileOrBundle;
|
|
@@ -91719,6 +91860,7 @@ function collectExternalModuleInfo(context, sourceFile) {
|
|
|
91719
91860
|
externalImports.push(node);
|
|
91720
91861
|
if (isNamedExports(node.exportClause)) {
|
|
91721
91862
|
addExportedNamesForExportDeclaration(node);
|
|
91863
|
+
hasImportDefault || (hasImportDefault = containsDefaultReference(node.exportClause));
|
|
91722
91864
|
} else {
|
|
91723
91865
|
const name = node.exportClause.name;
|
|
91724
91866
|
if (!uniqueExports.get(idText(name))) {
|
|
@@ -132952,13 +133094,15 @@ function insertImports(changes, sourceFile, imports, blankLineBetween, preferenc
|
|
|
132952
133094
|
const decl = isArray(imports) ? imports[0] : imports;
|
|
132953
133095
|
const importKindPredicate = decl.kind === 243 /* VariableStatement */ ? isRequireVariableStatement : isAnyImportSyntax;
|
|
132954
133096
|
const existingImportStatements = filter(sourceFile.statements, importKindPredicate);
|
|
132955
|
-
|
|
133097
|
+
let sortKind = isArray(imports) ? ts_OrganizeImports_exports.detectImportDeclarationSorting(imports, preferences) : 3 /* Both */;
|
|
133098
|
+
const comparer = ts_OrganizeImports_exports.getOrganizeImportsComparer(preferences, sortKind === 2 /* CaseInsensitive */);
|
|
132956
133099
|
const sortedNewImports = isArray(imports) ? stableSort(imports, (a, b) => ts_OrganizeImports_exports.compareImportsOrRequireStatements(a, b, comparer)) : [imports];
|
|
132957
133100
|
if (!existingImportStatements.length) {
|
|
132958
133101
|
changes.insertNodesAtTopOfFile(sourceFile, sortedNewImports, blankLineBetween);
|
|
132959
|
-
} else if (existingImportStatements &&
|
|
133102
|
+
} else if (existingImportStatements && (sortKind = ts_OrganizeImports_exports.detectImportDeclarationSorting(existingImportStatements, preferences))) {
|
|
133103
|
+
const comparer2 = ts_OrganizeImports_exports.getOrganizeImportsComparer(preferences, sortKind === 2 /* CaseInsensitive */);
|
|
132960
133104
|
for (const newImport of sortedNewImports) {
|
|
132961
|
-
const insertionIndex = ts_OrganizeImports_exports.getImportDeclarationInsertionIndex(existingImportStatements, newImport,
|
|
133105
|
+
const insertionIndex = ts_OrganizeImports_exports.getImportDeclarationInsertionIndex(existingImportStatements, newImport, comparer2);
|
|
132962
133106
|
if (insertionIndex === 0) {
|
|
132963
133107
|
const options = existingImportStatements[0] === sourceFile.statements[0] ? { leadingTriviaOption: ts_textChanges_exports.LeadingTriviaOption.Exclude } : {};
|
|
132964
133108
|
changes.insertNodeBefore(
|
|
@@ -145541,22 +145685,22 @@ function createLanguageService(host, documentRegistry = createDocumentRegistry(h
|
|
|
145541
145685
|
}
|
|
145542
145686
|
return [];
|
|
145543
145687
|
}
|
|
145544
|
-
function getCodeFixesAtPosition(fileName, start2, end,
|
|
145688
|
+
function getCodeFixesAtPosition(fileName, start2, end, errorCodes66, formatOptions, preferences = emptyOptions) {
|
|
145545
145689
|
synchronizeHostData();
|
|
145546
145690
|
const sourceFile = getValidSourceFile(fileName);
|
|
145547
145691
|
const span = createTextSpanFromBounds(start2, end);
|
|
145548
145692
|
const formatContext = ts_formatting_exports.getFormatContext(formatOptions, host);
|
|
145549
|
-
return flatMap(deduplicate(
|
|
145693
|
+
return flatMap(deduplicate(errorCodes66, equateValues, compareValues), (errorCode) => {
|
|
145550
145694
|
cancellationToken.throwIfCancellationRequested();
|
|
145551
145695
|
return ts_codefix_exports.getFixes({ errorCode, sourceFile, span, program, host, cancellationToken, formatContext, preferences });
|
|
145552
145696
|
});
|
|
145553
145697
|
}
|
|
145554
|
-
function getCombinedCodeFix(scope,
|
|
145698
|
+
function getCombinedCodeFix(scope, fixId53, formatOptions, preferences = emptyOptions) {
|
|
145555
145699
|
synchronizeHostData();
|
|
145556
145700
|
Debug.assert(scope.type === "file");
|
|
145557
145701
|
const sourceFile = getValidSourceFile(scope.fileName);
|
|
145558
145702
|
const formatContext = ts_formatting_exports.getFormatContext(formatOptions, host);
|
|
145559
|
-
return ts_codefix_exports.getAllFixes({ fixId:
|
|
145703
|
+
return ts_codefix_exports.getAllFixes({ fixId: fixId53, sourceFile, program, host, cancellationToken, formatContext, preferences });
|
|
145560
145704
|
}
|
|
145561
145705
|
function organizeImports2(args, formatOptions, preferences = emptyOptions) {
|
|
145562
145706
|
synchronizeHostData();
|
|
@@ -147235,14 +147379,14 @@ function createCodeFixActionWithoutFixAll(fixName8, changes, description3) {
|
|
|
147235
147379
|
void 0
|
|
147236
147380
|
);
|
|
147237
147381
|
}
|
|
147238
|
-
function createCodeFixAction(fixName8, changes, description3,
|
|
147239
|
-
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);
|
|
147240
147384
|
}
|
|
147241
|
-
function createCodeFixActionMaybeFixAll(fixName8, changes, description3,
|
|
147242
|
-
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);
|
|
147243
147387
|
}
|
|
147244
|
-
function createCodeFixActionWorker(fixName8, description3, changes,
|
|
147245
|
-
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 };
|
|
147246
147390
|
}
|
|
147247
147391
|
function registerCodeFix(reg) {
|
|
147248
147392
|
for (const error2 of reg.errorCodes) {
|
|
@@ -147250,9 +147394,9 @@ function registerCodeFix(reg) {
|
|
|
147250
147394
|
errorCodeToFixes.add(String(error2), reg);
|
|
147251
147395
|
}
|
|
147252
147396
|
if (reg.fixIds) {
|
|
147253
|
-
for (const
|
|
147254
|
-
Debug.assert(!fixIdToRegistration.has(
|
|
147255
|
-
fixIdToRegistration.set(
|
|
147397
|
+
for (const fixId53 of reg.fixIds) {
|
|
147398
|
+
Debug.assert(!fixIdToRegistration.has(fixId53));
|
|
147399
|
+
fixIdToRegistration.set(fixId53, reg);
|
|
147256
147400
|
}
|
|
147257
147401
|
}
|
|
147258
147402
|
}
|
|
@@ -147261,17 +147405,17 @@ function getSupportedErrorCodes() {
|
|
|
147261
147405
|
return errorCodeToFixesArray ?? (errorCodeToFixesArray = arrayFrom(errorCodeToFixes.keys()));
|
|
147262
147406
|
}
|
|
147263
147407
|
function removeFixIdIfFixAllUnavailable(registration, diagnostics) {
|
|
147264
|
-
const { errorCodes:
|
|
147408
|
+
const { errorCodes: errorCodes66 } = registration;
|
|
147265
147409
|
let maybeFixableDiagnostics = 0;
|
|
147266
147410
|
for (const diag2 of diagnostics) {
|
|
147267
|
-
if (contains(
|
|
147411
|
+
if (contains(errorCodes66, diag2.code))
|
|
147268
147412
|
maybeFixableDiagnostics++;
|
|
147269
147413
|
if (maybeFixableDiagnostics > 1)
|
|
147270
147414
|
break;
|
|
147271
147415
|
}
|
|
147272
147416
|
const fixAllUnavailable = maybeFixableDiagnostics < 2;
|
|
147273
|
-
return ({ fixId:
|
|
147274
|
-
return fixAllUnavailable ? action : { ...action, fixId:
|
|
147417
|
+
return ({ fixId: fixId53, fixAllDescription, ...action }) => {
|
|
147418
|
+
return fixAllUnavailable ? action : { ...action, fixId: fixId53, fixAllDescription };
|
|
147275
147419
|
};
|
|
147276
147420
|
}
|
|
147277
147421
|
function getFixes(context) {
|
|
@@ -147288,14 +147432,14 @@ function createCombinedCodeActions(changes, commands) {
|
|
|
147288
147432
|
function createFileTextChanges(fileName, textChanges2) {
|
|
147289
147433
|
return { fileName, textChanges: textChanges2 };
|
|
147290
147434
|
}
|
|
147291
|
-
function codeFixAll(context,
|
|
147435
|
+
function codeFixAll(context, errorCodes66, use) {
|
|
147292
147436
|
const commands = [];
|
|
147293
|
-
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)));
|
|
147294
147438
|
return createCombinedCodeActions(changes, commands.length === 0 ? void 0 : commands);
|
|
147295
147439
|
}
|
|
147296
|
-
function eachDiagnostic(context,
|
|
147440
|
+
function eachDiagnostic(context, errorCodes66, cb) {
|
|
147297
147441
|
for (const diag2 of getDiagnostics(context)) {
|
|
147298
|
-
if (contains(
|
|
147442
|
+
if (contains(errorCodes66, diag2.code)) {
|
|
147299
147443
|
cb(diag2);
|
|
147300
147444
|
}
|
|
147301
147445
|
}
|
|
@@ -151224,7 +151368,8 @@ function promoteFromTypeOnly(changes, aliasDeclaration, program, sourceFile, pre
|
|
|
151224
151368
|
switch (aliasDeclaration.kind) {
|
|
151225
151369
|
case 276 /* ImportSpecifier */:
|
|
151226
151370
|
if (aliasDeclaration.isTypeOnly) {
|
|
151227
|
-
|
|
151371
|
+
const sortKind = ts_OrganizeImports_exports.detectImportSpecifierSorting(aliasDeclaration.parent.elements, preferences);
|
|
151372
|
+
if (aliasDeclaration.parent.elements.length > 1 && sortKind) {
|
|
151228
151373
|
const newSpecifier = factory.updateImportSpecifier(
|
|
151229
151374
|
aliasDeclaration,
|
|
151230
151375
|
/*isTypeOnly*/
|
|
@@ -151232,8 +151377,8 @@ function promoteFromTypeOnly(changes, aliasDeclaration, program, sourceFile, pre
|
|
|
151232
151377
|
aliasDeclaration.propertyName,
|
|
151233
151378
|
aliasDeclaration.name
|
|
151234
151379
|
);
|
|
151235
|
-
const
|
|
151236
|
-
const insertionIndex = ts_OrganizeImports_exports.getImportSpecifierInsertionIndex(aliasDeclaration.parent.elements, newSpecifier,
|
|
151380
|
+
const comparer = ts_OrganizeImports_exports.getOrganizeImportsComparer(preferences, sortKind === 2 /* CaseInsensitive */);
|
|
151381
|
+
const insertionIndex = ts_OrganizeImports_exports.getImportSpecifierInsertionIndex(aliasDeclaration.parent.elements, newSpecifier, comparer, preferences);
|
|
151237
151382
|
if (insertionIndex !== aliasDeclaration.parent.elements.indexOf(aliasDeclaration)) {
|
|
151238
151383
|
changes.delete(sourceFile, aliasDeclaration);
|
|
151239
151384
|
changes.insertImportSpecifierAtIndex(sourceFile, newSpecifier, aliasDeclaration.parent, insertionIndex);
|
|
@@ -151273,8 +151418,7 @@ function promoteFromTypeOnly(changes, aliasDeclaration, program, sourceFile, pre
|
|
|
151273
151418
|
if (convertExistingToTypeOnly) {
|
|
151274
151419
|
const namedImports = tryCast(importClause.namedBindings, isNamedImports);
|
|
151275
151420
|
if (namedImports && namedImports.elements.length > 1) {
|
|
151276
|
-
|
|
151277
|
-
if (sortState.isSorted !== false && aliasDeclaration.kind === 276 /* ImportSpecifier */ && namedImports.elements.indexOf(aliasDeclaration) !== 0) {
|
|
151421
|
+
if (ts_OrganizeImports_exports.detectImportSpecifierSorting(namedImports.elements, preferences) && aliasDeclaration.kind === 276 /* ImportSpecifier */ && namedImports.elements.indexOf(aliasDeclaration) !== 0) {
|
|
151278
151422
|
changes.delete(sourceFile, aliasDeclaration);
|
|
151279
151423
|
changes.insertImportSpecifierAtIndex(sourceFile, aliasDeclaration, namedImports, 0);
|
|
151280
151424
|
}
|
|
@@ -151310,7 +151454,19 @@ function doAddExistingFix(changes, sourceFile, clause, defaultImport, namedImpor
|
|
|
151310
151454
|
changes.insertNodeAt(sourceFile, clause.getStart(sourceFile), factory.createIdentifier(defaultImport.name), { suffix: ", " });
|
|
151311
151455
|
}
|
|
151312
151456
|
if (namedImports.length) {
|
|
151313
|
-
|
|
151457
|
+
let ignoreCaseForSorting;
|
|
151458
|
+
if (typeof preferences.organizeImportsIgnoreCase === "boolean") {
|
|
151459
|
+
ignoreCaseForSorting = preferences.organizeImportsIgnoreCase;
|
|
151460
|
+
} else if (existingSpecifiers) {
|
|
151461
|
+
const targetImportSorting = ts_OrganizeImports_exports.detectImportSpecifierSorting(existingSpecifiers, preferences);
|
|
151462
|
+
if (targetImportSorting !== 3 /* Both */) {
|
|
151463
|
+
ignoreCaseForSorting = targetImportSorting === 2 /* CaseInsensitive */;
|
|
151464
|
+
}
|
|
151465
|
+
}
|
|
151466
|
+
if (ignoreCaseForSorting === void 0) {
|
|
151467
|
+
ignoreCaseForSorting = ts_OrganizeImports_exports.detectSorting(sourceFile, preferences) === 2 /* CaseInsensitive */;
|
|
151468
|
+
}
|
|
151469
|
+
const comparer = ts_OrganizeImports_exports.getOrganizeImportsComparer(preferences, ignoreCaseForSorting);
|
|
151314
151470
|
const newSpecifiers = stableSort(
|
|
151315
151471
|
namedImports.map(
|
|
151316
151472
|
(namedImport) => factory.createImportSpecifier(
|
|
@@ -151320,11 +151476,12 @@ function doAddExistingFix(changes, sourceFile, clause, defaultImport, namedImpor
|
|
|
151320
151476
|
factory.createIdentifier(namedImport.name)
|
|
151321
151477
|
)
|
|
151322
151478
|
),
|
|
151323
|
-
|
|
151479
|
+
(s1, s2) => ts_OrganizeImports_exports.compareImportOrExportSpecifiers(s1, s2, comparer)
|
|
151324
151480
|
);
|
|
151325
|
-
|
|
151481
|
+
const specifierSort = (existingSpecifiers == null ? void 0 : existingSpecifiers.length) && ts_OrganizeImports_exports.detectImportSpecifierSorting(existingSpecifiers, preferences);
|
|
151482
|
+
if (specifierSort && !(ignoreCaseForSorting && specifierSort === 1 /* CaseSensitive */)) {
|
|
151326
151483
|
for (const spec of newSpecifiers) {
|
|
151327
|
-
const insertionIndex = ts_OrganizeImports_exports.getImportSpecifierInsertionIndex(existingSpecifiers, spec,
|
|
151484
|
+
const insertionIndex = promoteFromTypeOnly2 && !spec.isTypeOnly ? 0 : ts_OrganizeImports_exports.getImportSpecifierInsertionIndex(existingSpecifiers, spec, comparer, preferences);
|
|
151328
151485
|
changes.insertImportSpecifierAtIndex(sourceFile, spec, clause.namedBindings, insertionIndex);
|
|
151329
151486
|
}
|
|
151330
151487
|
} else if (existingSpecifiers == null ? void 0 : existingSpecifiers.length) {
|
|
@@ -151693,10 +151850,10 @@ registerCodeFix({
|
|
|
151693
151850
|
const info = errorCodeFixIdMap[errorCode];
|
|
151694
151851
|
if (!info)
|
|
151695
151852
|
return emptyArray;
|
|
151696
|
-
const { descriptions, fixId:
|
|
151853
|
+
const { descriptions, fixId: fixId53, fixAllDescriptions } = info;
|
|
151697
151854
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (changes2) => dispatchChanges(changes2, context, errorCode, span.start));
|
|
151698
151855
|
return [
|
|
151699
|
-
createCodeFixActionMaybeFixAll(fixName, changes, descriptions,
|
|
151856
|
+
createCodeFixActionMaybeFixAll(fixName, changes, descriptions, fixId53, fixAllDescriptions)
|
|
151700
151857
|
];
|
|
151701
151858
|
},
|
|
151702
151859
|
fixIds: [fixName, fixAddOverrideId, fixRemoveOverrideId],
|
|
@@ -152501,7 +152658,7 @@ registerCodeFix({
|
|
|
152501
152658
|
},
|
|
152502
152659
|
fixIds: [fixMissingMember, fixMissingFunctionDeclaration, fixMissingProperties, fixMissingAttributes],
|
|
152503
152660
|
getAllCodeActions: (context) => {
|
|
152504
|
-
const { program, fixId:
|
|
152661
|
+
const { program, fixId: fixId53 } = context;
|
|
152505
152662
|
const checker = program.getTypeChecker();
|
|
152506
152663
|
const seen = /* @__PURE__ */ new Map();
|
|
152507
152664
|
const typeDeclToMembers = /* @__PURE__ */ new Map();
|
|
@@ -152511,11 +152668,11 @@ registerCodeFix({
|
|
|
152511
152668
|
if (!info || !addToSeen(seen, getNodeId(info.parentDeclaration) + "#" + (info.kind === 3 /* ObjectLiteral */ ? info.identifier : info.token.text))) {
|
|
152512
152669
|
return;
|
|
152513
152670
|
}
|
|
152514
|
-
if (
|
|
152671
|
+
if (fixId53 === fixMissingFunctionDeclaration && (info.kind === 2 /* Function */ || info.kind === 5 /* Signature */)) {
|
|
152515
152672
|
addFunctionDeclaration(changes, context, info);
|
|
152516
|
-
} else if (
|
|
152673
|
+
} else if (fixId53 === fixMissingProperties && info.kind === 3 /* ObjectLiteral */) {
|
|
152517
152674
|
addObjectLiteralProperties(changes, context, info);
|
|
152518
|
-
} else if (
|
|
152675
|
+
} else if (fixId53 === fixMissingAttributes && info.kind === 4 /* JsxAttributes */) {
|
|
152519
152676
|
addJsxAttributes(changes, context, info);
|
|
152520
152677
|
} else {
|
|
152521
152678
|
if (info.kind === 1 /* Enum */) {
|
|
@@ -154409,21 +154566,21 @@ registerCodeFix({
|
|
|
154409
154566
|
actions2.push(fix(type, fixIdNullable, Diagnostics.Change_all_jsdoc_style_types_to_TypeScript_and_add_undefined_to_nullable_types));
|
|
154410
154567
|
}
|
|
154411
154568
|
return actions2;
|
|
154412
|
-
function fix(type2,
|
|
154569
|
+
function fix(type2, fixId53, fixAllDescription) {
|
|
154413
154570
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange29(t, sourceFile, typeNode, type2, checker));
|
|
154414
|
-
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);
|
|
154415
154572
|
}
|
|
154416
154573
|
},
|
|
154417
154574
|
fixIds: [fixIdPlain, fixIdNullable],
|
|
154418
154575
|
getAllCodeActions(context) {
|
|
154419
|
-
const { fixId:
|
|
154576
|
+
const { fixId: fixId53, program, sourceFile } = context;
|
|
154420
154577
|
const checker = program.getTypeChecker();
|
|
154421
154578
|
return codeFixAll(context, errorCodes45, (changes, err) => {
|
|
154422
154579
|
const info = getInfo15(err.file, err.start, checker);
|
|
154423
154580
|
if (!info)
|
|
154424
154581
|
return;
|
|
154425
154582
|
const { typeNode, type } = info;
|
|
154426
|
-
const fixedType = typeNode.kind === 314 /* JSDocNullableType */ &&
|
|
154583
|
+
const fixedType = typeNode.kind === 314 /* JSDocNullableType */ && fixId53 === fixIdNullable ? checker.getNullableType(type, 32768 /* Undefined */) : type;
|
|
154427
154584
|
doChange29(changes, sourceFile, typeNode, fixedType, checker);
|
|
154428
154585
|
});
|
|
154429
154586
|
}
|
|
@@ -157131,11 +157288,31 @@ function flattenInvalidBinaryExpr(node) {
|
|
|
157131
157288
|
}
|
|
157132
157289
|
}
|
|
157133
157290
|
|
|
157134
|
-
// src/services/codefixes/
|
|
157135
|
-
var fixId45 = "
|
|
157136
|
-
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];
|
|
157137
157294
|
registerCodeFix({
|
|
157138
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,
|
|
157139
157316
|
getCodeActions: function getCodeActionsToConvertToMappedTypeObject(context) {
|
|
157140
157317
|
const { sourceFile, span } = context;
|
|
157141
157318
|
const info = getInfo20(sourceFile, span.start);
|
|
@@ -157143,10 +157320,10 @@ registerCodeFix({
|
|
|
157143
157320
|
return void 0;
|
|
157144
157321
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange39(t, sourceFile, info));
|
|
157145
157322
|
const name = idText(info.container.name);
|
|
157146
|
-
return [createCodeFixAction(
|
|
157323
|
+
return [createCodeFixAction(fixId46, changes, [Diagnostics.Convert_0_to_mapped_object_type, name], fixId46, [Diagnostics.Convert_0_to_mapped_object_type, name])];
|
|
157147
157324
|
},
|
|
157148
|
-
fixIds: [
|
|
157149
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
157325
|
+
fixIds: [fixId46],
|
|
157326
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes59, (changes, diag2) => {
|
|
157150
157327
|
const info = getInfo20(diag2.file, diag2.start);
|
|
157151
157328
|
if (info)
|
|
157152
157329
|
doChange39(changes, diag2.file, info);
|
|
@@ -157194,12 +157371,12 @@ function doChange39(changes, sourceFile, { indexSignature, container }) {
|
|
|
157194
157371
|
}
|
|
157195
157372
|
|
|
157196
157373
|
// src/services/codefixes/removeAccidentalCallParentheses.ts
|
|
157197
|
-
var
|
|
157198
|
-
var
|
|
157374
|
+
var fixId47 = "removeAccidentalCallParentheses";
|
|
157375
|
+
var errorCodes60 = [
|
|
157199
157376
|
Diagnostics.This_expression_is_not_callable_because_it_is_a_get_accessor_Did_you_mean_to_use_it_without.code
|
|
157200
157377
|
];
|
|
157201
157378
|
registerCodeFix({
|
|
157202
|
-
errorCodes:
|
|
157379
|
+
errorCodes: errorCodes60,
|
|
157203
157380
|
getCodeActions(context) {
|
|
157204
157381
|
const callExpression = findAncestor(getTokenAtPosition(context.sourceFile, context.span.start), isCallExpression);
|
|
157205
157382
|
if (!callExpression) {
|
|
@@ -157208,30 +157385,30 @@ registerCodeFix({
|
|
|
157208
157385
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => {
|
|
157209
157386
|
t.deleteRange(context.sourceFile, { pos: callExpression.expression.end, end: callExpression.end });
|
|
157210
157387
|
});
|
|
157211
|
-
return [createCodeFixActionWithoutFixAll(
|
|
157388
|
+
return [createCodeFixActionWithoutFixAll(fixId47, changes, Diagnostics.Remove_parentheses)];
|
|
157212
157389
|
},
|
|
157213
|
-
fixIds: [
|
|
157390
|
+
fixIds: [fixId47]
|
|
157214
157391
|
});
|
|
157215
157392
|
|
|
157216
157393
|
// src/services/codefixes/removeUnnecessaryAwait.ts
|
|
157217
|
-
var
|
|
157218
|
-
var
|
|
157394
|
+
var fixId48 = "removeUnnecessaryAwait";
|
|
157395
|
+
var errorCodes61 = [
|
|
157219
157396
|
Diagnostics.await_has_no_effect_on_the_type_of_this_expression.code
|
|
157220
157397
|
];
|
|
157221
157398
|
registerCodeFix({
|
|
157222
|
-
errorCodes:
|
|
157399
|
+
errorCodes: errorCodes61,
|
|
157223
157400
|
getCodeActions: function getCodeActionsToRemoveUnnecessaryAwait(context) {
|
|
157224
|
-
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));
|
|
157225
157402
|
if (changes.length > 0) {
|
|
157226
|
-
return [createCodeFixAction(
|
|
157403
|
+
return [createCodeFixAction(fixId48, changes, Diagnostics.Remove_unnecessary_await, fixId48, Diagnostics.Remove_all_unnecessary_uses_of_await)];
|
|
157227
157404
|
}
|
|
157228
157405
|
},
|
|
157229
|
-
fixIds: [
|
|
157406
|
+
fixIds: [fixId48],
|
|
157230
157407
|
getAllCodeActions: (context) => {
|
|
157231
|
-
return codeFixAll(context,
|
|
157408
|
+
return codeFixAll(context, errorCodes61, (changes, diag2) => makeChange11(changes, diag2.file, diag2));
|
|
157232
157409
|
}
|
|
157233
157410
|
});
|
|
157234
|
-
function
|
|
157411
|
+
function makeChange11(changeTracker, sourceFile, span) {
|
|
157235
157412
|
const awaitKeyword = tryCast(getTokenAtPosition(sourceFile, span.start), (node) => node.kind === 135 /* AwaitKeyword */);
|
|
157236
157413
|
const awaitExpression = awaitKeyword && tryCast(awaitKeyword.parent, isAwaitExpression);
|
|
157237
157414
|
if (!awaitExpression) {
|
|
@@ -157256,20 +157433,20 @@ function makeChange10(changeTracker, sourceFile, span) {
|
|
|
157256
157433
|
}
|
|
157257
157434
|
|
|
157258
157435
|
// src/services/codefixes/splitTypeOnlyImport.ts
|
|
157259
|
-
var
|
|
157260
|
-
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";
|
|
157261
157438
|
registerCodeFix({
|
|
157262
|
-
errorCodes:
|
|
157263
|
-
fixIds: [
|
|
157439
|
+
errorCodes: errorCodes62,
|
|
157440
|
+
fixIds: [fixId49],
|
|
157264
157441
|
getCodeActions: function getCodeActionsToSplitTypeOnlyImport(context) {
|
|
157265
157442
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => {
|
|
157266
157443
|
return splitTypeOnlyImport(t, getImportDeclaration2(context.sourceFile, context.span), context);
|
|
157267
157444
|
});
|
|
157268
157445
|
if (changes.length) {
|
|
157269
|
-
return [createCodeFixAction(
|
|
157446
|
+
return [createCodeFixAction(fixId49, changes, Diagnostics.Split_into_two_separate_import_declarations, fixId49, Diagnostics.Split_all_invalid_type_only_imports)];
|
|
157270
157447
|
}
|
|
157271
157448
|
},
|
|
157272
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
157449
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes62, (changes, error2) => {
|
|
157273
157450
|
splitTypeOnlyImport(changes, getImportDeclaration2(context.sourceFile, error2), context);
|
|
157274
157451
|
})
|
|
157275
157452
|
});
|
|
@@ -157318,23 +157495,23 @@ function splitTypeOnlyImport(changes, importDeclaration, context) {
|
|
|
157318
157495
|
}
|
|
157319
157496
|
|
|
157320
157497
|
// src/services/codefixes/convertConstToLet.ts
|
|
157321
|
-
var
|
|
157322
|
-
var
|
|
157498
|
+
var fixId50 = "fixConvertConstToLet";
|
|
157499
|
+
var errorCodes63 = [Diagnostics.Cannot_assign_to_0_because_it_is_a_constant.code];
|
|
157323
157500
|
registerCodeFix({
|
|
157324
|
-
errorCodes:
|
|
157501
|
+
errorCodes: errorCodes63,
|
|
157325
157502
|
getCodeActions: function getCodeActionsToConvertConstToLet(context) {
|
|
157326
157503
|
const { sourceFile, span, program } = context;
|
|
157327
157504
|
const info = getInfo21(sourceFile, span.start, program);
|
|
157328
157505
|
if (info === void 0)
|
|
157329
157506
|
return;
|
|
157330
157507
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange40(t, sourceFile, info.token));
|
|
157331
|
-
return [createCodeFixActionMaybeFixAll(
|
|
157508
|
+
return [createCodeFixActionMaybeFixAll(fixId50, changes, Diagnostics.Convert_const_to_let, fixId50, Diagnostics.Convert_all_const_to_let)];
|
|
157332
157509
|
},
|
|
157333
157510
|
getAllCodeActions: (context) => {
|
|
157334
157511
|
const { program } = context;
|
|
157335
157512
|
const seen = /* @__PURE__ */ new Map();
|
|
157336
157513
|
return createCombinedCodeActions(ts_textChanges_exports.ChangeTracker.with(context, (changes) => {
|
|
157337
|
-
eachDiagnostic(context,
|
|
157514
|
+
eachDiagnostic(context, errorCodes63, (diag2) => {
|
|
157338
157515
|
const info = getInfo21(diag2.file, diag2.start, program);
|
|
157339
157516
|
if (info) {
|
|
157340
157517
|
if (addToSeen(seen, getSymbolId(info.symbol))) {
|
|
@@ -157345,7 +157522,7 @@ registerCodeFix({
|
|
|
157345
157522
|
});
|
|
157346
157523
|
}));
|
|
157347
157524
|
},
|
|
157348
|
-
fixIds: [
|
|
157525
|
+
fixIds: [fixId50]
|
|
157349
157526
|
});
|
|
157350
157527
|
function getInfo21(sourceFile, pos, program) {
|
|
157351
157528
|
var _a;
|
|
@@ -157366,11 +157543,11 @@ function doChange40(changes, sourceFile, token) {
|
|
|
157366
157543
|
}
|
|
157367
157544
|
|
|
157368
157545
|
// src/services/codefixes/fixExpectedComma.ts
|
|
157369
|
-
var
|
|
157546
|
+
var fixId51 = "fixExpectedComma";
|
|
157370
157547
|
var expectedErrorCode = Diagnostics._0_expected.code;
|
|
157371
|
-
var
|
|
157548
|
+
var errorCodes64 = [expectedErrorCode];
|
|
157372
157549
|
registerCodeFix({
|
|
157373
|
-
errorCodes:
|
|
157550
|
+
errorCodes: errorCodes64,
|
|
157374
157551
|
getCodeActions(context) {
|
|
157375
157552
|
const { sourceFile } = context;
|
|
157376
157553
|
const info = getInfo22(sourceFile, context.span.start, context.errorCode);
|
|
@@ -157378,15 +157555,15 @@ registerCodeFix({
|
|
|
157378
157555
|
return void 0;
|
|
157379
157556
|
const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange41(t, sourceFile, info));
|
|
157380
157557
|
return [createCodeFixAction(
|
|
157381
|
-
|
|
157558
|
+
fixId51,
|
|
157382
157559
|
changes,
|
|
157383
157560
|
[Diagnostics.Change_0_to_1, ";", ","],
|
|
157384
|
-
|
|
157561
|
+
fixId51,
|
|
157385
157562
|
[Diagnostics.Change_0_to_1, ";", ","]
|
|
157386
157563
|
)];
|
|
157387
157564
|
},
|
|
157388
|
-
fixIds: [
|
|
157389
|
-
getAllCodeActions: (context) => codeFixAll(context,
|
|
157565
|
+
fixIds: [fixId51],
|
|
157566
|
+
getAllCodeActions: (context) => codeFixAll(context, errorCodes64, (changes, diag2) => {
|
|
157390
157567
|
const info = getInfo22(diag2.file, diag2.start, diag2.code);
|
|
157391
157568
|
if (info)
|
|
157392
157569
|
doChange41(changes, context.sourceFile, info);
|
|
@@ -157403,25 +157580,25 @@ function doChange41(changes, sourceFile, { node }) {
|
|
|
157403
157580
|
|
|
157404
157581
|
// src/services/codefixes/fixAddVoidToPromise.ts
|
|
157405
157582
|
var fixName7 = "addVoidToPromise";
|
|
157406
|
-
var
|
|
157407
|
-
var
|
|
157583
|
+
var fixId52 = "addVoidToPromise";
|
|
157584
|
+
var errorCodes65 = [
|
|
157408
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,
|
|
157409
157586
|
Diagnostics.Expected_0_arguments_but_got_1_Did_you_forget_to_include_void_in_your_type_argument_to_Promise.code
|
|
157410
157587
|
];
|
|
157411
157588
|
registerCodeFix({
|
|
157412
|
-
errorCodes:
|
|
157413
|
-
fixIds: [
|
|
157589
|
+
errorCodes: errorCodes65,
|
|
157590
|
+
fixIds: [fixId52],
|
|
157414
157591
|
getCodeActions(context) {
|
|
157415
|
-
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));
|
|
157416
157593
|
if (changes.length > 0) {
|
|
157417
|
-
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)];
|
|
157418
157595
|
}
|
|
157419
157596
|
},
|
|
157420
157597
|
getAllCodeActions(context) {
|
|
157421
|
-
return codeFixAll(context,
|
|
157598
|
+
return codeFixAll(context, errorCodes65, (changes, diag2) => makeChange12(changes, diag2.file, diag2, context.program, /* @__PURE__ */ new Set()));
|
|
157422
157599
|
}
|
|
157423
157600
|
});
|
|
157424
|
-
function
|
|
157601
|
+
function makeChange12(changes, sourceFile, span, program, seen) {
|
|
157425
157602
|
const node = getTokenAtPosition(sourceFile, span.start);
|
|
157426
157603
|
if (!isIdentifier(node) || !isCallExpression(node.parent) || node.parent.expression !== node || node.parent.arguments.length !== 0)
|
|
157427
157604
|
return;
|
|
@@ -166498,16 +166675,18 @@ function getRightHandSideOfAssignment(rightHandSide) {
|
|
|
166498
166675
|
// src/services/_namespaces/ts.OrganizeImports.ts
|
|
166499
166676
|
var ts_OrganizeImports_exports = {};
|
|
166500
166677
|
__export(ts_OrganizeImports_exports, {
|
|
166678
|
+
coalesceExports: () => coalesceExports,
|
|
166679
|
+
coalesceImports: () => coalesceImports,
|
|
166680
|
+
compareImportOrExportSpecifiers: () => compareImportOrExportSpecifiers,
|
|
166501
166681
|
compareImportsOrRequireStatements: () => compareImportsOrRequireStatements,
|
|
166502
166682
|
compareModuleSpecifiers: () => compareModuleSpecifiers2,
|
|
166503
|
-
|
|
166683
|
+
detectImportDeclarationSorting: () => detectImportDeclarationSorting,
|
|
166684
|
+
detectImportSpecifierSorting: () => detectImportSpecifierSorting,
|
|
166685
|
+
detectSorting: () => detectSorting,
|
|
166504
166686
|
getImportDeclarationInsertionIndex: () => getImportDeclarationInsertionIndex,
|
|
166505
166687
|
getImportSpecifierInsertionIndex: () => getImportSpecifierInsertionIndex,
|
|
166506
|
-
|
|
166507
|
-
|
|
166508
|
-
organizeImports: () => organizeImports,
|
|
166509
|
-
testCoalesceExports: () => testCoalesceExports,
|
|
166510
|
-
testCoalesceImports: () => testCoalesceImports
|
|
166688
|
+
getOrganizeImportsComparer: () => getOrganizeImportsComparer,
|
|
166689
|
+
organizeImports: () => organizeImports
|
|
166511
166690
|
});
|
|
166512
166691
|
|
|
166513
166692
|
// src/services/organizeImports.ts
|
|
@@ -166516,48 +166695,39 @@ function organizeImports(sourceFile, formatContext, host, program, preferences,
|
|
|
166516
166695
|
const shouldSort = mode === "SortAndCombine" /* SortAndCombine */ || mode === "All" /* All */;
|
|
166517
166696
|
const shouldCombine = shouldSort;
|
|
166518
166697
|
const shouldRemove = mode === "RemoveUnused" /* RemoveUnused */ || mode === "All" /* All */;
|
|
166519
|
-
const
|
|
166520
|
-
const
|
|
166521
|
-
const
|
|
166522
|
-
|
|
166523
|
-
|
|
166524
|
-
|
|
166525
|
-
|
|
166526
|
-
|
|
166698
|
+
const topLevelImportGroupDecls = groupByNewlineContiguous(sourceFile, sourceFile.statements.filter(isImportDeclaration));
|
|
166699
|
+
const comparer = getOrganizeImportsComparerWithDetection(preferences, shouldSort ? () => detectSortingWorker(topLevelImportGroupDecls, preferences) === 2 /* CaseInsensitive */ : void 0);
|
|
166700
|
+
const processImportsOfSameModuleSpecifier = (importGroup) => {
|
|
166701
|
+
if (shouldRemove)
|
|
166702
|
+
importGroup = removeUnusedImports(importGroup, sourceFile, program);
|
|
166703
|
+
if (shouldCombine)
|
|
166704
|
+
importGroup = coalesceImportsWorker(importGroup, comparer, sourceFile, preferences);
|
|
166705
|
+
if (shouldSort)
|
|
166706
|
+
importGroup = stableSort(importGroup, (s1, s2) => compareImportsOrRequireStatements(s1, s2, comparer));
|
|
166707
|
+
return importGroup;
|
|
166527
166708
|
};
|
|
166528
|
-
|
|
166529
|
-
({ comparer: comparer.moduleSpecifierComparer } = detectModuleSpecifierCaseBySort(topLevelImportGroupDecls, comparersToTest));
|
|
166530
|
-
}
|
|
166531
|
-
if (!comparer.typeOrder || typeof preferences.organizeImportsIgnoreCase !== "boolean") {
|
|
166532
|
-
const namedImportSort = detectNamedImportOrganizationBySort(topLevelImportDecls, comparersToTest, typeOrdersToTest);
|
|
166533
|
-
if (namedImportSort) {
|
|
166534
|
-
const { namedImportComparer, typeOrder } = namedImportSort;
|
|
166535
|
-
comparer.namedImportComparer = comparer.namedImportComparer ?? namedImportComparer;
|
|
166536
|
-
comparer.typeOrder = comparer.typeOrder ?? typeOrder;
|
|
166537
|
-
}
|
|
166538
|
-
}
|
|
166539
|
-
topLevelImportGroupDecls.forEach((importGroupDecl) => organizeImportsWorker(importGroupDecl, comparer));
|
|
166709
|
+
topLevelImportGroupDecls.forEach((importGroupDecl) => organizeImportsWorker(importGroupDecl, processImportsOfSameModuleSpecifier));
|
|
166540
166710
|
if (mode !== "RemoveUnused" /* RemoveUnused */) {
|
|
166541
|
-
getTopLevelExportGroups(sourceFile).forEach((exportGroupDecl) =>
|
|
166711
|
+
getTopLevelExportGroups(sourceFile).forEach((exportGroupDecl) => organizeImportsWorker(exportGroupDecl, (group2) => coalesceExportsWorker(group2, comparer, preferences)));
|
|
166542
166712
|
}
|
|
166543
166713
|
for (const ambientModule of sourceFile.statements.filter(isAmbientModule)) {
|
|
166544
166714
|
if (!ambientModule.body)
|
|
166545
166715
|
continue;
|
|
166546
166716
|
const ambientModuleImportGroupDecls = groupByNewlineContiguous(sourceFile, ambientModule.body.statements.filter(isImportDeclaration));
|
|
166547
|
-
ambientModuleImportGroupDecls.forEach((importGroupDecl) => organizeImportsWorker(importGroupDecl,
|
|
166717
|
+
ambientModuleImportGroupDecls.forEach((importGroupDecl) => organizeImportsWorker(importGroupDecl, processImportsOfSameModuleSpecifier));
|
|
166548
166718
|
if (mode !== "RemoveUnused" /* RemoveUnused */) {
|
|
166549
166719
|
const ambientModuleExportDecls = ambientModule.body.statements.filter(isExportDeclaration);
|
|
166550
|
-
|
|
166720
|
+
organizeImportsWorker(ambientModuleExportDecls, (group2) => coalesceExportsWorker(group2, comparer, preferences));
|
|
166551
166721
|
}
|
|
166552
166722
|
}
|
|
166553
166723
|
return changeTracker.getChanges();
|
|
166554
|
-
function
|
|
166724
|
+
function organizeImportsWorker(oldImportDecls, coalesce) {
|
|
166555
166725
|
if (length(oldImportDecls) === 0) {
|
|
166556
166726
|
return;
|
|
166557
166727
|
}
|
|
166558
166728
|
setEmitFlags(oldImportDecls[0], 1024 /* NoLeadingComments */);
|
|
166559
166729
|
const oldImportGroups = shouldCombine ? group(oldImportDecls, (importDecl) => getExternalModuleName2(importDecl.moduleSpecifier)) : [oldImportDecls];
|
|
166560
|
-
const sortedImportGroups = shouldSort ? stableSort(oldImportGroups, (group1, group2) => compareModuleSpecifiersWorker(group1[0].moduleSpecifier, group2[0].moduleSpecifier, comparer
|
|
166730
|
+
const sortedImportGroups = shouldSort ? stableSort(oldImportGroups, (group1, group2) => compareModuleSpecifiersWorker(group1[0].moduleSpecifier, group2[0].moduleSpecifier, comparer)) : oldImportGroups;
|
|
166561
166731
|
const newImportDecls = flatMap(sortedImportGroups, (importGroup) => getExternalModuleName2(importGroup[0].moduleSpecifier) || importGroup[0].moduleSpecifier === void 0 ? coalesce(importGroup) : importGroup);
|
|
166562
166732
|
if (newImportDecls.length === 0) {
|
|
166563
166733
|
changeTracker.deleteNodes(
|
|
@@ -166584,40 +166754,6 @@ function organizeImports(sourceFile, formatContext, host, program, preferences,
|
|
|
166584
166754
|
}, hasTrailingComment);
|
|
166585
166755
|
}
|
|
166586
166756
|
}
|
|
166587
|
-
function organizeImportsWorker(oldImportDecls, comparer2) {
|
|
166588
|
-
const detectedModuleCaseComparer = comparer2.moduleSpecifierComparer ?? defaultComparer;
|
|
166589
|
-
const detectedNamedImportCaseComparer = comparer2.namedImportComparer ?? defaultComparer;
|
|
166590
|
-
const detectedTypeOrder = comparer2.typeOrder ?? "last";
|
|
166591
|
-
const specifierComparer = getNamedImportSpecifierComparer({ organizeImportsTypeOrder: detectedTypeOrder }, detectedNamedImportCaseComparer);
|
|
166592
|
-
const processImportsOfSameModuleSpecifier = (importGroup) => {
|
|
166593
|
-
if (shouldRemove)
|
|
166594
|
-
importGroup = removeUnusedImports(importGroup, sourceFile, program);
|
|
166595
|
-
if (shouldCombine)
|
|
166596
|
-
importGroup = coalesceImportsWorker(importGroup, detectedModuleCaseComparer, specifierComparer, sourceFile);
|
|
166597
|
-
if (shouldSort)
|
|
166598
|
-
importGroup = stableSort(importGroup, (s1, s2) => compareImportsOrRequireStatements(s1, s2, detectedModuleCaseComparer));
|
|
166599
|
-
return importGroup;
|
|
166600
|
-
};
|
|
166601
|
-
organizeDeclsWorker(oldImportDecls, processImportsOfSameModuleSpecifier);
|
|
166602
|
-
}
|
|
166603
|
-
function organizeExportsWorker(oldExportDecls, specifierCaseComparer) {
|
|
166604
|
-
const useComparer = getNamedImportSpecifierComparer(preferences, specifierCaseComparer);
|
|
166605
|
-
organizeDeclsWorker(oldExportDecls, (group2) => coalesceExportsWorker(group2, useComparer));
|
|
166606
|
-
}
|
|
166607
|
-
}
|
|
166608
|
-
function getDetectionLists(preferences) {
|
|
166609
|
-
return {
|
|
166610
|
-
comparersToTest: typeof preferences.organizeImportsIgnoreCase === "boolean" ? [getOrganizeImportsStringComparer(preferences, preferences.organizeImportsIgnoreCase)] : [getOrganizeImportsStringComparer(
|
|
166611
|
-
preferences,
|
|
166612
|
-
/*ignoreCase*/
|
|
166613
|
-
true
|
|
166614
|
-
), getOrganizeImportsStringComparer(
|
|
166615
|
-
preferences,
|
|
166616
|
-
/*ignoreCase*/
|
|
166617
|
-
false
|
|
166618
|
-
)],
|
|
166619
|
-
typeOrdersToTest: preferences.organizeImportsTypeOrder ? [preferences.organizeImportsTypeOrder] : ["last", "inline", "first"]
|
|
166620
|
-
};
|
|
166621
166757
|
}
|
|
166622
166758
|
function groupByNewlineContiguous(sourceFile, decls) {
|
|
166623
166759
|
const scanner2 = createScanner(
|
|
@@ -166655,33 +166791,6 @@ function isNewGroup(sourceFile, decl, scanner2) {
|
|
|
166655
166791
|
}
|
|
166656
166792
|
return false;
|
|
166657
166793
|
}
|
|
166658
|
-
function getTopLevelExportGroups(sourceFile) {
|
|
166659
|
-
const topLevelExportGroups = [];
|
|
166660
|
-
const statements = sourceFile.statements;
|
|
166661
|
-
const len = length(statements);
|
|
166662
|
-
let i = 0;
|
|
166663
|
-
let groupIndex = 0;
|
|
166664
|
-
while (i < len) {
|
|
166665
|
-
if (isExportDeclaration(statements[i])) {
|
|
166666
|
-
if (topLevelExportGroups[groupIndex] === void 0) {
|
|
166667
|
-
topLevelExportGroups[groupIndex] = [];
|
|
166668
|
-
}
|
|
166669
|
-
const exportDecl = statements[i];
|
|
166670
|
-
if (exportDecl.moduleSpecifier) {
|
|
166671
|
-
topLevelExportGroups[groupIndex].push(exportDecl);
|
|
166672
|
-
i++;
|
|
166673
|
-
} else {
|
|
166674
|
-
while (i < len && isExportDeclaration(statements[i])) {
|
|
166675
|
-
topLevelExportGroups[groupIndex].push(statements[i++]);
|
|
166676
|
-
}
|
|
166677
|
-
groupIndex++;
|
|
166678
|
-
}
|
|
166679
|
-
} else {
|
|
166680
|
-
i++;
|
|
166681
|
-
}
|
|
166682
|
-
}
|
|
166683
|
-
return flatMap(topLevelExportGroups, (exportGroupDecls) => groupByNewlineContiguous(sourceFile, exportGroupDecls));
|
|
166684
|
-
}
|
|
166685
166794
|
function removeUnusedImports(oldImports, sourceFile, program) {
|
|
166686
166795
|
const typeChecker = program.getTypeChecker();
|
|
166687
166796
|
const compilerOptions = program.getCompilerOptions();
|
|
@@ -166733,38 +166842,18 @@ function removeUnusedImports(oldImports, sourceFile, program) {
|
|
|
166733
166842
|
return jsxElementsPresent && (identifier.text === jsxNamespace || jsxFragmentFactory && identifier.text === jsxFragmentFactory) && jsxModeNeedsExplicitImport(compilerOptions.jsx) || ts_FindAllReferences_exports.Core.isSymbolReferencedInFile(identifier, typeChecker, sourceFile);
|
|
166734
166843
|
}
|
|
166735
166844
|
}
|
|
166845
|
+
function hasModuleDeclarationMatchingSpecifier(sourceFile, moduleSpecifier) {
|
|
166846
|
+
const moduleSpecifierText = isStringLiteral(moduleSpecifier) && moduleSpecifier.text;
|
|
166847
|
+
return isString(moduleSpecifierText) && some(sourceFile.moduleAugmentations, (moduleName) => isStringLiteral(moduleName) && moduleName.text === moduleSpecifierText);
|
|
166848
|
+
}
|
|
166736
166849
|
function getExternalModuleName2(specifier) {
|
|
166737
166850
|
return specifier !== void 0 && isStringLiteralLike(specifier) ? specifier.text : void 0;
|
|
166738
166851
|
}
|
|
166739
|
-
function
|
|
166740
|
-
|
|
166741
|
-
|
|
166742
|
-
const regularImports = { defaultImports: [], namespaceImports: [], namedImports: [] };
|
|
166743
|
-
for (const importDeclaration of importGroup) {
|
|
166744
|
-
if (importDeclaration.importClause === void 0) {
|
|
166745
|
-
importWithoutClause = importWithoutClause || importDeclaration;
|
|
166746
|
-
continue;
|
|
166747
|
-
}
|
|
166748
|
-
const group2 = importDeclaration.importClause.isTypeOnly ? typeOnlyImports : regularImports;
|
|
166749
|
-
const { name, namedBindings } = importDeclaration.importClause;
|
|
166750
|
-
if (name) {
|
|
166751
|
-
group2.defaultImports.push(importDeclaration);
|
|
166752
|
-
}
|
|
166753
|
-
if (namedBindings) {
|
|
166754
|
-
if (isNamespaceImport(namedBindings)) {
|
|
166755
|
-
group2.namespaceImports.push(importDeclaration);
|
|
166756
|
-
} else {
|
|
166757
|
-
group2.namedImports.push(importDeclaration);
|
|
166758
|
-
}
|
|
166759
|
-
}
|
|
166760
|
-
}
|
|
166761
|
-
return {
|
|
166762
|
-
importWithoutClause,
|
|
166763
|
-
typeOnlyImports,
|
|
166764
|
-
regularImports
|
|
166765
|
-
};
|
|
166852
|
+
function coalesceImports(importGroup, ignoreCase, sourceFile, preferences) {
|
|
166853
|
+
const comparer = getOrganizeImportsOrdinalStringComparer(ignoreCase);
|
|
166854
|
+
return coalesceImportsWorker(importGroup, comparer, sourceFile, preferences);
|
|
166766
166855
|
}
|
|
166767
|
-
function coalesceImportsWorker(importGroup, comparer,
|
|
166856
|
+
function coalesceImportsWorker(importGroup, comparer, sourceFile, preferences) {
|
|
166768
166857
|
if (importGroup.length === 0) {
|
|
166769
166858
|
return importGroup;
|
|
166770
166859
|
}
|
|
@@ -166831,7 +166920,7 @@ function coalesceImportsWorker(importGroup, comparer, specifierComparer, sourceF
|
|
|
166831
166920
|
}
|
|
166832
166921
|
newImportSpecifiers.push(...getNewImportSpecifiers(namedImports));
|
|
166833
166922
|
const sortedImportSpecifiers = factory.createNodeArray(
|
|
166834
|
-
|
|
166923
|
+
sortSpecifiers(newImportSpecifiers, comparer, preferences),
|
|
166835
166924
|
firstNamedImport == null ? void 0 : firstNamedImport.importClause.namedBindings.elements.hasTrailingComma
|
|
166836
166925
|
);
|
|
166837
166926
|
const newNamedImports = sortedImportSpecifiers.length === 0 ? newDefaultImport ? void 0 : factory.createNamedImports(emptyArray) : firstNamedImport ? factory.updateNamedImports(firstNamedImport.importClause.namedBindings, sortedImportSpecifiers) : factory.createNamedImports(sortedImportSpecifiers);
|
|
@@ -166864,7 +166953,39 @@ function coalesceImportsWorker(importGroup, comparer, specifierComparer, sourceF
|
|
|
166864
166953
|
}
|
|
166865
166954
|
return coalescedImports;
|
|
166866
166955
|
}
|
|
166867
|
-
function
|
|
166956
|
+
function getCategorizedImports(importGroup) {
|
|
166957
|
+
let importWithoutClause;
|
|
166958
|
+
const typeOnlyImports = { defaultImports: [], namespaceImports: [], namedImports: [] };
|
|
166959
|
+
const regularImports = { defaultImports: [], namespaceImports: [], namedImports: [] };
|
|
166960
|
+
for (const importDeclaration of importGroup) {
|
|
166961
|
+
if (importDeclaration.importClause === void 0) {
|
|
166962
|
+
importWithoutClause = importWithoutClause || importDeclaration;
|
|
166963
|
+
continue;
|
|
166964
|
+
}
|
|
166965
|
+
const group2 = importDeclaration.importClause.isTypeOnly ? typeOnlyImports : regularImports;
|
|
166966
|
+
const { name, namedBindings } = importDeclaration.importClause;
|
|
166967
|
+
if (name) {
|
|
166968
|
+
group2.defaultImports.push(importDeclaration);
|
|
166969
|
+
}
|
|
166970
|
+
if (namedBindings) {
|
|
166971
|
+
if (isNamespaceImport(namedBindings)) {
|
|
166972
|
+
group2.namespaceImports.push(importDeclaration);
|
|
166973
|
+
} else {
|
|
166974
|
+
group2.namedImports.push(importDeclaration);
|
|
166975
|
+
}
|
|
166976
|
+
}
|
|
166977
|
+
}
|
|
166978
|
+
return {
|
|
166979
|
+
importWithoutClause,
|
|
166980
|
+
typeOnlyImports,
|
|
166981
|
+
regularImports
|
|
166982
|
+
};
|
|
166983
|
+
}
|
|
166984
|
+
function coalesceExports(exportGroup, ignoreCase, preferences) {
|
|
166985
|
+
const comparer = getOrganizeImportsOrdinalStringComparer(ignoreCase);
|
|
166986
|
+
return coalesceExportsWorker(exportGroup, comparer, preferences);
|
|
166987
|
+
}
|
|
166988
|
+
function coalesceExportsWorker(exportGroup, comparer, preferences) {
|
|
166868
166989
|
if (exportGroup.length === 0) {
|
|
166869
166990
|
return exportGroup;
|
|
166870
166991
|
}
|
|
@@ -166879,7 +167000,7 @@ function coalesceExportsWorker(exportGroup, specifierComparer) {
|
|
|
166879
167000
|
}
|
|
166880
167001
|
const newExportSpecifiers = [];
|
|
166881
167002
|
newExportSpecifiers.push(...flatMap(exportGroup2, (i) => i.exportClause && isNamedExports(i.exportClause) ? i.exportClause.elements : emptyArray));
|
|
166882
|
-
const sortedExportSpecifiers =
|
|
167003
|
+
const sortedExportSpecifiers = sortSpecifiers(newExportSpecifiers, comparer, preferences);
|
|
166883
167004
|
const exportDecl = exportGroup2[0];
|
|
166884
167005
|
coalescedExports.push(
|
|
166885
167006
|
factory.updateExportDeclaration(
|
|
@@ -166923,6 +167044,9 @@ function updateImportDeclarationAndClause(importDeclaration, name, namedBindings
|
|
|
166923
167044
|
importDeclaration.attributes
|
|
166924
167045
|
);
|
|
166925
167046
|
}
|
|
167047
|
+
function sortSpecifiers(specifiers, comparer, preferences) {
|
|
167048
|
+
return stableSort(specifiers, (s1, s2) => compareImportOrExportSpecifiers(s1, s2, comparer, preferences));
|
|
167049
|
+
}
|
|
166926
167050
|
function compareImportOrExportSpecifiers(s1, s2, comparer, preferences) {
|
|
166927
167051
|
switch (preferences == null ? void 0 : preferences.organizeImportsTypeOrder) {
|
|
166928
167052
|
case "first":
|
|
@@ -166933,14 +167057,15 @@ function compareImportOrExportSpecifiers(s1, s2, comparer, preferences) {
|
|
|
166933
167057
|
return compareBooleans(s1.isTypeOnly, s2.isTypeOnly) || comparer(s1.name.text, s2.name.text);
|
|
166934
167058
|
}
|
|
166935
167059
|
}
|
|
167060
|
+
function compareModuleSpecifiers2(m1, m2, ignoreCase) {
|
|
167061
|
+
const comparer = getOrganizeImportsOrdinalStringComparer(!!ignoreCase);
|
|
167062
|
+
return compareModuleSpecifiersWorker(m1, m2, comparer);
|
|
167063
|
+
}
|
|
166936
167064
|
function compareModuleSpecifiersWorker(m1, m2, comparer) {
|
|
166937
167065
|
const name1 = m1 === void 0 ? void 0 : getExternalModuleName2(m1);
|
|
166938
167066
|
const name2 = m2 === void 0 ? void 0 : getExternalModuleName2(m2);
|
|
166939
167067
|
return compareBooleans(name1 === void 0, name2 === void 0) || compareBooleans(isExternalModuleNameRelative(name1), isExternalModuleNameRelative(name2)) || comparer(name1, name2);
|
|
166940
167068
|
}
|
|
166941
|
-
function getModuleNamesFromDecls(decls) {
|
|
166942
|
-
return decls.map((s) => getExternalModuleName2(getModuleSpecifierExpression(s)) || "");
|
|
166943
|
-
}
|
|
166944
167069
|
function getModuleSpecifierExpression(declaration) {
|
|
166945
167070
|
var _a;
|
|
166946
167071
|
switch (declaration.kind) {
|
|
@@ -166952,114 +167077,164 @@ function getModuleSpecifierExpression(declaration) {
|
|
|
166952
167077
|
return declaration.declarationList.declarations[0].initializer.arguments[0];
|
|
166953
167078
|
}
|
|
166954
167079
|
}
|
|
166955
|
-
function
|
|
166956
|
-
|
|
166957
|
-
|
|
166958
|
-
|
|
166959
|
-
|
|
166960
|
-
return flatMap(namedImports, (namedImport) => map(tryGetNamedBindingElements(namedImport), (importSpecifier) => importSpecifier.name && importSpecifier.propertyName && importSpecifier.name.escapedText === importSpecifier.propertyName.escapedText ? factory.updateImportSpecifier(
|
|
166961
|
-
importSpecifier,
|
|
166962
|
-
importSpecifier.isTypeOnly,
|
|
166963
|
-
/*propertyName*/
|
|
166964
|
-
void 0,
|
|
166965
|
-
importSpecifier.name
|
|
166966
|
-
) : importSpecifier));
|
|
166967
|
-
}
|
|
166968
|
-
function tryGetNamedBindingElements(namedImport) {
|
|
166969
|
-
var _a;
|
|
166970
|
-
return ((_a = namedImport.importClause) == null ? void 0 : _a.namedBindings) && isNamedImports(namedImport.importClause.namedBindings) ? namedImport.importClause.namedBindings.elements : void 0;
|
|
166971
|
-
}
|
|
166972
|
-
function detectModuleSpecifierCaseBySort(importDeclsByGroup, comparersToTest) {
|
|
166973
|
-
const moduleSpecifiersByGroup = [];
|
|
166974
|
-
importDeclsByGroup.forEach((importGroup) => {
|
|
166975
|
-
moduleSpecifiersByGroup.push(getModuleNamesFromDecls(importGroup));
|
|
166976
|
-
});
|
|
166977
|
-
return detectCaseSensitivityBySort(moduleSpecifiersByGroup, comparersToTest);
|
|
167080
|
+
function detectSorting(sourceFile, preferences) {
|
|
167081
|
+
return detectSortingWorker(
|
|
167082
|
+
groupByNewlineContiguous(sourceFile, sourceFile.statements.filter(isImportDeclaration)),
|
|
167083
|
+
preferences
|
|
167084
|
+
);
|
|
166978
167085
|
}
|
|
166979
|
-
function
|
|
166980
|
-
|
|
166981
|
-
|
|
166982
|
-
|
|
166983
|
-
|
|
166984
|
-
|
|
166985
|
-
|
|
166986
|
-
|
|
166987
|
-
|
|
166988
|
-
|
|
166989
|
-
|
|
166990
|
-
|
|
166991
|
-
|
|
166992
|
-
|
|
166993
|
-
|
|
166994
|
-
|
|
166995
|
-
|
|
166996
|
-
|
|
166997
|
-
|
|
166998
|
-
|
|
166999
|
-
|
|
167000
|
-
|
|
167001
|
-
|
|
167002
|
-
|
|
167003
|
-
|
|
167004
|
-
|
|
167005
|
-
|
|
167006
|
-
const bestComparer = { first: comparersToTest[0], last: comparersToTest[0], inline: comparersToTest[0] };
|
|
167007
|
-
for (const curComparer of comparersToTest) {
|
|
167008
|
-
const currDiff = { first: 0, last: 0, inline: 0 };
|
|
167009
|
-
for (const importDecl of namedImportsByDecl) {
|
|
167010
|
-
for (const typeOrder of typesToTest) {
|
|
167011
|
-
currDiff[typeOrder] = (currDiff[typeOrder] ?? 0) + measureSortedness(importDecl, (n1, n2) => compareImportOrExportSpecifiers(n1, n2, curComparer, { organizeImportsTypeOrder: typeOrder }));
|
|
167086
|
+
function detectSortingWorker(importGroups, preferences) {
|
|
167087
|
+
const collateCaseSensitive = getOrganizeImportsComparer(
|
|
167088
|
+
preferences,
|
|
167089
|
+
/*ignoreCase*/
|
|
167090
|
+
false
|
|
167091
|
+
);
|
|
167092
|
+
const collateCaseInsensitive = getOrganizeImportsComparer(
|
|
167093
|
+
preferences,
|
|
167094
|
+
/*ignoreCase*/
|
|
167095
|
+
true
|
|
167096
|
+
);
|
|
167097
|
+
let sortState = 3 /* Both */;
|
|
167098
|
+
let seenUnsortedGroup = false;
|
|
167099
|
+
for (const importGroup of importGroups) {
|
|
167100
|
+
if (importGroup.length > 1) {
|
|
167101
|
+
const moduleSpecifierSort = detectSortCaseSensitivity(
|
|
167102
|
+
importGroup,
|
|
167103
|
+
(i) => {
|
|
167104
|
+
var _a;
|
|
167105
|
+
return ((_a = tryCast(i.moduleSpecifier, isStringLiteral)) == null ? void 0 : _a.text) ?? "";
|
|
167106
|
+
},
|
|
167107
|
+
collateCaseSensitive,
|
|
167108
|
+
collateCaseInsensitive
|
|
167109
|
+
);
|
|
167110
|
+
if (moduleSpecifierSort) {
|
|
167111
|
+
sortState &= moduleSpecifierSort;
|
|
167112
|
+
seenUnsortedGroup = true;
|
|
167012
167113
|
}
|
|
167013
|
-
|
|
167014
|
-
|
|
167015
|
-
const typeOrder = key;
|
|
167016
|
-
if (currDiff[typeOrder] < bestDiff[typeOrder]) {
|
|
167017
|
-
bestDiff[typeOrder] = currDiff[typeOrder];
|
|
167018
|
-
bestComparer[typeOrder] = curComparer;
|
|
167114
|
+
if (!sortState) {
|
|
167115
|
+
return sortState;
|
|
167019
167116
|
}
|
|
167020
167117
|
}
|
|
167021
|
-
|
|
167022
|
-
|
|
167023
|
-
|
|
167024
|
-
|
|
167025
|
-
|
|
167026
|
-
|
|
167027
|
-
|
|
167028
|
-
|
|
167118
|
+
const declarationWithNamedImports = find(
|
|
167119
|
+
importGroup,
|
|
167120
|
+
(i) => {
|
|
167121
|
+
var _a, _b;
|
|
167122
|
+
return ((_b = tryCast((_a = i.importClause) == null ? void 0 : _a.namedBindings, isNamedImports)) == null ? void 0 : _b.elements.length) > 1;
|
|
167123
|
+
}
|
|
167124
|
+
);
|
|
167125
|
+
if (declarationWithNamedImports) {
|
|
167126
|
+
const namedImportSort = detectImportSpecifierSorting(declarationWithNamedImports.importClause.namedBindings.elements, preferences);
|
|
167127
|
+
if (namedImportSort) {
|
|
167128
|
+
sortState &= namedImportSort;
|
|
167129
|
+
seenUnsortedGroup = true;
|
|
167130
|
+
}
|
|
167131
|
+
if (!sortState) {
|
|
167132
|
+
return sortState;
|
|
167029
167133
|
}
|
|
167030
|
-
return { namedImportComparer: bestComparer[bestTypeOrder], typeOrder: bestTypeOrder, isSorted: bestDiff[bestTypeOrder] === 0 };
|
|
167031
167134
|
}
|
|
167032
|
-
|
|
167033
|
-
|
|
167034
|
-
function measureSortedness(arr, comparer) {
|
|
167035
|
-
let i = 0;
|
|
167036
|
-
for (let j = 0; j < arr.length - 1; j++) {
|
|
167037
|
-
if (comparer(arr[j], arr[j + 1]) > 0) {
|
|
167038
|
-
i++;
|
|
167135
|
+
if (sortState !== 3 /* Both */) {
|
|
167136
|
+
return sortState;
|
|
167039
167137
|
}
|
|
167040
167138
|
}
|
|
167041
|
-
return
|
|
167139
|
+
return seenUnsortedGroup ? 0 /* None */ : sortState;
|
|
167042
167140
|
}
|
|
167043
|
-
function
|
|
167044
|
-
|
|
167045
|
-
|
|
167046
|
-
|
|
167047
|
-
|
|
167048
|
-
|
|
167049
|
-
|
|
167050
|
-
|
|
167051
|
-
|
|
167052
|
-
|
|
167141
|
+
function detectImportDeclarationSorting(imports, preferences) {
|
|
167142
|
+
const collateCaseSensitive = getOrganizeImportsComparer(
|
|
167143
|
+
preferences,
|
|
167144
|
+
/*ignoreCase*/
|
|
167145
|
+
false
|
|
167146
|
+
);
|
|
167147
|
+
const collateCaseInsensitive = getOrganizeImportsComparer(
|
|
167148
|
+
preferences,
|
|
167149
|
+
/*ignoreCase*/
|
|
167150
|
+
true
|
|
167151
|
+
);
|
|
167152
|
+
return detectSortCaseSensitivity(
|
|
167153
|
+
imports,
|
|
167154
|
+
(s) => getExternalModuleName2(getModuleSpecifierExpression(s)) || "",
|
|
167155
|
+
collateCaseSensitive,
|
|
167156
|
+
collateCaseInsensitive
|
|
167157
|
+
);
|
|
167158
|
+
}
|
|
167159
|
+
var ImportSpecifierSortingCache = class {
|
|
167160
|
+
has([specifiers, preferences]) {
|
|
167161
|
+
if (this._lastPreferences !== preferences || !this._cache)
|
|
167162
|
+
return false;
|
|
167163
|
+
return this._cache.has(specifiers);
|
|
167164
|
+
}
|
|
167165
|
+
get([specifiers, preferences]) {
|
|
167166
|
+
if (this._lastPreferences !== preferences || !this._cache)
|
|
167167
|
+
return void 0;
|
|
167168
|
+
return this._cache.get(specifiers);
|
|
167169
|
+
}
|
|
167170
|
+
set([specifiers, preferences], value) {
|
|
167171
|
+
if (this._lastPreferences !== preferences) {
|
|
167172
|
+
this._lastPreferences = preferences;
|
|
167173
|
+
this._cache = void 0;
|
|
167053
167174
|
}
|
|
167054
|
-
|
|
167055
|
-
|
|
167056
|
-
|
|
167175
|
+
this._cache ?? (this._cache = /* @__PURE__ */ new WeakMap());
|
|
167176
|
+
this._cache.set(specifiers, value);
|
|
167177
|
+
}
|
|
167178
|
+
};
|
|
167179
|
+
var detectImportSpecifierSorting = memoizeCached((specifiers, preferences) => {
|
|
167180
|
+
switch (preferences.organizeImportsTypeOrder) {
|
|
167181
|
+
case "first":
|
|
167182
|
+
if (!arrayIsSorted(specifiers, (s1, s2) => compareBooleans(s2.isTypeOnly, s1.isTypeOnly)))
|
|
167183
|
+
return 0 /* None */;
|
|
167184
|
+
break;
|
|
167185
|
+
case "inline":
|
|
167186
|
+
if (!arrayIsSorted(specifiers, (s1, s2) => {
|
|
167187
|
+
const comparer = getStringComparer(
|
|
167188
|
+
/*ignoreCase*/
|
|
167189
|
+
true
|
|
167190
|
+
);
|
|
167191
|
+
return comparer(s1.name.text, s2.name.text);
|
|
167192
|
+
})) {
|
|
167193
|
+
return 0 /* None */;
|
|
167194
|
+
}
|
|
167195
|
+
break;
|
|
167196
|
+
default:
|
|
167197
|
+
if (!arrayIsSorted(specifiers, (s1, s2) => compareBooleans(s1.isTypeOnly, s2.isTypeOnly)))
|
|
167198
|
+
return 0 /* None */;
|
|
167199
|
+
break;
|
|
167200
|
+
}
|
|
167201
|
+
const collateCaseSensitive = getOrganizeImportsComparer(
|
|
167202
|
+
preferences,
|
|
167203
|
+
/*ignoreCase*/
|
|
167204
|
+
false
|
|
167205
|
+
);
|
|
167206
|
+
const collateCaseInsensitive = getOrganizeImportsComparer(
|
|
167207
|
+
preferences,
|
|
167208
|
+
/*ignoreCase*/
|
|
167209
|
+
true
|
|
167210
|
+
);
|
|
167211
|
+
if (preferences.organizeImportsTypeOrder !== "inline") {
|
|
167212
|
+
const { type: regularImports, regular: typeImports } = groupBy(specifiers, (s) => s.isTypeOnly ? "type" : "regular");
|
|
167213
|
+
const regularCaseSensitivity = (regularImports == null ? void 0 : regularImports.length) ? detectSortCaseSensitivity(regularImports, (specifier) => specifier.name.text, collateCaseSensitive, collateCaseInsensitive) : void 0;
|
|
167214
|
+
const typeCaseSensitivity = (typeImports == null ? void 0 : typeImports.length) ? detectSortCaseSensitivity(typeImports, (specifier) => specifier.name.text ?? "", collateCaseSensitive, collateCaseInsensitive) : void 0;
|
|
167215
|
+
if (regularCaseSensitivity === void 0) {
|
|
167216
|
+
return typeCaseSensitivity ?? 0 /* None */;
|
|
167217
|
+
}
|
|
167218
|
+
if (typeCaseSensitivity === void 0) {
|
|
167219
|
+
return regularCaseSensitivity;
|
|
167220
|
+
}
|
|
167221
|
+
if (regularCaseSensitivity === 0 /* None */ || typeCaseSensitivity === 0 /* None */) {
|
|
167222
|
+
return 0 /* None */;
|
|
167057
167223
|
}
|
|
167224
|
+
return typeCaseSensitivity & regularCaseSensitivity;
|
|
167058
167225
|
}
|
|
167059
|
-
return
|
|
167060
|
-
|
|
167061
|
-
|
|
167062
|
-
|
|
167226
|
+
return detectSortCaseSensitivity(specifiers, (specifier) => specifier.name.text, collateCaseSensitive, collateCaseInsensitive);
|
|
167227
|
+
}, new ImportSpecifierSortingCache());
|
|
167228
|
+
function getImportDeclarationInsertionIndex(sortedImports, newImport, comparer) {
|
|
167229
|
+
const index = binarySearch(sortedImports, newImport, identity, (a, b) => compareImportsOrRequireStatements(a, b, comparer));
|
|
167230
|
+
return index < 0 ? ~index : index;
|
|
167231
|
+
}
|
|
167232
|
+
function getImportSpecifierInsertionIndex(sortedImports, newImport, comparer, preferences) {
|
|
167233
|
+
const index = binarySearch(sortedImports, newImport, identity, (s1, s2) => compareImportOrExportSpecifiers(s1, s2, comparer, preferences));
|
|
167234
|
+
return index < 0 ? ~index : index;
|
|
167235
|
+
}
|
|
167236
|
+
function compareImportsOrRequireStatements(s1, s2, comparer) {
|
|
167237
|
+
return compareModuleSpecifiersWorker(getModuleSpecifierExpression(s1), getModuleSpecifierExpression(s2), comparer) || compareImportKind(s1, s2);
|
|
167063
167238
|
}
|
|
167064
167239
|
function compareImportKind(s1, s2) {
|
|
167065
167240
|
return compareValues(getImportKindOrder(s1), getImportKindOrder(s2));
|
|
@@ -167083,6 +167258,19 @@ function getImportKindOrder(s1) {
|
|
|
167083
167258
|
return 6;
|
|
167084
167259
|
}
|
|
167085
167260
|
}
|
|
167261
|
+
function getNewImportSpecifiers(namedImports) {
|
|
167262
|
+
return flatMap(namedImports, (namedImport) => map(tryGetNamedBindingElements(namedImport), (importSpecifier) => importSpecifier.name && importSpecifier.propertyName && importSpecifier.name.escapedText === importSpecifier.propertyName.escapedText ? factory.updateImportSpecifier(
|
|
167263
|
+
importSpecifier,
|
|
167264
|
+
importSpecifier.isTypeOnly,
|
|
167265
|
+
/*propertyName*/
|
|
167266
|
+
void 0,
|
|
167267
|
+
importSpecifier.name
|
|
167268
|
+
) : importSpecifier));
|
|
167269
|
+
}
|
|
167270
|
+
function tryGetNamedBindingElements(namedImport) {
|
|
167271
|
+
var _a;
|
|
167272
|
+
return ((_a = namedImport.importClause) == null ? void 0 : _a.namedBindings) && isNamedImports(namedImport.importClause.namedBindings) ? namedImport.importClause.namedBindings.elements : void 0;
|
|
167273
|
+
}
|
|
167086
167274
|
function getOrganizeImportsOrdinalStringComparer(ignoreCase) {
|
|
167087
167275
|
return ignoreCase ? compareStringsCaseInsensitiveEslintCompatible : compareStringsCaseSensitive;
|
|
167088
167276
|
}
|
|
@@ -167110,61 +167298,40 @@ function getOrganizeImportsLocale(preferences) {
|
|
|
167110
167298
|
const resolvedLocale = supportedLocales.length ? supportedLocales[0] : "en";
|
|
167111
167299
|
return resolvedLocale;
|
|
167112
167300
|
}
|
|
167113
|
-
function
|
|
167301
|
+
function getOrganizeImportsComparer(preferences, ignoreCase) {
|
|
167114
167302
|
const collation = preferences.organizeImportsCollation ?? "ordinal";
|
|
167115
167303
|
return collation === "unicode" ? getOrganizeImportsUnicodeStringComparer(ignoreCase, preferences) : getOrganizeImportsOrdinalStringComparer(ignoreCase);
|
|
167116
167304
|
}
|
|
167117
|
-
function
|
|
167118
|
-
|
|
167305
|
+
function getOrganizeImportsComparerWithDetection(preferences, detectIgnoreCase) {
|
|
167306
|
+
const ignoreCase = typeof preferences.organizeImportsIgnoreCase === "boolean" ? preferences.organizeImportsIgnoreCase : (detectIgnoreCase == null ? void 0 : detectIgnoreCase()) ?? false;
|
|
167307
|
+
return getOrganizeImportsComparer(preferences, ignoreCase);
|
|
167119
167308
|
}
|
|
167120
|
-
function
|
|
167121
|
-
const
|
|
167122
|
-
|
|
167123
|
-
|
|
167124
|
-
|
|
167125
|
-
|
|
167126
|
-
|
|
167127
|
-
|
|
167128
|
-
|
|
167129
|
-
|
|
167130
|
-
|
|
167131
|
-
const
|
|
167132
|
-
|
|
167133
|
-
|
|
167134
|
-
|
|
167135
|
-
|
|
167136
|
-
|
|
167137
|
-
|
|
167138
|
-
|
|
167139
|
-
|
|
167309
|
+
function getTopLevelExportGroups(sourceFile) {
|
|
167310
|
+
const topLevelExportGroups = [];
|
|
167311
|
+
const statements = sourceFile.statements;
|
|
167312
|
+
const len = length(statements);
|
|
167313
|
+
let i = 0;
|
|
167314
|
+
let groupIndex = 0;
|
|
167315
|
+
while (i < len) {
|
|
167316
|
+
if (isExportDeclaration(statements[i])) {
|
|
167317
|
+
if (topLevelExportGroups[groupIndex] === void 0) {
|
|
167318
|
+
topLevelExportGroups[groupIndex] = [];
|
|
167319
|
+
}
|
|
167320
|
+
const exportDecl = statements[i];
|
|
167321
|
+
if (exportDecl.moduleSpecifier) {
|
|
167322
|
+
topLevelExportGroups[groupIndex].push(exportDecl);
|
|
167323
|
+
i++;
|
|
167324
|
+
} else {
|
|
167325
|
+
while (i < len && isExportDeclaration(statements[i])) {
|
|
167326
|
+
topLevelExportGroups[groupIndex].push(statements[i++]);
|
|
167327
|
+
}
|
|
167328
|
+
groupIndex++;
|
|
167140
167329
|
}
|
|
167330
|
+
} else {
|
|
167331
|
+
i++;
|
|
167141
167332
|
}
|
|
167142
167333
|
}
|
|
167143
|
-
return
|
|
167144
|
-
}
|
|
167145
|
-
function getImportDeclarationInsertionIndex(sortedImports, newImport, comparer) {
|
|
167146
|
-
const index = binarySearch(sortedImports, newImport, identity, (a, b) => compareImportsOrRequireStatements(a, b, comparer));
|
|
167147
|
-
return index < 0 ? ~index : index;
|
|
167148
|
-
}
|
|
167149
|
-
function getImportSpecifierInsertionIndex(sortedImports, newImport, comparer) {
|
|
167150
|
-
const index = binarySearch(sortedImports, newImport, identity, comparer);
|
|
167151
|
-
return index < 0 ? ~index : index;
|
|
167152
|
-
}
|
|
167153
|
-
function compareImportsOrRequireStatements(s1, s2, comparer) {
|
|
167154
|
-
return compareModuleSpecifiersWorker(getModuleSpecifierExpression(s1), getModuleSpecifierExpression(s2), comparer) || compareImportKind(s1, s2);
|
|
167155
|
-
}
|
|
167156
|
-
function testCoalesceImports(importGroup, ignoreCase, sourceFile, preferences) {
|
|
167157
|
-
const comparer = getOrganizeImportsOrdinalStringComparer(ignoreCase);
|
|
167158
|
-
const specifierComparer = getNamedImportSpecifierComparer({ organizeImportsTypeOrder: preferences == null ? void 0 : preferences.organizeImportsTypeOrder }, comparer);
|
|
167159
|
-
return coalesceImportsWorker(importGroup, comparer, specifierComparer, sourceFile);
|
|
167160
|
-
}
|
|
167161
|
-
function testCoalesceExports(exportGroup, ignoreCase, preferences) {
|
|
167162
|
-
const comparer = (s1, s2) => compareImportOrExportSpecifiers(s1, s2, getOrganizeImportsOrdinalStringComparer(ignoreCase), { organizeImportsTypeOrder: (preferences == null ? void 0 : preferences.organizeImportsTypeOrder) ?? "last" });
|
|
167163
|
-
return coalesceExportsWorker(exportGroup, comparer);
|
|
167164
|
-
}
|
|
167165
|
-
function compareModuleSpecifiers2(m1, m2, ignoreCase) {
|
|
167166
|
-
const comparer = getOrganizeImportsOrdinalStringComparer(!!ignoreCase);
|
|
167167
|
-
return compareModuleSpecifiersWorker(m1, m2, comparer);
|
|
167334
|
+
return flatMap(topLevelExportGroups, (exportGroupDecls) => groupByNewlineContiguous(sourceFile, exportGroupDecls));
|
|
167168
167335
|
}
|
|
167169
167336
|
|
|
167170
167337
|
// src/services/_namespaces/ts.OutliningElementsCollector.ts
|
|
@@ -173262,6 +173429,7 @@ __export(ts_exports2, {
|
|
|
173262
173429
|
JsxEmit: () => JsxEmit,
|
|
173263
173430
|
JsxFlags: () => JsxFlags,
|
|
173264
173431
|
JsxReferenceKind: () => JsxReferenceKind,
|
|
173432
|
+
LanguageFeatureMinimumTarget: () => LanguageFeatureMinimumTarget,
|
|
173265
173433
|
LanguageServiceMode: () => LanguageServiceMode,
|
|
173266
173434
|
LanguageVariant: () => LanguageVariant,
|
|
173267
173435
|
LexicalEnvironmentFlags: () => LexicalEnvironmentFlags,
|
|
@@ -173317,6 +173485,7 @@ __export(ts_exports2, {
|
|
|
173317
173485
|
SignatureKind: () => SignatureKind,
|
|
173318
173486
|
SmartSelectionRange: () => ts_SmartSelectionRange_exports,
|
|
173319
173487
|
SnippetKind: () => SnippetKind,
|
|
173488
|
+
SortKind: () => SortKind,
|
|
173320
173489
|
StructureIsReused: () => StructureIsReused,
|
|
173321
173490
|
SymbolAccessibility: () => SymbolAccessibility,
|
|
173322
173491
|
SymbolDisplay: () => ts_SymbolDisplay_exports,
|
|
@@ -173651,6 +173820,7 @@ __export(ts_exports2, {
|
|
|
173651
173820
|
defaultIncludeSpec: () => defaultIncludeSpec,
|
|
173652
173821
|
defaultInitCompilerOptions: () => defaultInitCompilerOptions,
|
|
173653
173822
|
defaultMaximumTruncationLength: () => defaultMaximumTruncationLength,
|
|
173823
|
+
detectSortCaseSensitivity: () => detectSortCaseSensitivity,
|
|
173654
173824
|
diagnosticCategoryName: () => diagnosticCategoryName,
|
|
173655
173825
|
diagnosticToString: () => diagnosticToString,
|
|
173656
173826
|
directoryProbablyExists: () => directoryProbablyExists,
|
|
@@ -185916,10 +186086,10 @@ ${e.message}`;
|
|
|
185916
186086
|
}
|
|
185917
186087
|
return simplifiedResult ? codeActions.map((codeAction) => this.mapCodeFixAction(codeAction)) : codeActions;
|
|
185918
186088
|
}
|
|
185919
|
-
getCombinedCodeFix({ scope, fixId:
|
|
186089
|
+
getCombinedCodeFix({ scope, fixId: fixId53 }, simplifiedResult) {
|
|
185920
186090
|
Debug.assert(scope.type === "file");
|
|
185921
186091
|
const { file, project } = this.getFileAndProject(scope.args);
|
|
185922
|
-
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));
|
|
185923
186093
|
if (simplifiedResult) {
|
|
185924
186094
|
return { changes: this.mapTextChangesToCodeEdits(res.changes), commands: res.commands };
|
|
185925
186095
|
} else {
|
|
@@ -185958,8 +186128,8 @@ ${e.message}`;
|
|
|
185958
186128
|
mapCodeAction({ description: description3, changes, commands }) {
|
|
185959
186129
|
return { description: description3, changes: this.mapTextChangesToCodeEdits(changes), commands };
|
|
185960
186130
|
}
|
|
185961
|
-
mapCodeFixAction({ fixName: fixName8, description: description3, changes, commands, fixId:
|
|
185962
|
-
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 };
|
|
185963
186133
|
}
|
|
185964
186134
|
mapTextChangesToCodeEdits(textChanges2) {
|
|
185965
186135
|
return textChanges2.map((change) => this.mapTextChangeToCodeEdit(change));
|
|
@@ -188035,6 +188205,7 @@ start(initializeNodeSystem(), require("os").platform());
|
|
|
188035
188205
|
JsxEmit,
|
|
188036
188206
|
JsxFlags,
|
|
188037
188207
|
JsxReferenceKind,
|
|
188208
|
+
LanguageFeatureMinimumTarget,
|
|
188038
188209
|
LanguageServiceMode,
|
|
188039
188210
|
LanguageVariant,
|
|
188040
188211
|
LexicalEnvironmentFlags,
|
|
@@ -188090,6 +188261,7 @@ start(initializeNodeSystem(), require("os").platform());
|
|
|
188090
188261
|
SignatureKind,
|
|
188091
188262
|
SmartSelectionRange,
|
|
188092
188263
|
SnippetKind,
|
|
188264
|
+
SortKind,
|
|
188093
188265
|
StructureIsReused,
|
|
188094
188266
|
SymbolAccessibility,
|
|
188095
188267
|
SymbolDisplay,
|
|
@@ -188424,6 +188596,7 @@ start(initializeNodeSystem(), require("os").platform());
|
|
|
188424
188596
|
defaultIncludeSpec,
|
|
188425
188597
|
defaultInitCompilerOptions,
|
|
188426
188598
|
defaultMaximumTruncationLength,
|
|
188599
|
+
detectSortCaseSensitivity,
|
|
188427
188600
|
diagnosticCategoryName,
|
|
188428
188601
|
diagnosticToString,
|
|
188429
188602
|
directoryProbablyExists,
|