typescript 4.6.0-dev.20220111 → 4.6.0-dev.20220115
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 +341 -118
- package/lib/tsserver.js +553 -224
- package/lib/tsserverlibrary.js +553 -224
- package/lib/typescript.js +499 -203
- package/lib/typescriptServices.js +499 -203
- package/lib/typingsInstaller.js +421 -144
- package/package.json +1 -1
|
@@ -294,7 +294,7 @@ var ts;
|
|
|
294
294
|
// The following is baselined as a literal template type without intervention
|
|
295
295
|
/** The version of the TypeScript compiler release */
|
|
296
296
|
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
297
|
-
ts.version = ts.versionMajorMinor + ".0-dev.
|
|
297
|
+
ts.version = ts.versionMajorMinor + ".0-dev.20220115";
|
|
298
298
|
/* @internal */
|
|
299
299
|
var Comparison;
|
|
300
300
|
(function (Comparison) {
|
|
@@ -8482,7 +8482,7 @@ var ts;
|
|
|
8482
8482
|
Parameter_0_cannot_reference_identifier_1_declared_after_it: diag(2373, ts.DiagnosticCategory.Error, "Parameter_0_cannot_reference_identifier_1_declared_after_it_2373", "Parameter '{0}' cannot reference identifier '{1}' declared after it."),
|
|
8483
8483
|
Duplicate_index_signature_for_type_0: diag(2374, ts.DiagnosticCategory.Error, "Duplicate_index_signature_for_type_0_2374", "Duplicate index signature for type '{0}'."),
|
|
8484
8484
|
Type_0_is_not_assignable_to_type_1_with_exactOptionalPropertyTypes_Colon_true_Consider_adding_undefined_to_the_types_of_the_target_s_properties: diag(2375, ts.DiagnosticCategory.Error, "Type_0_is_not_assignable_to_type_1_with_exactOptionalPropertyTypes_Colon_true_Consider_adding_undefi_2375", "Type '{0}' is not assignable to type '{1}' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the types of the target's properties."),
|
|
8485
|
-
|
|
8485
|
+
A_super_call_must_be_the_first_statement_in_the_constructor_to_refer_to_super_or_this_when_a_derived_class_contains_initialized_properties_parameter_properties_or_private_identifiers: diag(2376, ts.DiagnosticCategory.Error, "A_super_call_must_be_the_first_statement_in_the_constructor_to_refer_to_super_or_this_when_a_derived_2376", "A 'super' call must be the first statement in the constructor to refer to 'super' or 'this' when a derived class contains initialized properties, parameter properties, or private identifiers."),
|
|
8486
8486
|
Constructors_for_derived_classes_must_contain_a_super_call: diag(2377, ts.DiagnosticCategory.Error, "Constructors_for_derived_classes_must_contain_a_super_call_2377", "Constructors for derived classes must contain a 'super' call."),
|
|
8487
8487
|
A_get_accessor_must_return_a_value: diag(2378, ts.DiagnosticCategory.Error, "A_get_accessor_must_return_a_value_2378", "A 'get' accessor must return a value."),
|
|
8488
8488
|
Argument_of_type_0_is_not_assignable_to_parameter_of_type_1_with_exactOptionalPropertyTypes_Colon_true_Consider_adding_undefined_to_the_types_of_the_target_s_properties: diag(2379, ts.DiagnosticCategory.Error, "Argument_of_type_0_is_not_assignable_to_parameter_of_type_1_with_exactOptionalPropertyTypes_Colon_tr_2379", "Argument of type '{0}' is not assignable to parameter of type '{1}' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the types of the target's properties."),
|
|
@@ -8505,6 +8505,7 @@ var ts;
|
|
|
8505
8505
|
constructor_cannot_be_used_as_a_parameter_property_name: diag(2398, ts.DiagnosticCategory.Error, "constructor_cannot_be_used_as_a_parameter_property_name_2398", "'constructor' cannot be used as a parameter property name."),
|
|
8506
8506
|
Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference: diag(2399, ts.DiagnosticCategory.Error, "Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference_2399", "Duplicate identifier '_this'. Compiler uses variable declaration '_this' to capture 'this' reference."),
|
|
8507
8507
|
Expression_resolves_to_variable_declaration_this_that_compiler_uses_to_capture_this_reference: diag(2400, ts.DiagnosticCategory.Error, "Expression_resolves_to_variable_declaration_this_that_compiler_uses_to_capture_this_reference_2400", "Expression resolves to variable declaration '_this' that compiler uses to capture 'this' reference."),
|
|
8508
|
+
A_super_call_must_be_a_root_level_statement_within_a_constructor_of_a_derived_class_that_contains_initialized_properties_parameter_properties_or_private_identifiers: diag(2401, ts.DiagnosticCategory.Error, "A_super_call_must_be_a_root_level_statement_within_a_constructor_of_a_derived_class_that_contains_in_2401", "A 'super' call must be a root-level statement within a constructor of a derived class that contains initialized properties, parameter properties, or private identifiers."),
|
|
8508
8509
|
Expression_resolves_to_super_that_compiler_uses_to_capture_base_class_reference: diag(2402, ts.DiagnosticCategory.Error, "Expression_resolves_to_super_that_compiler_uses_to_capture_base_class_reference_2402", "Expression resolves to '_super' that compiler uses to capture base class reference."),
|
|
8509
8510
|
Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2: diag(2403, ts.DiagnosticCategory.Error, "Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_t_2403", "Subsequent variable declarations must have the same type. Variable '{0}' must be of type '{1}', but here has type '{2}'."),
|
|
8510
8511
|
The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation: diag(2404, ts.DiagnosticCategory.Error, "The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation_2404", "The left-hand side of a 'for...in' statement cannot use a type annotation."),
|
|
@@ -15665,6 +15666,34 @@ var ts;
|
|
|
15665
15666
|
}
|
|
15666
15667
|
}
|
|
15667
15668
|
ts.getThisContainer = getThisContainer;
|
|
15669
|
+
/**
|
|
15670
|
+
* @returns Whether the node creates a new 'this' scope for its children.
|
|
15671
|
+
*/
|
|
15672
|
+
function isThisContainerOrFunctionBlock(node) {
|
|
15673
|
+
switch (node.kind) {
|
|
15674
|
+
// Arrow functions use the same scope, but may do so in a "delayed" manner
|
|
15675
|
+
// For example, `const getThis = () => this` may be before a super() call in a derived constructor
|
|
15676
|
+
case 213 /* ArrowFunction */:
|
|
15677
|
+
case 255 /* FunctionDeclaration */:
|
|
15678
|
+
case 212 /* FunctionExpression */:
|
|
15679
|
+
case 166 /* PropertyDeclaration */:
|
|
15680
|
+
return true;
|
|
15681
|
+
case 234 /* Block */:
|
|
15682
|
+
switch (node.parent.kind) {
|
|
15683
|
+
case 170 /* Constructor */:
|
|
15684
|
+
case 168 /* MethodDeclaration */:
|
|
15685
|
+
case 171 /* GetAccessor */:
|
|
15686
|
+
case 172 /* SetAccessor */:
|
|
15687
|
+
// Object properties can have computed names; only method-like bodies start a new scope
|
|
15688
|
+
return true;
|
|
15689
|
+
default:
|
|
15690
|
+
return false;
|
|
15691
|
+
}
|
|
15692
|
+
default:
|
|
15693
|
+
return false;
|
|
15694
|
+
}
|
|
15695
|
+
}
|
|
15696
|
+
ts.isThisContainerOrFunctionBlock = isThisContainerOrFunctionBlock;
|
|
15668
15697
|
function isInTopLevelContext(node) {
|
|
15669
15698
|
// The name of a class or function declaration is a BindingIdentifier in its surrounding scope.
|
|
15670
15699
|
if (ts.isIdentifier(node) && (ts.isClassDeclaration(node.parent) || ts.isFunctionDeclaration(node.parent)) && node.parent.name === node) {
|
|
@@ -19985,16 +20014,6 @@ var ts;
|
|
|
19985
20014
|
(symlinkedDirectories || (symlinkedDirectories = new ts.Map())).set(symlinkPath, real);
|
|
19986
20015
|
}
|
|
19987
20016
|
},
|
|
19988
|
-
setSymlinkedDirectoryFromSymlinkedFile: function (symlink, real) {
|
|
19989
|
-
this.setSymlinkedFile(ts.toPath(symlink, cwd, getCanonicalFileName), real);
|
|
19990
|
-
var _a = guessDirectorySymlink(real, symlink, cwd, getCanonicalFileName) || ts.emptyArray, commonResolved = _a[0], commonOriginal = _a[1];
|
|
19991
|
-
if (commonResolved && commonOriginal) {
|
|
19992
|
-
this.setSymlinkedDirectory(commonOriginal, {
|
|
19993
|
-
real: commonResolved,
|
|
19994
|
-
realPath: ts.toPath(commonResolved, cwd, getCanonicalFileName),
|
|
19995
|
-
});
|
|
19996
|
-
}
|
|
19997
|
-
},
|
|
19998
20017
|
setSymlinksFromResolutions: function (files, typeReferenceDirectives) {
|
|
19999
20018
|
var _this = this;
|
|
20000
20019
|
var _a;
|
|
@@ -26261,7 +26280,7 @@ var ts;
|
|
|
26261
26280
|
* @param visitor Optional callback used to visit any custom prologue directives.
|
|
26262
26281
|
*/
|
|
26263
26282
|
function copyPrologue(source, target, ensureUseStrict, visitor) {
|
|
26264
|
-
var offset = copyStandardPrologue(source, target, ensureUseStrict);
|
|
26283
|
+
var offset = copyStandardPrologue(source, target, 0, ensureUseStrict);
|
|
26265
26284
|
return copyCustomPrologue(source, target, offset, visitor);
|
|
26266
26285
|
}
|
|
26267
26286
|
function isUseStrictPrologue(node) {
|
|
@@ -26274,12 +26293,14 @@ var ts;
|
|
|
26274
26293
|
* Copies only the standard (string-expression) prologue-directives into the target statement-array.
|
|
26275
26294
|
* @param source origin statements array
|
|
26276
26295
|
* @param target result statements array
|
|
26296
|
+
* @param statementOffset The offset at which to begin the copy.
|
|
26277
26297
|
* @param ensureUseStrict boolean determining whether the function need to add prologue-directives
|
|
26298
|
+
* @returns Count of how many directive statements were copied.
|
|
26278
26299
|
*/
|
|
26279
|
-
function copyStandardPrologue(source, target, ensureUseStrict) {
|
|
26300
|
+
function copyStandardPrologue(source, target, statementOffset, ensureUseStrict) {
|
|
26301
|
+
if (statementOffset === void 0) { statementOffset = 0; }
|
|
26280
26302
|
ts.Debug.assert(target.length === 0, "Prologue directives should be at the first statement in the target statements array");
|
|
26281
26303
|
var foundUseStrict = false;
|
|
26282
|
-
var statementOffset = 0;
|
|
26283
26304
|
var numStatements = source.length;
|
|
26284
26305
|
while (statementOffset < numStatements) {
|
|
26285
26306
|
var statement = source[statementOffset];
|
|
@@ -27702,7 +27723,7 @@ var ts;
|
|
|
27702
27723
|
importName: "__createBinding",
|
|
27703
27724
|
scoped: false,
|
|
27704
27725
|
priority: 1,
|
|
27705
|
-
text: "\n var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n Object.
|
|
27726
|
+
text: "\n var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n var desc = Object.getOwnPropertyDescriptor(m, k);\n if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\n desc = { enumerable: true, get: function() { return m[k]; } };\n }\n Object.defineProperty(o, k2, desc);\n }) : (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n o[k2] = m[k];\n }));"
|
|
27706
27727
|
};
|
|
27707
27728
|
ts.setModuleDefaultHelper = {
|
|
27708
27729
|
name: "typescript:commonjscreatevalue",
|
|
@@ -41337,7 +41358,7 @@ var ts;
|
|
|
41337
41358
|
? 1 /* Recursive */ : 0 /* None */
|
|
41338
41359
|
};
|
|
41339
41360
|
}
|
|
41340
|
-
if (ts.isImplicitGlob(spec)) {
|
|
41361
|
+
if (ts.isImplicitGlob(spec.substring(spec.lastIndexOf(ts.directorySeparator) + 1))) {
|
|
41341
41362
|
return {
|
|
41342
41363
|
key: useCaseSensitiveFileNames ? spec : ts.toFileNameLowerCase(spec),
|
|
41343
41364
|
flags: 1 /* Recursive */
|
|
@@ -41703,9 +41724,7 @@ var ts;
|
|
|
41703
41724
|
}
|
|
41704
41725
|
}
|
|
41705
41726
|
var failedLookupLocations = [];
|
|
41706
|
-
var features =
|
|
41707
|
-
ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.NodeNext ? NodeResolutionFeatures.NodeNextDefault :
|
|
41708
|
-
NodeResolutionFeatures.None;
|
|
41727
|
+
var features = getDefaultNodeResolutionFeatures(options);
|
|
41709
41728
|
var moduleResolutionState = { compilerOptions: options, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: cache, features: features, conditions: ["node", "require", "types"] };
|
|
41710
41729
|
var resolved = primaryLookup();
|
|
41711
41730
|
var primary = true;
|
|
@@ -41790,6 +41809,34 @@ var ts;
|
|
|
41790
41809
|
}
|
|
41791
41810
|
}
|
|
41792
41811
|
ts.resolveTypeReferenceDirective = resolveTypeReferenceDirective;
|
|
41812
|
+
function getDefaultNodeResolutionFeatures(options) {
|
|
41813
|
+
return ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Node12 ? NodeResolutionFeatures.Node12Default :
|
|
41814
|
+
ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.NodeNext ? NodeResolutionFeatures.NodeNextDefault :
|
|
41815
|
+
NodeResolutionFeatures.None;
|
|
41816
|
+
}
|
|
41817
|
+
/**
|
|
41818
|
+
* @internal
|
|
41819
|
+
* Does not try `@types/${packageName}` - use a second pass if needed.
|
|
41820
|
+
*/
|
|
41821
|
+
function resolvePackageNameToPackageJson(packageName, containingDirectory, options, host, cache) {
|
|
41822
|
+
var moduleResolutionState = {
|
|
41823
|
+
compilerOptions: options,
|
|
41824
|
+
host: host,
|
|
41825
|
+
traceEnabled: isTraceEnabled(options, host),
|
|
41826
|
+
failedLookupLocations: [],
|
|
41827
|
+
packageJsonInfoCache: cache === null || cache === void 0 ? void 0 : cache.getPackageJsonInfoCache(),
|
|
41828
|
+
conditions: ts.emptyArray,
|
|
41829
|
+
features: NodeResolutionFeatures.None,
|
|
41830
|
+
};
|
|
41831
|
+
return ts.forEachAncestorDirectory(containingDirectory, function (ancestorDirectory) {
|
|
41832
|
+
if (ts.getBaseFileName(ancestorDirectory) !== "node_modules") {
|
|
41833
|
+
var nodeModulesFolder = ts.combinePaths(ancestorDirectory, "node_modules");
|
|
41834
|
+
var candidate = ts.combinePaths(nodeModulesFolder, packageName);
|
|
41835
|
+
return getPackageJsonInfo(candidate, /*onlyRecordFailures*/ false, moduleResolutionState);
|
|
41836
|
+
}
|
|
41837
|
+
});
|
|
41838
|
+
}
|
|
41839
|
+
ts.resolvePackageNameToPackageJson = resolvePackageNameToPackageJson;
|
|
41793
41840
|
/**
|
|
41794
41841
|
* Given a set of options, returns the set of type directive names
|
|
41795
41842
|
* that should be included for this program automatically.
|
|
@@ -42363,11 +42410,6 @@ var ts;
|
|
|
42363
42410
|
}
|
|
42364
42411
|
ts.resolveJSModule = resolveJSModule;
|
|
42365
42412
|
/* @internal */
|
|
42366
|
-
function tryResolveJSModule(moduleName, initialDir, host) {
|
|
42367
|
-
return tryResolveJSModuleWorker(moduleName, initialDir, host).resolvedModule;
|
|
42368
|
-
}
|
|
42369
|
-
ts.tryResolveJSModule = tryResolveJSModule;
|
|
42370
|
-
/* @internal */
|
|
42371
42413
|
var NodeResolutionFeatures;
|
|
42372
42414
|
(function (NodeResolutionFeatures) {
|
|
42373
42415
|
NodeResolutionFeatures[NodeResolutionFeatures["None"] = 0] = "None";
|
|
@@ -42675,6 +42717,97 @@ var ts;
|
|
|
42675
42717
|
var versionPaths = packageInfo && packageInfo.versionPaths;
|
|
42676
42718
|
return withPackageId(packageInfo, loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFailures, state, packageJsonContent, versionPaths));
|
|
42677
42719
|
}
|
|
42720
|
+
/* @internal */
|
|
42721
|
+
function getEntrypointsFromPackageJsonInfo(packageJsonInfo, options, host, cache, resolveJs) {
|
|
42722
|
+
if (!resolveJs && packageJsonInfo.resolvedEntrypoints !== undefined) {
|
|
42723
|
+
// Cached value excludes resolutions to JS files - those could be
|
|
42724
|
+
// cached separately, but they're used rarely.
|
|
42725
|
+
return packageJsonInfo.resolvedEntrypoints;
|
|
42726
|
+
}
|
|
42727
|
+
var entrypoints;
|
|
42728
|
+
var extensions = resolveJs ? Extensions.JavaScript : Extensions.TypeScript;
|
|
42729
|
+
var features = getDefaultNodeResolutionFeatures(options);
|
|
42730
|
+
var requireState = {
|
|
42731
|
+
compilerOptions: options,
|
|
42732
|
+
host: host,
|
|
42733
|
+
traceEnabled: isTraceEnabled(options, host),
|
|
42734
|
+
failedLookupLocations: [],
|
|
42735
|
+
packageJsonInfoCache: cache === null || cache === void 0 ? void 0 : cache.getPackageJsonInfoCache(),
|
|
42736
|
+
conditions: ["node", "require", "types"],
|
|
42737
|
+
features: features,
|
|
42738
|
+
};
|
|
42739
|
+
var requireResolution = loadNodeModuleFromDirectoryWorker(extensions, packageJsonInfo.packageDirectory,
|
|
42740
|
+
/*onlyRecordFailures*/ false, requireState, packageJsonInfo.packageJsonContent, packageJsonInfo.versionPaths);
|
|
42741
|
+
entrypoints = ts.append(entrypoints, requireResolution === null || requireResolution === void 0 ? void 0 : requireResolution.path);
|
|
42742
|
+
if (features & NodeResolutionFeatures.Exports && packageJsonInfo.packageJsonContent.exports) {
|
|
42743
|
+
for (var _i = 0, _a = [["node", "import", "types"], ["node", "require", "types"]]; _i < _a.length; _i++) {
|
|
42744
|
+
var conditions = _a[_i];
|
|
42745
|
+
var exportState = __assign(__assign({}, requireState), { failedLookupLocations: [], conditions: conditions });
|
|
42746
|
+
var exportResolutions = loadEntrypointsFromExportMap(packageJsonInfo, packageJsonInfo.packageJsonContent.exports, exportState, extensions);
|
|
42747
|
+
if (exportResolutions) {
|
|
42748
|
+
for (var _b = 0, exportResolutions_1 = exportResolutions; _b < exportResolutions_1.length; _b++) {
|
|
42749
|
+
var resolution = exportResolutions_1[_b];
|
|
42750
|
+
entrypoints = ts.appendIfUnique(entrypoints, resolution.path);
|
|
42751
|
+
}
|
|
42752
|
+
}
|
|
42753
|
+
}
|
|
42754
|
+
}
|
|
42755
|
+
return packageJsonInfo.resolvedEntrypoints = entrypoints || false;
|
|
42756
|
+
}
|
|
42757
|
+
ts.getEntrypointsFromPackageJsonInfo = getEntrypointsFromPackageJsonInfo;
|
|
42758
|
+
function loadEntrypointsFromExportMap(scope, exports, state, extensions) {
|
|
42759
|
+
var entrypoints;
|
|
42760
|
+
if (ts.isArray(exports)) {
|
|
42761
|
+
for (var _i = 0, exports_1 = exports; _i < exports_1.length; _i++) {
|
|
42762
|
+
var target = exports_1[_i];
|
|
42763
|
+
loadEntrypointsFromTargetExports(target);
|
|
42764
|
+
}
|
|
42765
|
+
}
|
|
42766
|
+
// eslint-disable-next-line no-null/no-null
|
|
42767
|
+
else if (typeof exports === "object" && exports !== null && allKeysStartWithDot(exports)) {
|
|
42768
|
+
for (var key in exports) {
|
|
42769
|
+
loadEntrypointsFromTargetExports(exports[key]);
|
|
42770
|
+
}
|
|
42771
|
+
}
|
|
42772
|
+
else {
|
|
42773
|
+
loadEntrypointsFromTargetExports(exports);
|
|
42774
|
+
}
|
|
42775
|
+
return entrypoints;
|
|
42776
|
+
function loadEntrypointsFromTargetExports(target) {
|
|
42777
|
+
var _a, _b;
|
|
42778
|
+
if (typeof target === "string" && ts.startsWith(target, "./") && target.indexOf("*") === -1) {
|
|
42779
|
+
var partsAfterFirst = ts.getPathComponents(target).slice(2);
|
|
42780
|
+
if (partsAfterFirst.indexOf("..") >= 0 || partsAfterFirst.indexOf(".") >= 0 || partsAfterFirst.indexOf("node_modules") >= 0) {
|
|
42781
|
+
return false;
|
|
42782
|
+
}
|
|
42783
|
+
var resolvedTarget = ts.combinePaths(scope.packageDirectory, target);
|
|
42784
|
+
var finalPath = ts.getNormalizedAbsolutePath(resolvedTarget, (_b = (_a = state.host).getCurrentDirectory) === null || _b === void 0 ? void 0 : _b.call(_a));
|
|
42785
|
+
var result = loadJSOrExactTSFileName(extensions, finalPath, /*recordOnlyFailures*/ false, state);
|
|
42786
|
+
if (result) {
|
|
42787
|
+
entrypoints = ts.appendIfUnique(entrypoints, result, function (a, b) { return a.path === b.path; });
|
|
42788
|
+
return true;
|
|
42789
|
+
}
|
|
42790
|
+
}
|
|
42791
|
+
else if (Array.isArray(target)) {
|
|
42792
|
+
for (var _i = 0, target_1 = target; _i < target_1.length; _i++) {
|
|
42793
|
+
var t = target_1[_i];
|
|
42794
|
+
var success = loadEntrypointsFromTargetExports(t);
|
|
42795
|
+
if (success) {
|
|
42796
|
+
return true;
|
|
42797
|
+
}
|
|
42798
|
+
}
|
|
42799
|
+
}
|
|
42800
|
+
// eslint-disable-next-line no-null/no-null
|
|
42801
|
+
else if (typeof target === "object" && target !== null) {
|
|
42802
|
+
return ts.forEach(ts.getOwnKeys(target), function (key) {
|
|
42803
|
+
if (key === "default" || ts.contains(state.conditions, key) || isApplicableVersionedTypesKey(state.conditions, key)) {
|
|
42804
|
+
loadEntrypointsFromTargetExports(target[key]);
|
|
42805
|
+
return true;
|
|
42806
|
+
}
|
|
42807
|
+
});
|
|
42808
|
+
}
|
|
42809
|
+
}
|
|
42810
|
+
}
|
|
42678
42811
|
/**
|
|
42679
42812
|
* A function for locating the package.json scope for a given path
|
|
42680
42813
|
*/
|
|
@@ -42731,7 +42864,7 @@ var ts;
|
|
|
42731
42864
|
trace(host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath);
|
|
42732
42865
|
}
|
|
42733
42866
|
var versionPaths = readPackageJsonTypesVersionPaths(packageJsonContent, state);
|
|
42734
|
-
var result = { packageDirectory: packageDirectory, packageJsonContent: packageJsonContent, versionPaths: versionPaths };
|
|
42867
|
+
var result = { packageDirectory: packageDirectory, packageJsonContent: packageJsonContent, versionPaths: versionPaths, resolvedEntrypoints: undefined };
|
|
42735
42868
|
(_b = state.packageJsonInfoCache) === null || _b === void 0 ? void 0 : _b.setPackageJsonInfo(packageJsonPath, result);
|
|
42736
42869
|
return result;
|
|
42737
42870
|
}
|
|
@@ -43028,8 +43161,8 @@ var ts;
|
|
|
43028
43161
|
}
|
|
43029
43162
|
return toSearchResult(/*value*/ undefined);
|
|
43030
43163
|
}
|
|
43031
|
-
for (var _d = 0,
|
|
43032
|
-
var elem =
|
|
43164
|
+
for (var _d = 0, target_2 = target; _d < target_2.length; _d++) {
|
|
43165
|
+
var elem = target_2[_d];
|
|
43033
43166
|
var result = loadModuleFromTargetImportOrExport(elem, subpath, pattern);
|
|
43034
43167
|
if (result) {
|
|
43035
43168
|
return result;
|
|
@@ -52262,8 +52395,8 @@ var ts;
|
|
|
52262
52395
|
}
|
|
52263
52396
|
else {
|
|
52264
52397
|
if (parent && getExportsOfSymbol(parent)) {
|
|
52265
|
-
var
|
|
52266
|
-
ts.forEachEntry(
|
|
52398
|
+
var exports_2 = getExportsOfSymbol(parent);
|
|
52399
|
+
ts.forEachEntry(exports_2, function (ex, name) {
|
|
52267
52400
|
if (getSymbolIfSameReference(ex, symbol) && !isLateBoundName(name) && name !== "export=" /* ExportEquals */) {
|
|
52268
52401
|
symbolName = ts.unescapeLeadingUnderscores(name);
|
|
52269
52402
|
return true;
|
|
@@ -57374,6 +57507,11 @@ var ts;
|
|
|
57374
57507
|
return simplified !== type ? simplified : getConstraintOfType(type);
|
|
57375
57508
|
}
|
|
57376
57509
|
function getConstraintFromIndexedAccess(type) {
|
|
57510
|
+
if (isMappedTypeGenericIndexedAccess(type)) {
|
|
57511
|
+
// For indexed access types of the form { [P in K]: E }[X], where K is non-generic and X is generic,
|
|
57512
|
+
// we substitute an instantiation of E where P is replaced with X.
|
|
57513
|
+
return substituteIndexedMappedType(type.objectType, type.indexType);
|
|
57514
|
+
}
|
|
57377
57515
|
var indexConstraint = getSimplifiedTypeOrConstraint(type.indexType);
|
|
57378
57516
|
if (indexConstraint && indexConstraint !== type.indexType) {
|
|
57379
57517
|
var indexedAccess = getIndexedAccessTypeOrUndefined(type.objectType, indexConstraint, type.accessFlags);
|
|
@@ -57578,6 +57716,11 @@ var ts;
|
|
|
57578
57716
|
return constraint ? getStringMappingType(t.symbol, constraint) : stringType;
|
|
57579
57717
|
}
|
|
57580
57718
|
if (t.flags & 8388608 /* IndexedAccess */) {
|
|
57719
|
+
if (isMappedTypeGenericIndexedAccess(t)) {
|
|
57720
|
+
// For indexed access types of the form { [P in K]: E }[X], where K is non-generic and X is generic,
|
|
57721
|
+
// we substitute an instantiation of E where P is replaced with X.
|
|
57722
|
+
return getBaseConstraint(substituteIndexedMappedType(t.objectType, t.indexType));
|
|
57723
|
+
}
|
|
57581
57724
|
var baseObjectType = getBaseConstraint(t.objectType);
|
|
57582
57725
|
var baseIndexType = getBaseConstraint(t.indexType);
|
|
57583
57726
|
var baseIndexedAccess = baseObjectType && baseIndexType && getIndexedAccessTypeOrUndefined(baseObjectType, baseIndexType, t.accessFlags);
|
|
@@ -57662,13 +57805,7 @@ var ts;
|
|
|
57662
57805
|
* type itself.
|
|
57663
57806
|
*/
|
|
57664
57807
|
function getApparentType(type) {
|
|
57665
|
-
|
|
57666
|
-
// { [P in K]: E }[X], where K is non-generic and X is generic. For those types, we instead substitute an
|
|
57667
|
-
// instantiation of E where P is replaced with X. We do this because getBaseConstraintOfType directly
|
|
57668
|
-
// lowers to an instantiation where X's constraint is substituted for X, which isn't always desirable.
|
|
57669
|
-
var t = !(type.flags & 465829888 /* Instantiable */) ? type :
|
|
57670
|
-
isMappedTypeGenericIndexedAccess(type) ? substituteIndexedMappedType(type.objectType, type.indexType) :
|
|
57671
|
-
getBaseConstraintOfType(type) || unknownType;
|
|
57808
|
+
var t = !(type.flags & 465829888 /* Instantiable */) ? type : getBaseConstraintOfType(type) || unknownType;
|
|
57672
57809
|
return ts.getObjectFlags(t) & 32 /* Mapped */ ? getApparentTypeOfMappedType(t) :
|
|
57673
57810
|
t.flags & 2097152 /* Intersection */ ? getApparentTypeOfIntersectionType(t) :
|
|
57674
57811
|
t.flags & 402653316 /* StringLike */ ? globalStringType :
|
|
@@ -64332,6 +64469,17 @@ var ts;
|
|
|
64332
64469
|
resetErrorInfo(saveErrorInfo);
|
|
64333
64470
|
return result;
|
|
64334
64471
|
}
|
|
64472
|
+
if (isMappedTypeGenericIndexedAccess(source)) {
|
|
64473
|
+
// For an indexed access type { [P in K]: E}[X], above we have already explored an instantiation of E with X
|
|
64474
|
+
// substituted for P. We also want to explore type { [P in K]: E }[C], where C is the constraint of X.
|
|
64475
|
+
var indexConstraint = getConstraintOfType(source.indexType);
|
|
64476
|
+
if (indexConstraint) {
|
|
64477
|
+
if (result = isRelatedTo(getIndexedAccessType(source.objectType, indexConstraint), target, 1 /* Source */, reportErrors)) {
|
|
64478
|
+
resetErrorInfo(saveErrorInfo);
|
|
64479
|
+
return result;
|
|
64480
|
+
}
|
|
64481
|
+
}
|
|
64482
|
+
}
|
|
64335
64483
|
}
|
|
64336
64484
|
}
|
|
64337
64485
|
else if (source.flags & 4194304 /* Index */) {
|
|
@@ -78595,32 +78743,38 @@ var ts;
|
|
|
78595
78743
|
if (classExtendsNull) {
|
|
78596
78744
|
error(superCall, ts.Diagnostics.A_constructor_cannot_contain_a_super_call_when_its_class_extends_null);
|
|
78597
78745
|
}
|
|
78598
|
-
//
|
|
78599
|
-
// if both of the following are true:
|
|
78746
|
+
// A super call must be root-level in a constructor if both of the following are true:
|
|
78600
78747
|
// - The containing class is a derived class.
|
|
78601
78748
|
// - The constructor declares parameter properties
|
|
78602
78749
|
// or the containing class declares instance member variables with initializers.
|
|
78603
|
-
var
|
|
78750
|
+
var superCallShouldBeRootLevel = (ts.getEmitScriptTarget(compilerOptions) !== 99 /* ESNext */ || !useDefineForClassFields) &&
|
|
78604
78751
|
(ts.some(node.parent.members, isInstancePropertyWithInitializerOrPrivateIdentifierProperty) ||
|
|
78605
78752
|
ts.some(node.parameters, function (p) { return ts.hasSyntacticModifier(p, 16476 /* ParameterPropertyModifier */); }));
|
|
78606
|
-
|
|
78607
|
-
|
|
78608
|
-
|
|
78609
|
-
|
|
78610
|
-
|
|
78611
|
-
|
|
78612
|
-
|
|
78613
|
-
|
|
78614
|
-
|
|
78615
|
-
|
|
78753
|
+
if (superCallShouldBeRootLevel) {
|
|
78754
|
+
// Until we have better flow analysis, it is an error to place the super call within any kind of block or conditional
|
|
78755
|
+
// See GH #8277
|
|
78756
|
+
if (!superCallIsRootLevelInConstructor(superCall, node.body)) {
|
|
78757
|
+
error(superCall, ts.Diagnostics.A_super_call_must_be_a_root_level_statement_within_a_constructor_of_a_derived_class_that_contains_initialized_properties_parameter_properties_or_private_identifiers);
|
|
78758
|
+
}
|
|
78759
|
+
// Skip past any prologue directives to check statements for referring to 'super' or 'this' before a super call
|
|
78760
|
+
else {
|
|
78761
|
+
var superCallStatement = void 0;
|
|
78762
|
+
for (var _i = 0, _a = node.body.statements; _i < _a.length; _i++) {
|
|
78763
|
+
var statement = _a[_i];
|
|
78764
|
+
if (ts.isExpressionStatement(statement) && ts.isSuperCall(ts.skipOuterExpressions(statement.expression))) {
|
|
78765
|
+
superCallStatement = statement;
|
|
78766
|
+
break;
|
|
78767
|
+
}
|
|
78768
|
+
if (!ts.isPrologueDirective(statement) && nodeImmediatelyReferencesSuperOrThis(statement)) {
|
|
78769
|
+
break;
|
|
78770
|
+
}
|
|
78616
78771
|
}
|
|
78617
|
-
|
|
78618
|
-
|
|
78772
|
+
// Until we have better flow analysis, it is an error to place the super call within any kind of block or conditional
|
|
78773
|
+
// See GH #8277
|
|
78774
|
+
if (superCallStatement === undefined) {
|
|
78775
|
+
error(node, ts.Diagnostics.A_super_call_must_be_the_first_statement_in_the_constructor_to_refer_to_super_or_this_when_a_derived_class_contains_initialized_properties_parameter_properties_or_private_identifiers);
|
|
78619
78776
|
}
|
|
78620
78777
|
}
|
|
78621
|
-
if (!superCallStatement) {
|
|
78622
|
-
error(node, ts.Diagnostics.A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_properties_parameter_properties_or_private_identifiers);
|
|
78623
|
-
}
|
|
78624
78778
|
}
|
|
78625
78779
|
}
|
|
78626
78780
|
else if (!classExtendsNull) {
|
|
@@ -78628,6 +78782,19 @@ var ts;
|
|
|
78628
78782
|
}
|
|
78629
78783
|
}
|
|
78630
78784
|
}
|
|
78785
|
+
function superCallIsRootLevelInConstructor(superCall, body) {
|
|
78786
|
+
var superCallParent = ts.walkUpParenthesizedExpressions(superCall.parent);
|
|
78787
|
+
return ts.isExpressionStatement(superCallParent) && superCallParent.parent === body;
|
|
78788
|
+
}
|
|
78789
|
+
function nodeImmediatelyReferencesSuperOrThis(node) {
|
|
78790
|
+
if (node.kind === 106 /* SuperKeyword */ || node.kind === 108 /* ThisKeyword */) {
|
|
78791
|
+
return true;
|
|
78792
|
+
}
|
|
78793
|
+
if (ts.isThisContainerOrFunctionBlock(node)) {
|
|
78794
|
+
return false;
|
|
78795
|
+
}
|
|
78796
|
+
return !!ts.forEachChild(node, nodeImmediatelyReferencesSuperOrThis);
|
|
78797
|
+
}
|
|
78631
78798
|
function checkAccessorDeclaration(node) {
|
|
78632
78799
|
if (produceDiagnostics) {
|
|
78633
78800
|
// Grammar checking accessors
|
|
@@ -83450,9 +83617,9 @@ var ts;
|
|
|
83450
83617
|
}
|
|
83451
83618
|
}
|
|
83452
83619
|
// Checks for export * conflicts
|
|
83453
|
-
var
|
|
83454
|
-
if (
|
|
83455
|
-
|
|
83620
|
+
var exports_3 = getExportsOfModule(moduleSymbol);
|
|
83621
|
+
if (exports_3) {
|
|
83622
|
+
exports_3.forEach(function (_a, id) {
|
|
83456
83623
|
var declarations = _a.declarations, flags = _a.flags;
|
|
83457
83624
|
if (id === "__export") {
|
|
83458
83625
|
return;
|
|
@@ -88750,34 +88917,31 @@ var ts;
|
|
|
88750
88917
|
}
|
|
88751
88918
|
ts.getNonAssignmentOperatorForCompoundAssignment = getNonAssignmentOperatorForCompoundAssignment;
|
|
88752
88919
|
/**
|
|
88753
|
-
*
|
|
88754
|
-
|
|
88755
|
-
|
|
88756
|
-
|
|
88757
|
-
|
|
88758
|
-
|
|
88920
|
+
* @returns Contained super() call from descending into the statement ignoring parentheses, if that call exists.
|
|
88921
|
+
*/
|
|
88922
|
+
function getSuperCallFromStatement(statement) {
|
|
88923
|
+
if (!ts.isExpressionStatement(statement)) {
|
|
88924
|
+
return undefined;
|
|
88925
|
+
}
|
|
88926
|
+
var expression = ts.skipParentheses(statement.expression);
|
|
88927
|
+
return ts.isSuperCall(expression)
|
|
88928
|
+
? expression
|
|
88929
|
+
: undefined;
|
|
88930
|
+
}
|
|
88931
|
+
ts.getSuperCallFromStatement = getSuperCallFromStatement;
|
|
88932
|
+
/**
|
|
88933
|
+
* @returns The index (after prologue statements) of a super call, or -1 if not found.
|
|
88759
88934
|
*/
|
|
88760
|
-
function
|
|
88761
|
-
|
|
88762
|
-
var
|
|
88763
|
-
|
|
88764
|
-
|
|
88765
|
-
if (index === statements.length) {
|
|
88766
|
-
// list contains nothing but prologue directives (or empty) - exit
|
|
88767
|
-
return index;
|
|
88768
|
-
}
|
|
88769
|
-
var superIndex = ts.findIndex(statements, function (s) { return ts.isExpressionStatement(s) && ts.isSuperCall(s.expression); }, index);
|
|
88770
|
-
if (superIndex > -1) {
|
|
88771
|
-
for (var i = index; i <= superIndex; i++) {
|
|
88772
|
-
result.push(ts.visitNode(statements[i], visitor, ts.isStatement));
|
|
88773
|
-
}
|
|
88774
|
-
return superIndex + 1;
|
|
88935
|
+
function findSuperStatementIndex(statements, indexAfterLastPrologueStatement) {
|
|
88936
|
+
for (var i = indexAfterLastPrologueStatement; i < statements.length; i += 1) {
|
|
88937
|
+
var statement = statements[i];
|
|
88938
|
+
if (getSuperCallFromStatement(statement)) {
|
|
88939
|
+
return i;
|
|
88775
88940
|
}
|
|
88776
|
-
return index;
|
|
88777
88941
|
}
|
|
88778
|
-
return
|
|
88942
|
+
return -1;
|
|
88779
88943
|
}
|
|
88780
|
-
ts.
|
|
88944
|
+
ts.findSuperStatementIndex = findSuperStatementIndex;
|
|
88781
88945
|
function getProperties(node, requireInitializer, isStatic) {
|
|
88782
88946
|
return ts.filter(node.members, function (m) { return isInitializedOrStaticProperty(m, requireInitializer, isStatic); });
|
|
88783
88947
|
}
|
|
@@ -90676,6 +90840,7 @@ var ts;
|
|
|
90676
90840
|
case 176 /* TypePredicate */:
|
|
90677
90841
|
case 133 /* BooleanKeyword */:
|
|
90678
90842
|
return factory.createIdentifier("Boolean");
|
|
90843
|
+
case 197 /* TemplateLiteralType */:
|
|
90679
90844
|
case 149 /* StringKeyword */:
|
|
90680
90845
|
return factory.createIdentifier("String");
|
|
90681
90846
|
case 147 /* ObjectKeyword */:
|
|
@@ -91014,10 +91179,14 @@ var ts;
|
|
|
91014
91179
|
return ts.visitFunctionBody(body, visitor, context);
|
|
91015
91180
|
}
|
|
91016
91181
|
var statements = [];
|
|
91017
|
-
var indexOfFirstStatement = 0;
|
|
91018
91182
|
resumeLexicalEnvironment();
|
|
91019
|
-
|
|
91020
|
-
|
|
91183
|
+
var indexAfterLastPrologueStatement = factory.copyPrologue(body.statements, statements, /*ensureUseStrict*/ false, visitor);
|
|
91184
|
+
var superStatementIndex = ts.findSuperStatementIndex(body.statements, indexAfterLastPrologueStatement);
|
|
91185
|
+
// If there was a super call, visit existing statements up to and including it
|
|
91186
|
+
if (superStatementIndex >= 0) {
|
|
91187
|
+
ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, indexAfterLastPrologueStatement, superStatementIndex + 1 - indexAfterLastPrologueStatement));
|
|
91188
|
+
}
|
|
91189
|
+
// Transform parameters into property assignments. Transforms this:
|
|
91021
91190
|
//
|
|
91022
91191
|
// constructor (public x, public y) {
|
|
91023
91192
|
// }
|
|
@@ -91029,9 +91198,17 @@ var ts;
|
|
|
91029
91198
|
// this.y = y;
|
|
91030
91199
|
// }
|
|
91031
91200
|
//
|
|
91032
|
-
|
|
91033
|
-
//
|
|
91034
|
-
|
|
91201
|
+
var parameterPropertyAssignments = ts.mapDefined(parametersWithPropertyAssignments, transformParameterWithPropertyAssignment);
|
|
91202
|
+
// If there is a super() call, the parameter properties go immediately after it
|
|
91203
|
+
if (superStatementIndex >= 0) {
|
|
91204
|
+
ts.addRange(statements, parameterPropertyAssignments);
|
|
91205
|
+
}
|
|
91206
|
+
// Since there was no super() call, parameter properties are the first statements in the constructor
|
|
91207
|
+
else {
|
|
91208
|
+
statements = ts.addRange(parameterPropertyAssignments, statements);
|
|
91209
|
+
}
|
|
91210
|
+
// Add remaining statements from the body, skipping the super() call if it was found
|
|
91211
|
+
ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, superStatementIndex + 1));
|
|
91035
91212
|
// End the lexical environment.
|
|
91036
91213
|
statements = factory.mergeLexicalEnvironment(statements, endLexicalEnvironment());
|
|
91037
91214
|
var block = factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), body.statements), /*multiLine*/ true);
|
|
@@ -92929,6 +93106,7 @@ var ts;
|
|
|
92929
93106
|
/*modifiers*/ undefined, parameters !== null && parameters !== void 0 ? parameters : [], body), constructor || node), constructor));
|
|
92930
93107
|
}
|
|
92931
93108
|
function transformConstructorBody(node, constructor, isDerivedClass) {
|
|
93109
|
+
var _a;
|
|
92932
93110
|
var properties = ts.getProperties(node, /*requireInitializer*/ false, /*isStatic*/ false);
|
|
92933
93111
|
if (!useDefineForClassFields) {
|
|
92934
93112
|
properties = ts.filter(properties, function (property) { return !!property.initializer || ts.isPrivateIdentifier(property.name); });
|
|
@@ -92940,9 +93118,21 @@ var ts;
|
|
|
92940
93118
|
return ts.visitFunctionBody(/*node*/ undefined, visitor, context);
|
|
92941
93119
|
}
|
|
92942
93120
|
resumeLexicalEnvironment();
|
|
92943
|
-
var
|
|
93121
|
+
var needsSyntheticConstructor = !constructor && isDerivedClass;
|
|
93122
|
+
var indexOfFirstStatementAfterSuper = 0;
|
|
93123
|
+
var prologueStatementCount = 0;
|
|
93124
|
+
var superStatementIndex = -1;
|
|
92944
93125
|
var statements = [];
|
|
92945
|
-
if (
|
|
93126
|
+
if ((_a = constructor === null || constructor === void 0 ? void 0 : constructor.body) === null || _a === void 0 ? void 0 : _a.statements) {
|
|
93127
|
+
prologueStatementCount = factory.copyPrologue(constructor.body.statements, statements, /*ensureUseStrict*/ false, visitor);
|
|
93128
|
+
superStatementIndex = ts.findSuperStatementIndex(constructor.body.statements, prologueStatementCount);
|
|
93129
|
+
// If there was a super call, visit existing statements up to and including it
|
|
93130
|
+
if (superStatementIndex >= 0) {
|
|
93131
|
+
indexOfFirstStatementAfterSuper = superStatementIndex + 1;
|
|
93132
|
+
statements = __spreadArray(__spreadArray(__spreadArray([], statements.slice(0, prologueStatementCount), true), ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, prologueStatementCount, indexOfFirstStatementAfterSuper - prologueStatementCount), true), statements.slice(prologueStatementCount), true);
|
|
93133
|
+
}
|
|
93134
|
+
}
|
|
93135
|
+
if (needsSyntheticConstructor) {
|
|
92946
93136
|
// Add a synthetic `super` call:
|
|
92947
93137
|
//
|
|
92948
93138
|
// super(...arguments);
|
|
@@ -92950,9 +93140,6 @@ var ts;
|
|
|
92950
93140
|
statements.push(factory.createExpressionStatement(factory.createCallExpression(factory.createSuper(),
|
|
92951
93141
|
/*typeArguments*/ undefined, [factory.createSpreadElement(factory.createIdentifier("arguments"))])));
|
|
92952
93142
|
}
|
|
92953
|
-
if (constructor) {
|
|
92954
|
-
indexOfFirstStatement = ts.addPrologueDirectivesAndInitialSuperCall(factory, constructor, statements, visitor);
|
|
92955
|
-
}
|
|
92956
93143
|
// Add the property initializers. Transforms this:
|
|
92957
93144
|
//
|
|
92958
93145
|
// public x = 1;
|
|
@@ -92963,31 +93150,59 @@ var ts;
|
|
|
92963
93150
|
// this.x = 1;
|
|
92964
93151
|
// }
|
|
92965
93152
|
//
|
|
93153
|
+
// If we do useDefineForClassFields, they'll be converted elsewhere.
|
|
93154
|
+
// We instead *remove* them from the transformed output at this stage.
|
|
93155
|
+
var parameterPropertyDeclarationCount = 0;
|
|
92966
93156
|
if (constructor === null || constructor === void 0 ? void 0 : constructor.body) {
|
|
92967
|
-
|
|
92968
|
-
|
|
92969
|
-
afterParameterProperties = constructor.body.statements.length;
|
|
93157
|
+
if (useDefineForClassFields) {
|
|
93158
|
+
statements = statements.filter(function (statement) { return !ts.isParameterPropertyDeclaration(ts.getOriginalNode(statement), constructor); });
|
|
92970
93159
|
}
|
|
92971
|
-
|
|
92972
|
-
|
|
92973
|
-
|
|
93160
|
+
else {
|
|
93161
|
+
for (var _i = 0, _b = constructor.body.statements; _i < _b.length; _i++) {
|
|
93162
|
+
var statement = _b[_i];
|
|
93163
|
+
if (ts.isParameterPropertyDeclaration(ts.getOriginalNode(statement), constructor)) {
|
|
93164
|
+
parameterPropertyDeclarationCount++;
|
|
93165
|
+
}
|
|
93166
|
+
}
|
|
93167
|
+
if (parameterPropertyDeclarationCount > 0) {
|
|
93168
|
+
var parameterProperties = ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, indexOfFirstStatementAfterSuper, parameterPropertyDeclarationCount);
|
|
93169
|
+
// If there was a super() call found, add parameter properties immediately after it
|
|
93170
|
+
if (superStatementIndex >= 0) {
|
|
93171
|
+
ts.addRange(statements, parameterProperties);
|
|
93172
|
+
}
|
|
93173
|
+
// If a synthetic super() call was added, add them just after it
|
|
93174
|
+
else if (needsSyntheticConstructor) {
|
|
93175
|
+
statements = __spreadArray(__spreadArray([
|
|
93176
|
+
statements[0]
|
|
93177
|
+
], parameterProperties, true), statements.slice(1), true);
|
|
93178
|
+
}
|
|
93179
|
+
// Since there wasn't a super() call, add them to the top of the constructor
|
|
93180
|
+
else {
|
|
93181
|
+
statements = __spreadArray(__spreadArray([], parameterProperties, true), statements, true);
|
|
93182
|
+
}
|
|
93183
|
+
indexOfFirstStatementAfterSuper += parameterPropertyDeclarationCount;
|
|
92974
93184
|
}
|
|
92975
|
-
indexOfFirstStatement = afterParameterProperties;
|
|
92976
93185
|
}
|
|
92977
93186
|
}
|
|
92978
93187
|
var receiver = factory.createThis();
|
|
92979
93188
|
// private methods can be called in property initializers, they should execute first.
|
|
92980
93189
|
addMethodStatements(statements, privateMethodsAndAccessors, receiver);
|
|
92981
93190
|
addPropertyOrClassStaticBlockStatements(statements, properties, receiver);
|
|
92982
|
-
// Add existing statements
|
|
93191
|
+
// Add existing statements after the initial prologues and super call
|
|
92983
93192
|
if (constructor) {
|
|
92984
|
-
ts.addRange(statements, ts.visitNodes(constructor.body.statements,
|
|
93193
|
+
ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitBodyStatement, ts.isStatement, indexOfFirstStatementAfterSuper + prologueStatementCount));
|
|
92985
93194
|
}
|
|
92986
93195
|
statements = factory.mergeLexicalEnvironment(statements, endLexicalEnvironment());
|
|
92987
93196
|
return ts.setTextRange(factory.createBlock(ts.setTextRange(factory.createNodeArray(statements),
|
|
92988
93197
|
/*location*/ constructor ? constructor.body.statements : node.members),
|
|
92989
93198
|
/*multiLine*/ true),
|
|
92990
93199
|
/*location*/ constructor ? constructor.body : undefined);
|
|
93200
|
+
function visitBodyStatement(statement) {
|
|
93201
|
+
if (useDefineForClassFields && ts.isParameterPropertyDeclaration(ts.getOriginalNode(statement), constructor)) {
|
|
93202
|
+
return undefined;
|
|
93203
|
+
}
|
|
93204
|
+
return visitor(statement);
|
|
93205
|
+
}
|
|
92991
93206
|
}
|
|
92992
93207
|
/**
|
|
92993
93208
|
* Generates assignment statements for property initializers.
|
|
@@ -93008,6 +93223,11 @@ var ts;
|
|
|
93008
93223
|
ts.setSourceMapRange(statement, ts.moveRangePastModifiers(property));
|
|
93009
93224
|
ts.setCommentRange(statement, property);
|
|
93010
93225
|
ts.setOriginalNode(statement, property);
|
|
93226
|
+
// `setOriginalNode` *copies* the `emitNode` from `property`, so now both
|
|
93227
|
+
// `statement` and `expression` have a copy of the synthesized comments.
|
|
93228
|
+
// Drop the comments from expression to avoid printing them twice.
|
|
93229
|
+
ts.setSyntheticLeadingComments(expression, undefined);
|
|
93230
|
+
ts.setSyntheticTrailingComments(expression, undefined);
|
|
93011
93231
|
statements.push(statement);
|
|
93012
93232
|
}
|
|
93013
93233
|
}
|
|
@@ -96774,37 +96994,39 @@ var ts;
|
|
|
96774
96994
|
var prologue = [];
|
|
96775
96995
|
var statements = [];
|
|
96776
96996
|
resumeLexicalEnvironment();
|
|
96997
|
+
// In derived classes, there may be code before the necessary super() call
|
|
96998
|
+
// We'll remove pre-super statements to be tacked on after the rest of the body
|
|
96999
|
+
var existingPrologue = ts.takeWhile(constructor.body.statements, ts.isPrologueDirective);
|
|
97000
|
+
var _a = findSuperCallAndStatementIndex(constructor.body.statements, existingPrologue), superCall = _a.superCall, superStatementIndex = _a.superStatementIndex;
|
|
97001
|
+
var postSuperStatementsStart = superStatementIndex === -1 ? existingPrologue.length : superStatementIndex + 1;
|
|
96777
97002
|
// If a super call has already been synthesized,
|
|
96778
97003
|
// we're going to assume that we should just transform everything after that.
|
|
96779
97004
|
// The assumption is that no prior step in the pipeline has added any prologue directives.
|
|
96780
|
-
var statementOffset =
|
|
97005
|
+
var statementOffset = postSuperStatementsStart;
|
|
96781
97006
|
if (!hasSynthesizedSuper)
|
|
96782
|
-
statementOffset = factory.copyStandardPrologue(constructor.body.statements, prologue, /*ensureUseStrict*/ false);
|
|
96783
|
-
addDefaultValueAssignmentsIfNeeded(statements, constructor);
|
|
96784
|
-
addRestParameterIfNeeded(statements, constructor, hasSynthesizedSuper);
|
|
97007
|
+
statementOffset = factory.copyStandardPrologue(constructor.body.statements, prologue, statementOffset, /*ensureUseStrict*/ false);
|
|
96785
97008
|
if (!hasSynthesizedSuper)
|
|
96786
|
-
statementOffset = factory.copyCustomPrologue(constructor.body.statements, statements, statementOffset, visitor);
|
|
96787
|
-
// If
|
|
97009
|
+
statementOffset = factory.copyCustomPrologue(constructor.body.statements, statements, statementOffset, visitor, /*filter*/ undefined);
|
|
97010
|
+
// If there already exists a call to `super()`, visit the statement directly
|
|
96788
97011
|
var superCallExpression;
|
|
96789
97012
|
if (hasSynthesizedSuper) {
|
|
96790
97013
|
superCallExpression = createDefaultSuperCallOrThis();
|
|
96791
97014
|
}
|
|
96792
|
-
else if (
|
|
96793
|
-
|
|
96794
|
-
if (ts.isExpressionStatement(firstStatement) && ts.isSuperCall(firstStatement.expression)) {
|
|
96795
|
-
superCallExpression = visitImmediateSuperCallInBody(firstStatement.expression);
|
|
96796
|
-
}
|
|
97015
|
+
else if (superCall) {
|
|
97016
|
+
superCallExpression = visitSuperCallInBody(superCall);
|
|
96797
97017
|
}
|
|
96798
97018
|
if (superCallExpression) {
|
|
96799
97019
|
hierarchyFacts |= 8192 /* ConstructorWithCapturedSuper */;
|
|
96800
|
-
statementOffset++; // skip this statement, we will add it after visiting the rest of the body.
|
|
96801
97020
|
}
|
|
97021
|
+
// Add parameter defaults at the beginning of the output, with prologue statements
|
|
97022
|
+
addDefaultValueAssignmentsIfNeeded(prologue, constructor);
|
|
97023
|
+
addRestParameterIfNeeded(prologue, constructor, hasSynthesizedSuper);
|
|
96802
97024
|
// visit the remaining statements
|
|
96803
97025
|
ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, /*start*/ statementOffset));
|
|
96804
97026
|
factory.mergeLexicalEnvironment(prologue, endLexicalEnvironment());
|
|
96805
97027
|
insertCaptureNewTargetIfNeeded(prologue, constructor, /*copyOnWrite*/ false);
|
|
96806
|
-
if (isDerivedClass) {
|
|
96807
|
-
if (superCallExpression &&
|
|
97028
|
+
if (isDerivedClass || superCallExpression) {
|
|
97029
|
+
if (superCallExpression && postSuperStatementsStart === constructor.body.statements.length && !(constructor.body.transformFlags & 8192 /* ContainsLexicalThis */)) {
|
|
96808
97030
|
// If the subclass constructor does *not* contain `this` and *ends* with a `super()` call, we will use the
|
|
96809
97031
|
// following representation:
|
|
96810
97032
|
//
|
|
@@ -96824,10 +97046,10 @@ var ts;
|
|
|
96824
97046
|
// return C;
|
|
96825
97047
|
// })(Base);
|
|
96826
97048
|
// ```
|
|
96827
|
-
var
|
|
97049
|
+
var superCall_1 = ts.cast(ts.cast(superCallExpression, ts.isBinaryExpression).left, ts.isCallExpression);
|
|
96828
97050
|
var returnStatement = factory.createReturnStatement(superCallExpression);
|
|
96829
|
-
ts.setCommentRange(returnStatement, ts.getCommentRange(
|
|
96830
|
-
ts.setEmitFlags(
|
|
97051
|
+
ts.setCommentRange(returnStatement, ts.getCommentRange(superCall_1));
|
|
97052
|
+
ts.setEmitFlags(superCall_1, 1536 /* NoComments */);
|
|
96831
97053
|
statements.push(returnStatement);
|
|
96832
97054
|
}
|
|
96833
97055
|
else {
|
|
@@ -96852,9 +97074,19 @@ var ts;
|
|
|
96852
97074
|
// return C;
|
|
96853
97075
|
// })(Base);
|
|
96854
97076
|
// ```
|
|
96855
|
-
//
|
|
96856
|
-
|
|
96857
|
-
|
|
97077
|
+
// If the super() call is the first statement, we can directly create and assign its result to `_this`
|
|
97078
|
+
if (superStatementIndex <= existingPrologue.length) {
|
|
97079
|
+
insertCaptureThisForNode(statements, constructor, superCallExpression || createActualThis());
|
|
97080
|
+
}
|
|
97081
|
+
// Since the `super()` call isn't the first statement, it's split across 1-2 statements:
|
|
97082
|
+
// * A prologue `var _this = this;`, in case the constructor accesses this before super()
|
|
97083
|
+
// * If it exists, a reassignment to that `_this` of the super() call
|
|
97084
|
+
else {
|
|
97085
|
+
insertCaptureThisForNode(prologue, constructor, createActualThis());
|
|
97086
|
+
if (superCallExpression) {
|
|
97087
|
+
insertSuperThisCaptureThisForNode(statements, superCallExpression);
|
|
97088
|
+
}
|
|
97089
|
+
}
|
|
96858
97090
|
if (!isSufficientlyCoveredByReturnStatements(constructor.body)) {
|
|
96859
97091
|
statements.push(factory.createReturnStatement(factory.createUniqueName("_this", 16 /* Optimistic */ | 32 /* FileLevel */)));
|
|
96860
97092
|
}
|
|
@@ -96877,11 +97109,27 @@ var ts;
|
|
|
96877
97109
|
// ```
|
|
96878
97110
|
insertCaptureThisForNodeIfNeeded(prologue, constructor);
|
|
96879
97111
|
}
|
|
96880
|
-
var
|
|
97112
|
+
var body = factory.createBlock(ts.setTextRange(factory.createNodeArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], existingPrologue, true), prologue, true), (superStatementIndex <= existingPrologue.length ? ts.emptyArray : ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, existingPrologue.length, superStatementIndex)), true), statements, true)),
|
|
96881
97113
|
/*location*/ constructor.body.statements),
|
|
96882
97114
|
/*multiLine*/ true);
|
|
96883
|
-
ts.setTextRange(
|
|
96884
|
-
return
|
|
97115
|
+
ts.setTextRange(body, constructor.body);
|
|
97116
|
+
return body;
|
|
97117
|
+
}
|
|
97118
|
+
function findSuperCallAndStatementIndex(originalBodyStatements, existingPrologue) {
|
|
97119
|
+
for (var i = existingPrologue.length; i < originalBodyStatements.length; i += 1) {
|
|
97120
|
+
var superCall = ts.getSuperCallFromStatement(originalBodyStatements[i]);
|
|
97121
|
+
if (superCall) {
|
|
97122
|
+
// With a super() call, split the statements into pre-super() and 'body' (post-super())
|
|
97123
|
+
return {
|
|
97124
|
+
superCall: superCall,
|
|
97125
|
+
superStatementIndex: i,
|
|
97126
|
+
};
|
|
97127
|
+
}
|
|
97128
|
+
}
|
|
97129
|
+
// Since there was no super() call found, consider all statements to be in the main 'body' (post-super())
|
|
97130
|
+
return {
|
|
97131
|
+
superStatementIndex: -1,
|
|
97132
|
+
};
|
|
96885
97133
|
}
|
|
96886
97134
|
/**
|
|
96887
97135
|
* We want to try to avoid emitting a return statement in certain cases if a user already returned something.
|
|
@@ -97110,6 +97358,18 @@ var ts;
|
|
|
97110
97358
|
}
|
|
97111
97359
|
return false;
|
|
97112
97360
|
}
|
|
97361
|
+
/**
|
|
97362
|
+
* Assigns the `this` in a constructor to the result of its `super()` call.
|
|
97363
|
+
*
|
|
97364
|
+
* @param statements Statements in the constructor body.
|
|
97365
|
+
* @param superExpression Existing `super()` call for the constructor.
|
|
97366
|
+
*/
|
|
97367
|
+
function insertSuperThisCaptureThisForNode(statements, superExpression) {
|
|
97368
|
+
enableSubstitutionsForCapturedThis();
|
|
97369
|
+
var assignSuperExpression = factory.createExpressionStatement(factory.createBinaryExpression(factory.createThis(), 63 /* EqualsToken */, superExpression));
|
|
97370
|
+
ts.insertStatementAfterCustomPrologue(statements, assignSuperExpression);
|
|
97371
|
+
ts.setCommentRange(assignSuperExpression, ts.getOriginalNode(superExpression).parent);
|
|
97372
|
+
}
|
|
97113
97373
|
function insertCaptureThisForNode(statements, node, initializer) {
|
|
97114
97374
|
enableSubstitutionsForCapturedThis();
|
|
97115
97375
|
var captureThisStatement = factory.createVariableStatement(
|
|
@@ -97419,7 +97679,7 @@ var ts;
|
|
|
97419
97679
|
if (ts.isBlock(body)) {
|
|
97420
97680
|
// ensureUseStrict is false because no new prologue-directive should be added.
|
|
97421
97681
|
// addStandardPrologue will put already-existing directives at the beginning of the target statement-array
|
|
97422
|
-
statementOffset = factory.copyStandardPrologue(body.statements, prologue, /*ensureUseStrict*/ false);
|
|
97682
|
+
statementOffset = factory.copyStandardPrologue(body.statements, prologue, 0, /*ensureUseStrict*/ false);
|
|
97423
97683
|
statementOffset = factory.copyCustomPrologue(body.statements, statements, statementOffset, visitor, ts.isHoistedFunction);
|
|
97424
97684
|
statementOffset = factory.copyCustomPrologue(body.statements, statements, statementOffset, visitor, ts.isHoistedVariableStatement);
|
|
97425
97685
|
}
|
|
@@ -98790,7 +99050,7 @@ var ts;
|
|
|
98790
99050
|
/*type*/ undefined, factory.updateBlock(func.body, statements))),
|
|
98791
99051
|
/*typeArguments*/ undefined, call.arguments))));
|
|
98792
99052
|
}
|
|
98793
|
-
function
|
|
99053
|
+
function visitSuperCallInBody(node) {
|
|
98794
99054
|
return visitCallExpressionWithPotentialCapturedThisAssignment(node, /*assignToCapturedThis*/ false);
|
|
98795
99055
|
}
|
|
98796
99056
|
function visitCallExpressionWithPotentialCapturedThisAssignment(node, assignToCapturedThis) {
|
|
@@ -119348,28 +119608,37 @@ var ts;
|
|
|
119348
119608
|
useCaseSensitiveFileNames: (_a = host.useCaseSensitiveFileNames) === null || _a === void 0 ? void 0 : _a.call(host),
|
|
119349
119609
|
};
|
|
119350
119610
|
}
|
|
119351
|
-
|
|
119352
|
-
|
|
119611
|
+
// `importingSourceFile` and `importingSourceFileName`? Why not just use `importingSourceFile.path`?
|
|
119612
|
+
// Because when this is called by the file renamer, `importingSourceFile` is the file being renamed,
|
|
119613
|
+
// while `importingSourceFileName` its *new* name. We need a source file just to get its
|
|
119614
|
+
// `impliedNodeFormat` and to detect certain preferences from existing import module specifiers.
|
|
119615
|
+
function updateModuleSpecifier(compilerOptions, importingSourceFile, importingSourceFileName, toFileName, host, oldImportSpecifier) {
|
|
119616
|
+
var res = getModuleSpecifierWorker(compilerOptions, importingSourceFile, importingSourceFileName, toFileName, host, getPreferencesForUpdate(compilerOptions, oldImportSpecifier, importingSourceFileName, host), {});
|
|
119353
119617
|
if (res === oldImportSpecifier)
|
|
119354
119618
|
return undefined;
|
|
119355
119619
|
return res;
|
|
119356
119620
|
}
|
|
119357
119621
|
moduleSpecifiers_1.updateModuleSpecifier = updateModuleSpecifier;
|
|
119358
|
-
//
|
|
119622
|
+
// `importingSourceFile` and `importingSourceFileName`? Why not just use `importingSourceFile.path`?
|
|
119623
|
+
// Because when this is called by the declaration emitter, `importingSourceFile` is the implementation
|
|
119624
|
+
// file, but `importingSourceFileName` and `toFileName` refer to declaration files (the former to the
|
|
119625
|
+
// one currently being produced; the latter to the one being imported). We need an implementation file
|
|
119626
|
+
// just to get its `impliedNodeFormat` and to detect certain preferences from existing import module
|
|
119627
|
+
// specifiers.
|
|
119359
119628
|
function getModuleSpecifier(compilerOptions, importingSourceFile, importingSourceFileName, toFileName, host) {
|
|
119360
|
-
return getModuleSpecifierWorker(compilerOptions, importingSourceFileName, toFileName, host, getPreferences(host, {}, compilerOptions, importingSourceFile), {});
|
|
119629
|
+
return getModuleSpecifierWorker(compilerOptions, importingSourceFile, importingSourceFileName, toFileName, host, getPreferences(host, {}, compilerOptions, importingSourceFile), {});
|
|
119361
119630
|
}
|
|
119362
119631
|
moduleSpecifiers_1.getModuleSpecifier = getModuleSpecifier;
|
|
119363
|
-
function getNodeModulesPackageName(compilerOptions,
|
|
119364
|
-
var info = getInfo(
|
|
119365
|
-
var modulePaths = getAllModulePaths(
|
|
119366
|
-
return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, host, compilerOptions, /*packageNameOnly*/ true); });
|
|
119632
|
+
function getNodeModulesPackageName(compilerOptions, importingSourceFile, nodeModulesFileName, host, preferences) {
|
|
119633
|
+
var info = getInfo(importingSourceFile.path, host);
|
|
119634
|
+
var modulePaths = getAllModulePaths(importingSourceFile.path, nodeModulesFileName, host, preferences);
|
|
119635
|
+
return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, /*packageNameOnly*/ true); });
|
|
119367
119636
|
}
|
|
119368
119637
|
moduleSpecifiers_1.getNodeModulesPackageName = getNodeModulesPackageName;
|
|
119369
|
-
function getModuleSpecifierWorker(compilerOptions, importingSourceFileName, toFileName, host, preferences, userPreferences) {
|
|
119638
|
+
function getModuleSpecifierWorker(compilerOptions, importingSourceFile, importingSourceFileName, toFileName, host, preferences, userPreferences) {
|
|
119370
119639
|
var info = getInfo(importingSourceFileName, host);
|
|
119371
119640
|
var modulePaths = getAllModulePaths(importingSourceFileName, toFileName, host, userPreferences);
|
|
119372
|
-
return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, host, compilerOptions); }) ||
|
|
119641
|
+
return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions); }) ||
|
|
119373
119642
|
getLocalModuleSpecifier(toFileName, info, compilerOptions, host, preferences);
|
|
119374
119643
|
}
|
|
119375
119644
|
function tryGetModuleSpecifiersFromCache(moduleSymbol, importingSourceFile, host, userPreferences) {
|
|
@@ -119436,7 +119705,7 @@ var ts;
|
|
|
119436
119705
|
var relativeSpecifiers;
|
|
119437
119706
|
for (var _i = 0, modulePaths_1 = modulePaths; _i < modulePaths_1.length; _i++) {
|
|
119438
119707
|
var modulePath = modulePaths_1[_i];
|
|
119439
|
-
var specifier = tryGetModuleNameAsNodeModule(modulePath, info, host, compilerOptions);
|
|
119708
|
+
var specifier = tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions);
|
|
119440
119709
|
nodeModulesSpecifiers = ts.append(nodeModulesSpecifiers, specifier);
|
|
119441
119710
|
if (specifier && modulePath.isRedirect) {
|
|
119442
119711
|
// If we got a specifier for a redirect, it was a bare package specifier (e.g. "@foo/bar",
|
|
@@ -119828,7 +120097,7 @@ var ts;
|
|
|
119828
120097
|
? removeExtensionAndIndexPostFix(relativePath, ending, compilerOptions)
|
|
119829
120098
|
: ts.removeFileExtension(relativePath);
|
|
119830
120099
|
}
|
|
119831
|
-
function tryGetModuleNameAsNodeModule(_a, _b, host, options, packageNameOnly) {
|
|
120100
|
+
function tryGetModuleNameAsNodeModule(_a, _b, importingSourceFile, host, options, packageNameOnly) {
|
|
119832
120101
|
var path = _a.path, isRedirect = _a.isRedirect;
|
|
119833
120102
|
var getCanonicalFileName = _b.getCanonicalFileName, sourceDirectory = _b.sourceDirectory;
|
|
119834
120103
|
if (!host.fileExists || !host.readFile) {
|
|
@@ -119891,11 +120160,19 @@ var ts;
|
|
|
119891
120160
|
var moduleFileToTry = path;
|
|
119892
120161
|
if (host.fileExists(packageJsonPath)) {
|
|
119893
120162
|
var packageJsonContent = JSON.parse(host.readFile(packageJsonPath));
|
|
119894
|
-
// TODO: Inject `require` or `import` condition based on the intended import mode
|
|
119895
120163
|
if (ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Node12 || ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.NodeNext) {
|
|
119896
|
-
|
|
120164
|
+
// `conditions` *could* be made to go against `importingSourceFile.impliedNodeFormat` if something wanted to generate
|
|
120165
|
+
// an ImportEqualsDeclaration in an ESM-implied file or an ImportCall in a CJS-implied file. But since this function is
|
|
120166
|
+
// usually called to conjure an import out of thin air, we don't have an existing usage to call `getModeForUsageAtIndex`
|
|
120167
|
+
// with, so for now we just stick with the mode of the file.
|
|
120168
|
+
var conditions = ["node", importingSourceFile.impliedNodeFormat === ts.ModuleKind.ESNext ? "import" : "require", "types"];
|
|
120169
|
+
var fromExports = packageJsonContent.exports && typeof packageJsonContent.name === "string"
|
|
120170
|
+
? tryGetModuleNameFromExports(options, path, packageRootPath, ts.getPackageNameFromTypesPackageName(packageJsonContent.name), packageJsonContent.exports, conditions)
|
|
120171
|
+
: undefined;
|
|
119897
120172
|
if (fromExports) {
|
|
119898
|
-
var withJsExtension = !ts.hasTSFileExtension(fromExports.moduleFileToTry)
|
|
120173
|
+
var withJsExtension = !ts.hasTSFileExtension(fromExports.moduleFileToTry)
|
|
120174
|
+
? fromExports
|
|
120175
|
+
: { moduleFileToTry: ts.removeFileExtension(fromExports.moduleFileToTry) + tryGetJSExtensionForFile(fromExports.moduleFileToTry, options) };
|
|
119899
120176
|
return __assign(__assign({}, withJsExtension), { verbatimFromExports: true });
|
|
119900
120177
|
}
|
|
119901
120178
|
if (packageJsonContent.exports) {
|
|
@@ -120001,8 +120278,8 @@ var ts;
|
|
|
120001
120278
|
}
|
|
120002
120279
|
function getPathRelativeToRootDirs(path, rootDirs, getCanonicalFileName) {
|
|
120003
120280
|
return ts.firstDefined(rootDirs, function (rootDir) {
|
|
120004
|
-
var relativePath = getRelativePathIfInDirectory(path, rootDir, getCanonicalFileName);
|
|
120005
|
-
return isPathRelativeToParent(relativePath) ? undefined : relativePath;
|
|
120281
|
+
var relativePath = getRelativePathIfInDirectory(path, rootDir, getCanonicalFileName);
|
|
120282
|
+
return relativePath !== undefined && isPathRelativeToParent(relativePath) ? undefined : relativePath;
|
|
120006
120283
|
});
|
|
120007
120284
|
}
|
|
120008
120285
|
function removeExtensionAndIndexPostFix(fileName, ending, options) {
|
|
@@ -126631,7 +126908,7 @@ var ts;
|
|
|
126631
126908
|
if (!ts.stringContains(importedFileName, "node_modules")) {
|
|
126632
126909
|
return undefined;
|
|
126633
126910
|
}
|
|
126634
|
-
var specifier = ts.moduleSpecifiers.getNodeModulesPackageName(host.getCompilationSettings(), fromFile
|
|
126911
|
+
var specifier = ts.moduleSpecifiers.getNodeModulesPackageName(host.getCompilationSettings(), fromFile, importedFileName, moduleSpecifierResolutionHost, preferences);
|
|
126635
126912
|
if (!specifier) {
|
|
126636
126913
|
return undefined;
|
|
126637
126914
|
}
|
|
@@ -129447,7 +129724,7 @@ var ts;
|
|
|
129447
129724
|
return (location === null || location === void 0 ? void 0 : location.kind) === 79 /* Identifier */ ? ts.createTextSpanFromNode(location) : undefined;
|
|
129448
129725
|
}
|
|
129449
129726
|
function completionInfoFromData(sourceFile, host, program, compilerOptions, log, completionData, preferences, formatContext) {
|
|
129450
|
-
var symbols = completionData.symbols, contextToken = completionData.contextToken, completionKind = completionData.completionKind, isInSnippetScope = completionData.isInSnippetScope, isNewIdentifierLocation = completionData.isNewIdentifierLocation, location = completionData.location, propertyAccessToConvert = completionData.propertyAccessToConvert, keywordFilters = completionData.keywordFilters, literals = completionData.literals, symbolToOriginInfoMap = completionData.symbolToOriginInfoMap, recommendedCompletion = completionData.recommendedCompletion, isJsxInitializer = completionData.isJsxInitializer, isTypeOnlyLocation = completionData.isTypeOnlyLocation, isJsxIdentifierExpected = completionData.isJsxIdentifierExpected, importCompletionNode = completionData.importCompletionNode, insideJsDocTagTypeExpression = completionData.insideJsDocTagTypeExpression, symbolToSortTextIdMap = completionData.symbolToSortTextIdMap, hasUnresolvedAutoImports = completionData.hasUnresolvedAutoImports;
|
|
129727
|
+
var symbols = completionData.symbols, contextToken = completionData.contextToken, completionKind = completionData.completionKind, isInSnippetScope = completionData.isInSnippetScope, isNewIdentifierLocation = completionData.isNewIdentifierLocation, location = completionData.location, propertyAccessToConvert = completionData.propertyAccessToConvert, keywordFilters = completionData.keywordFilters, literals = completionData.literals, symbolToOriginInfoMap = completionData.symbolToOriginInfoMap, recommendedCompletion = completionData.recommendedCompletion, isJsxInitializer = completionData.isJsxInitializer, isTypeOnlyLocation = completionData.isTypeOnlyLocation, isJsxIdentifierExpected = completionData.isJsxIdentifierExpected, isRightOfOpenTag = completionData.isRightOfOpenTag, importCompletionNode = completionData.importCompletionNode, insideJsDocTagTypeExpression = completionData.insideJsDocTagTypeExpression, symbolToSortTextIdMap = completionData.symbolToSortTextIdMap, hasUnresolvedAutoImports = completionData.hasUnresolvedAutoImports;
|
|
129451
129728
|
// Verify if the file is JSX language variant
|
|
129452
129729
|
if (ts.getLanguageVariant(sourceFile.scriptKind) === 1 /* JSX */) {
|
|
129453
129730
|
var completionInfo = getJsxClosingTagCompletion(location, sourceFile);
|
|
@@ -129458,7 +129735,7 @@ var ts;
|
|
|
129458
129735
|
var entries = ts.createSortedArray();
|
|
129459
129736
|
if (isUncheckedFile(sourceFile, compilerOptions)) {
|
|
129460
129737
|
var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries,
|
|
129461
|
-
/*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, formatContext, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap);
|
|
129738
|
+
/*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, formatContext, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap, isJsxIdentifierExpected, isRightOfOpenTag);
|
|
129462
129739
|
getJSCompletionEntries(sourceFile, location.pos, uniqueNames, ts.getEmitScriptTarget(compilerOptions), entries); // TODO: GH#18217
|
|
129463
129740
|
}
|
|
129464
129741
|
else {
|
|
@@ -129466,7 +129743,7 @@ var ts;
|
|
|
129466
129743
|
return undefined;
|
|
129467
129744
|
}
|
|
129468
129745
|
getCompletionEntriesFromSymbols(symbols, entries,
|
|
129469
|
-
/*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, formatContext, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap);
|
|
129746
|
+
/*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, formatContext, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap, isJsxIdentifierExpected, isRightOfOpenTag);
|
|
129470
129747
|
}
|
|
129471
129748
|
if (keywordFilters !== 0 /* None */) {
|
|
129472
129749
|
var entryNames = new ts.Set(entries.map(function (e) { return e.name; }));
|
|
@@ -129572,7 +129849,7 @@ var ts;
|
|
|
129572
129849
|
function createCompletionEntryForLiteral(sourceFile, preferences, literal) {
|
|
129573
129850
|
return { name: completionNameForLiteral(sourceFile, preferences, literal), kind: "string" /* string */, kindModifiers: "" /* none */, sortText: SortText.LocationPriority };
|
|
129574
129851
|
}
|
|
129575
|
-
function createCompletionEntry(symbol, sortText, replacementToken, contextToken, location, sourceFile, host, program, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importCompletionNode, useSemicolons, options, preferences, completionKind, formatContext) {
|
|
129852
|
+
function createCompletionEntry(symbol, sortText, replacementToken, contextToken, location, sourceFile, host, program, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importCompletionNode, useSemicolons, options, preferences, completionKind, formatContext, isJsxIdentifierExpected, isRightOfOpenTag) {
|
|
129576
129853
|
var _a, _b;
|
|
129577
129854
|
var insertText;
|
|
129578
129855
|
var replacementSpan = ts.getReplacementSpanForContextToken(replacementToken);
|
|
@@ -129643,8 +129920,7 @@ var ts;
|
|
|
129643
129920
|
source = CompletionSource.ClassMemberSnippet;
|
|
129644
129921
|
}
|
|
129645
129922
|
}
|
|
129646
|
-
|
|
129647
|
-
if (kind === "JSX attribute" /* jsxAttribute */ && preferences.includeCompletionsWithSnippetText && preferences.jsxAttributeCompletionStyle && preferences.jsxAttributeCompletionStyle !== "none") {
|
|
129923
|
+
if (isJsxIdentifierExpected && !isRightOfOpenTag && preferences.includeCompletionsWithSnippetText && preferences.jsxAttributeCompletionStyle && preferences.jsxAttributeCompletionStyle !== "none") {
|
|
129648
129924
|
var useBraces_1 = preferences.jsxAttributeCompletionStyle === "braces";
|
|
129649
129925
|
var type = typeChecker.getTypeOfSymbolAtLocation(symbol, location);
|
|
129650
129926
|
// If is boolean like or undefined, don't return a snippet we want just to return the completion.
|
|
@@ -129682,7 +129958,7 @@ var ts;
|
|
|
129682
129958
|
// entries (like JavaScript identifier entries).
|
|
129683
129959
|
return {
|
|
129684
129960
|
name: name,
|
|
129685
|
-
kind:
|
|
129961
|
+
kind: ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, location),
|
|
129686
129962
|
kindModifiers: ts.SymbolDisplay.getSymbolModifiers(typeChecker, symbol),
|
|
129687
129963
|
sortText: sortText,
|
|
129688
129964
|
source: source,
|
|
@@ -129978,7 +130254,7 @@ var ts;
|
|
|
129978
130254
|
return CompletionSource.ThisProperty;
|
|
129979
130255
|
}
|
|
129980
130256
|
}
|
|
129981
|
-
function getCompletionEntriesFromSymbols(symbols, entries, replacementToken, contextToken, location, sourceFile, host, program, target, log, kind, preferences, compilerOptions, formatContext, isTypeOnlyLocation, propertyAccessToConvert, jsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap) {
|
|
130257
|
+
function getCompletionEntriesFromSymbols(symbols, entries, replacementToken, contextToken, location, sourceFile, host, program, target, log, kind, preferences, compilerOptions, formatContext, isTypeOnlyLocation, propertyAccessToConvert, jsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap, isJsxIdentifierExpected, isRightOfOpenTag) {
|
|
129982
130258
|
var _a;
|
|
129983
130259
|
var start = ts.timestamp();
|
|
129984
130260
|
var variableDeclaration = getVariableDeclaration(location);
|
|
@@ -129999,7 +130275,7 @@ var ts;
|
|
|
129999
130275
|
var name = info.name, needsConvertPropertyAccess = info.needsConvertPropertyAccess;
|
|
130000
130276
|
var sortTextId = (_a = symbolToSortTextIdMap === null || symbolToSortTextIdMap === void 0 ? void 0 : symbolToSortTextIdMap[ts.getSymbolId(symbol)]) !== null && _a !== void 0 ? _a : 11 /* LocationPriority */;
|
|
130001
130277
|
var sortText = (isDeprecated(symbol, typeChecker) ? 8 /* DeprecatedOffset */ + sortTextId : sortTextId).toString();
|
|
130002
|
-
var entry = createCompletionEntry(symbol, sortText, replacementToken, contextToken, location, sourceFile, host, program, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importCompletionNode, useSemicolons, compilerOptions, preferences, kind, formatContext);
|
|
130278
|
+
var entry = createCompletionEntry(symbol, sortText, replacementToken, contextToken, location, sourceFile, host, program, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importCompletionNode, useSemicolons, compilerOptions, preferences, kind, formatContext, isJsxIdentifierExpected, isRightOfOpenTag);
|
|
130003
130279
|
if (!entry) {
|
|
130004
130280
|
continue;
|
|
130005
130281
|
}
|
|
@@ -130593,6 +130869,7 @@ var ts;
|
|
|
130593
130869
|
symbolToSortTextIdMap: symbolToSortTextIdMap,
|
|
130594
130870
|
isTypeOnlyLocation: isTypeOnlyLocation,
|
|
130595
130871
|
isJsxIdentifierExpected: isJsxIdentifierExpected,
|
|
130872
|
+
isRightOfOpenTag: isRightOfOpenTag,
|
|
130596
130873
|
importCompletionNode: importCompletionNode,
|
|
130597
130874
|
hasUnresolvedAutoImports: hasUnresolvedAutoImports,
|
|
130598
130875
|
};
|
|
@@ -136277,7 +136554,7 @@ var ts;
|
|
|
136277
136554
|
: getSourceFileToImport(importedModuleSymbol, importLiteral, sourceFile, program, host, oldToNew);
|
|
136278
136555
|
// Need an update if the imported file moved, or the importing file moved and was using a relative path.
|
|
136279
136556
|
return toImport !== undefined && (toImport.updated || (importingSourceFileMoved && ts.pathIsRelative(importLiteral.text)))
|
|
136280
|
-
? ts.moduleSpecifiers.updateModuleSpecifier(program.getCompilerOptions(), getCanonicalFileName(newImportFromPath), toImport.newFileName, ts.createModuleSpecifierResolutionHost(program, host), importLiteral.text)
|
|
136557
|
+
? ts.moduleSpecifiers.updateModuleSpecifier(program.getCompilerOptions(), sourceFile, getCanonicalFileName(newImportFromPath), toImport.newFileName, ts.createModuleSpecifierResolutionHost(program, host), importLiteral.text)
|
|
136281
136558
|
: undefined;
|
|
136282
136559
|
});
|
|
136283
136560
|
};
|
|
@@ -137922,6 +138199,9 @@ var ts;
|
|
|
137922
138199
|
// We use 1 NavNode to represent 'A.B.C', but there are multiple source nodes.
|
|
137923
138200
|
// Only merge module nodes that have the same chain. Don't merge 'A.B.C' with 'A'!
|
|
137924
138201
|
function areSameModule(a, b) {
|
|
138202
|
+
if (!a.body || !b.body) {
|
|
138203
|
+
return a.body === b.body;
|
|
138204
|
+
}
|
|
137925
138205
|
return a.body.kind === b.body.kind && (a.body.kind !== 260 /* ModuleDeclaration */ || areSameModule(a.body, b.body));
|
|
137926
138206
|
}
|
|
137927
138207
|
/** Merge source into target. Source should be thrown away after this is called. */
|
|
@@ -146699,20 +146979,31 @@ var ts;
|
|
|
146699
146979
|
codefix.registerCodeFix({
|
|
146700
146980
|
errorCodes: errorCodes,
|
|
146701
146981
|
getCodeActions: function getCodeActionsToAddConvertToUnknownForNonOverlappingTypes(context) {
|
|
146702
|
-
var
|
|
146982
|
+
var assertion = getAssertion(context.sourceFile, context.span.start);
|
|
146983
|
+
if (assertion === undefined)
|
|
146984
|
+
return undefined;
|
|
146985
|
+
var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return makeChange(t, context.sourceFile, assertion); });
|
|
146703
146986
|
return [codefix.createCodeFixAction(fixId, changes, ts.Diagnostics.Add_unknown_conversion_for_non_overlapping_types, fixId, ts.Diagnostics.Add_unknown_to_all_conversions_of_non_overlapping_types)];
|
|
146704
146987
|
},
|
|
146705
146988
|
fixIds: [fixId],
|
|
146706
|
-
getAllCodeActions: function (context) { return codefix.codeFixAll(context, errorCodes, function (changes, diag) {
|
|
146989
|
+
getAllCodeActions: function (context) { return codefix.codeFixAll(context, errorCodes, function (changes, diag) {
|
|
146990
|
+
var assertion = getAssertion(diag.file, diag.start);
|
|
146991
|
+
if (assertion) {
|
|
146992
|
+
makeChange(changes, diag.file, assertion);
|
|
146993
|
+
}
|
|
146994
|
+
}); },
|
|
146707
146995
|
});
|
|
146708
|
-
function makeChange(changeTracker, sourceFile,
|
|
146709
|
-
var token = ts.getTokenAtPosition(sourceFile, pos);
|
|
146710
|
-
var assertion = ts.Debug.checkDefined(ts.findAncestor(token, function (n) { return ts.isAsExpression(n) || ts.isTypeAssertionExpression(n); }), "Expected to find an assertion expression");
|
|
146996
|
+
function makeChange(changeTracker, sourceFile, assertion) {
|
|
146711
146997
|
var replacement = ts.isAsExpression(assertion)
|
|
146712
146998
|
? ts.factory.createAsExpression(assertion.expression, ts.factory.createKeywordTypeNode(154 /* UnknownKeyword */))
|
|
146713
146999
|
: ts.factory.createTypeAssertion(ts.factory.createKeywordTypeNode(154 /* UnknownKeyword */), assertion.expression);
|
|
146714
147000
|
changeTracker.replaceNode(sourceFile, assertion.expression, replacement);
|
|
146715
147001
|
}
|
|
147002
|
+
function getAssertion(sourceFile, pos) {
|
|
147003
|
+
if (ts.isInJSFile(sourceFile))
|
|
147004
|
+
return undefined;
|
|
147005
|
+
return ts.findAncestor(ts.getTokenAtPosition(sourceFile, pos), function (n) { return ts.isAsExpression(n) || ts.isTypeAssertionExpression(n); });
|
|
147006
|
+
}
|
|
146716
147007
|
})(codefix = ts.codefix || (ts.codefix = {}));
|
|
146717
147008
|
})(ts || (ts = {}));
|
|
146718
147009
|
/* @internal */
|
|
@@ -149830,10 +150121,15 @@ var ts;
|
|
|
149830
150121
|
if (a.kind !== 0 /* UseNamespace */ && b.kind !== 0 /* UseNamespace */) {
|
|
149831
150122
|
return ts.compareBooleans(allowsImportingSpecifier(b.moduleSpecifier), allowsImportingSpecifier(a.moduleSpecifier))
|
|
149832
150123
|
|| compareNodeCoreModuleSpecifiers(a.moduleSpecifier, b.moduleSpecifier, importingFile, program)
|
|
150124
|
+
|| ts.compareBooleans(isOnlyDotsAndSlashes(a.moduleSpecifier), isOnlyDotsAndSlashes(b.moduleSpecifier))
|
|
149833
150125
|
|| ts.compareNumberOfDirectorySeparators(a.moduleSpecifier, b.moduleSpecifier);
|
|
149834
150126
|
}
|
|
149835
150127
|
return 0 /* EqualTo */;
|
|
149836
150128
|
}
|
|
150129
|
+
var notDotOrSlashPattern = /[^.\/]/;
|
|
150130
|
+
function isOnlyDotsAndSlashes(path) {
|
|
150131
|
+
return !notDotOrSlashPattern.test(path);
|
|
150132
|
+
}
|
|
149837
150133
|
function compareNodeCoreModuleSpecifiers(a, b, importingFile, program) {
|
|
149838
150134
|
if (ts.startsWith(a, "node:") && !ts.startsWith(b, "node:"))
|
|
149839
150135
|
return ts.shouldUseUriStyleNodeCoreModules(importingFile, program) ? -1 /* LessThan */ : 1 /* GreaterThan */;
|
|
@@ -155136,7 +155432,7 @@ var ts;
|
|
|
155136
155432
|
defaultToNamedAction.kind,
|
|
155137
155433
|
namedToDefaultAction.kind
|
|
155138
155434
|
],
|
|
155139
|
-
getAvailableActions: function (context) {
|
|
155435
|
+
getAvailableActions: function getRefactorActionsToConvertBetweenNamedAndDefaultExports(context) {
|
|
155140
155436
|
var info = getInfo(context, context.triggerReason === "invoked");
|
|
155141
155437
|
if (!info)
|
|
155142
155438
|
return ts.emptyArray;
|
|
@@ -155154,7 +155450,7 @@ var ts;
|
|
|
155154
155450
|
}
|
|
155155
155451
|
return ts.emptyArray;
|
|
155156
155452
|
},
|
|
155157
|
-
getEditsForAction: function (context, actionName) {
|
|
155453
|
+
getEditsForAction: function getRefactorEditsToConvertBetweenNamedAndDefaultExports(context, actionName) {
|
|
155158
155454
|
ts.Debug.assert(actionName === defaultToNamedAction.name || actionName === namedToDefaultAction.name, "Unexpected action name");
|
|
155159
155455
|
var info = getInfo(context);
|
|
155160
155456
|
ts.Debug.assert(info && !refactor.isRefactorErrorInfo(info), "Expected applicable refactor info");
|
|
@@ -155382,7 +155678,7 @@ var ts;
|
|
|
155382
155678
|
namespaceToNamedAction.kind,
|
|
155383
155679
|
namedToNamespaceAction.kind
|
|
155384
155680
|
],
|
|
155385
|
-
getAvailableActions: function (context) {
|
|
155681
|
+
getAvailableActions: function getRefactorActionsToConvertBetweenNamedAndNamespacedImports(context) {
|
|
155386
155682
|
var info = getImportToConvert(context, context.triggerReason === "invoked");
|
|
155387
155683
|
if (!info)
|
|
155388
155684
|
return ts.emptyArray;
|
|
@@ -155401,7 +155697,7 @@ var ts;
|
|
|
155401
155697
|
}
|
|
155402
155698
|
return ts.emptyArray;
|
|
155403
155699
|
},
|
|
155404
|
-
getEditsForAction: function (context, actionName) {
|
|
155700
|
+
getEditsForAction: function getRefactorEditsToConvertBetweenNamedAndNamespacedImports(context, actionName) {
|
|
155405
155701
|
ts.Debug.assert(actionName === namespaceToNamedAction.name || actionName === namedToNamespaceAction.name, "Unexpected action name");
|
|
155406
155702
|
var info = getImportToConvert(context);
|
|
155407
155703
|
ts.Debug.assert(info && !refactor.isRefactorErrorInfo(info), "Expected applicable refactor info");
|
|
@@ -155567,10 +155863,10 @@ var ts;
|
|
|
155567
155863
|
};
|
|
155568
155864
|
refactor.registerRefactor(refactorName, {
|
|
155569
155865
|
kinds: [toOptionalChainAction.kind],
|
|
155570
|
-
|
|
155571
|
-
|
|
155866
|
+
getEditsForAction: getRefactorEditsToConvertToOptionalChain,
|
|
155867
|
+
getAvailableActions: getRefactorActionsToConvertToOptionalChain,
|
|
155572
155868
|
});
|
|
155573
|
-
function
|
|
155869
|
+
function getRefactorActionsToConvertToOptionalChain(context) {
|
|
155574
155870
|
var info = getInfo(context, context.triggerReason === "invoked");
|
|
155575
155871
|
if (!info)
|
|
155576
155872
|
return ts.emptyArray;
|
|
@@ -155590,7 +155886,7 @@ var ts;
|
|
|
155590
155886
|
}
|
|
155591
155887
|
return ts.emptyArray;
|
|
155592
155888
|
}
|
|
155593
|
-
function
|
|
155889
|
+
function getRefactorEditsToConvertToOptionalChain(context, actionName) {
|
|
155594
155890
|
var info = getInfo(context);
|
|
155595
155891
|
ts.Debug.assert(info && !refactor.isRefactorErrorInfo(info), "Expected applicable refactor info");
|
|
155596
155892
|
var edits = ts.textChanges.ChangeTracker.with(context, function (t) {
|
|
@@ -155833,10 +156129,10 @@ var ts;
|
|
|
155833
156129
|
};
|
|
155834
156130
|
refactor.registerRefactor(refactorName, {
|
|
155835
156131
|
kinds: [functionOverloadAction.kind],
|
|
155836
|
-
getEditsForAction:
|
|
155837
|
-
getAvailableActions:
|
|
156132
|
+
getEditsForAction: getRefactorEditsToConvertOverloadsToOneSignature,
|
|
156133
|
+
getAvailableActions: getRefactorActionsToConvertOverloadsToOneSignature
|
|
155838
156134
|
});
|
|
155839
|
-
function
|
|
156135
|
+
function getRefactorActionsToConvertOverloadsToOneSignature(context) {
|
|
155840
156136
|
var file = context.file, startPosition = context.startPosition, program = context.program;
|
|
155841
156137
|
var info = getConvertableOverloadListAtPosition(file, startPosition, program);
|
|
155842
156138
|
if (!info)
|
|
@@ -155847,7 +156143,7 @@ var ts;
|
|
|
155847
156143
|
actions: [functionOverloadAction]
|
|
155848
156144
|
}];
|
|
155849
156145
|
}
|
|
155850
|
-
function
|
|
156146
|
+
function getRefactorEditsToConvertOverloadsToOneSignature(context) {
|
|
155851
156147
|
var file = context.file, startPosition = context.startPosition, program = context.program;
|
|
155852
156148
|
var signatureDecls = getConvertableOverloadListAtPosition(file, startPosition, program);
|
|
155853
156149
|
if (!signatureDecls)
|
|
@@ -156003,14 +156299,14 @@ var ts;
|
|
|
156003
156299
|
extractConstantAction.kind,
|
|
156004
156300
|
extractFunctionAction.kind
|
|
156005
156301
|
],
|
|
156006
|
-
|
|
156007
|
-
|
|
156302
|
+
getEditsForAction: getRefactorEditsToExtractSymbol,
|
|
156303
|
+
getAvailableActions: getRefactorActionsToExtractSymbol,
|
|
156008
156304
|
});
|
|
156009
156305
|
/**
|
|
156010
156306
|
* Compute the associated code actions
|
|
156011
156307
|
* Exported for tests.
|
|
156012
156308
|
*/
|
|
156013
|
-
function
|
|
156309
|
+
function getRefactorActionsToExtractSymbol(context) {
|
|
156014
156310
|
var requestedRefactor = context.kind;
|
|
156015
156311
|
var rangeToExtract = getRangeToExtract(context.file, ts.getRefactorContextSpan(context), context.triggerReason === "invoked");
|
|
156016
156312
|
var targetRange = rangeToExtract.targetRange;
|
|
@@ -156139,9 +156435,9 @@ var ts;
|
|
|
156139
156435
|
return error;
|
|
156140
156436
|
}
|
|
156141
156437
|
}
|
|
156142
|
-
extractSymbol.
|
|
156438
|
+
extractSymbol.getRefactorActionsToExtractSymbol = getRefactorActionsToExtractSymbol;
|
|
156143
156439
|
/* Exported for tests */
|
|
156144
|
-
function
|
|
156440
|
+
function getRefactorEditsToExtractSymbol(context, actionName) {
|
|
156145
156441
|
var rangeToExtract = getRangeToExtract(context.file, ts.getRefactorContextSpan(context));
|
|
156146
156442
|
var targetRange = rangeToExtract.targetRange; // TODO:GH#18217
|
|
156147
156443
|
var parsedFunctionIndexMatch = /^function_scope_(\d+)$/.exec(actionName);
|
|
@@ -156158,7 +156454,7 @@ var ts;
|
|
|
156158
156454
|
}
|
|
156159
156455
|
ts.Debug.fail("Unrecognized action name");
|
|
156160
156456
|
}
|
|
156161
|
-
extractSymbol.
|
|
156457
|
+
extractSymbol.getRefactorEditsToExtractSymbol = getRefactorEditsToExtractSymbol;
|
|
156162
156458
|
// Move these into diagnostic messages if they become user-facing
|
|
156163
156459
|
var Messages;
|
|
156164
156460
|
(function (Messages) {
|
|
@@ -157709,7 +158005,7 @@ var ts;
|
|
|
157709
158005
|
extractToInterfaceAction.kind,
|
|
157710
158006
|
extractToTypeDefAction.kind
|
|
157711
158007
|
],
|
|
157712
|
-
getAvailableActions: function (context) {
|
|
158008
|
+
getAvailableActions: function getRefactorActionsToExtractType(context) {
|
|
157713
158009
|
var info = getRangeToExtract(context, context.triggerReason === "invoked");
|
|
157714
158010
|
if (!info)
|
|
157715
158011
|
return ts.emptyArray;
|
|
@@ -157734,7 +158030,7 @@ var ts;
|
|
|
157734
158030
|
}
|
|
157735
158031
|
return ts.emptyArray;
|
|
157736
158032
|
},
|
|
157737
|
-
getEditsForAction: function (context, actionName) {
|
|
158033
|
+
getEditsForAction: function getRefactorEditsToExtractType(context, actionName) {
|
|
157738
158034
|
var file = context.file;
|
|
157739
158035
|
var info = getRangeToExtract(context);
|
|
157740
158036
|
ts.Debug.assert(info && !refactor.isRefactorErrorInfo(info), "Expected to find a range to extract");
|
|
@@ -157902,7 +158198,7 @@ var ts;
|
|
|
157902
158198
|
};
|
|
157903
158199
|
refactor.registerRefactor(actionName, {
|
|
157904
158200
|
kinds: [generateGetSetAction.kind],
|
|
157905
|
-
getEditsForAction: function (context, actionName) {
|
|
158201
|
+
getEditsForAction: function getRefactorActionsToGenerateGetAndSetAccessors(context, actionName) {
|
|
157906
158202
|
if (!context.endPosition)
|
|
157907
158203
|
return undefined;
|
|
157908
158204
|
var info = ts.codefix.getAccessorConvertiblePropertyAtPosition(context.file, context.program, context.startPosition, context.endPosition);
|
|
@@ -157981,7 +158277,7 @@ var ts;
|
|
|
157981
158277
|
};
|
|
157982
158278
|
refactor.registerRefactor(refactorName, {
|
|
157983
158279
|
kinds: [moveToNewFileAction.kind],
|
|
157984
|
-
getAvailableActions: function (context) {
|
|
158280
|
+
getAvailableActions: function getRefactorActionsToMoveToNewFile(context) {
|
|
157985
158281
|
var statements = getStatementsToMove(context);
|
|
157986
158282
|
if (context.preferences.allowTextChangesInNewFiles && statements) {
|
|
157987
158283
|
return [{ name: refactorName, description: description, actions: [moveToNewFileAction] }];
|
|
@@ -157992,7 +158288,7 @@ var ts;
|
|
|
157992
158288
|
}
|
|
157993
158289
|
return ts.emptyArray;
|
|
157994
158290
|
},
|
|
157995
|
-
getEditsForAction: function (context, actionName) {
|
|
158291
|
+
getEditsForAction: function getRefactorEditsToMoveToNewFile(context, actionName) {
|
|
157996
158292
|
ts.Debug.assert(actionName === refactorName, "Wrong refactor invoked");
|
|
157997
158293
|
var statements = ts.Debug.checkDefined(getStatementsToMove(context));
|
|
157998
158294
|
var edits = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(context.file, context.program, statements, t, context.host, context.preferences); });
|
|
@@ -158723,10 +159019,10 @@ var ts;
|
|
|
158723
159019
|
};
|
|
158724
159020
|
refactor.registerRefactor(refactorName, {
|
|
158725
159021
|
kinds: [removeBracesAction.kind],
|
|
158726
|
-
getEditsForAction:
|
|
158727
|
-
getAvailableActions:
|
|
159022
|
+
getEditsForAction: getRefactorEditsToRemoveFunctionBraces,
|
|
159023
|
+
getAvailableActions: getRefactorActionsToRemoveFunctionBraces
|
|
158728
159024
|
});
|
|
158729
|
-
function
|
|
159025
|
+
function getRefactorActionsToRemoveFunctionBraces(context) {
|
|
158730
159026
|
var file = context.file, startPosition = context.startPosition, triggerReason = context.triggerReason;
|
|
158731
159027
|
var info = getConvertibleArrowFunctionAtPosition(file, startPosition, triggerReason === "invoked");
|
|
158732
159028
|
if (!info)
|
|
@@ -158752,7 +159048,7 @@ var ts;
|
|
|
158752
159048
|
}
|
|
158753
159049
|
return ts.emptyArray;
|
|
158754
159050
|
}
|
|
158755
|
-
function
|
|
159051
|
+
function getRefactorEditsToRemoveFunctionBraces(context, actionName) {
|
|
158756
159052
|
var file = context.file, startPosition = context.startPosition;
|
|
158757
159053
|
var info = getConvertibleArrowFunctionAtPosition(file, startPosition);
|
|
158758
159054
|
ts.Debug.assert(info && !refactor.isRefactorErrorInfo(info), "Expected applicable refactor info");
|
|
@@ -158826,10 +159122,10 @@ var ts;
|
|
|
158826
159122
|
};
|
|
158827
159123
|
refactor.registerRefactor(refactorName, {
|
|
158828
159124
|
kinds: [toDestructuredAction.kind],
|
|
158829
|
-
getEditsForAction:
|
|
158830
|
-
getAvailableActions:
|
|
159125
|
+
getEditsForAction: getRefactorEditsToConvertParametersToDestructuredObject,
|
|
159126
|
+
getAvailableActions: getRefactorActionsToConvertParametersToDestructuredObject
|
|
158831
159127
|
});
|
|
158832
|
-
function
|
|
159128
|
+
function getRefactorActionsToConvertParametersToDestructuredObject(context) {
|
|
158833
159129
|
var file = context.file, startPosition = context.startPosition;
|
|
158834
159130
|
var isJSFile = ts.isSourceFileJS(file);
|
|
158835
159131
|
if (isJSFile)
|
|
@@ -158843,7 +159139,7 @@ var ts;
|
|
|
158843
159139
|
actions: [toDestructuredAction]
|
|
158844
159140
|
}];
|
|
158845
159141
|
}
|
|
158846
|
-
function
|
|
159142
|
+
function getRefactorEditsToConvertParametersToDestructuredObject(context, actionName) {
|
|
158847
159143
|
ts.Debug.assert(actionName === refactorName, "Unexpected action name");
|
|
158848
159144
|
var file = context.file, startPosition = context.startPosition, program = context.program, cancellationToken = context.cancellationToken, host = context.host;
|
|
158849
159145
|
var functionDeclaration = getFunctionDeclarationAtPosition(file, startPosition, program.getTypeChecker());
|
|
@@ -159353,10 +159649,10 @@ var ts;
|
|
|
159353
159649
|
};
|
|
159354
159650
|
refactor.registerRefactor(refactorName, {
|
|
159355
159651
|
kinds: [convertStringAction.kind],
|
|
159356
|
-
getEditsForAction:
|
|
159357
|
-
getAvailableActions:
|
|
159652
|
+
getEditsForAction: getRefactorEditsToConvertToTemplateString,
|
|
159653
|
+
getAvailableActions: getRefactorActionsToConvertToTemplateString
|
|
159358
159654
|
});
|
|
159359
|
-
function
|
|
159655
|
+
function getRefactorActionsToConvertToTemplateString(context) {
|
|
159360
159656
|
var file = context.file, startPosition = context.startPosition;
|
|
159361
159657
|
var node = getNodeOrParentOfParentheses(file, startPosition);
|
|
159362
159658
|
var maybeBinary = getParentBinaryExpression(node);
|
|
@@ -159382,7 +159678,7 @@ var ts;
|
|
|
159382
159678
|
}
|
|
159383
159679
|
return node;
|
|
159384
159680
|
}
|
|
159385
|
-
function
|
|
159681
|
+
function getRefactorEditsToConvertToTemplateString(context, actionName) {
|
|
159386
159682
|
var file = context.file, startPosition = context.startPosition;
|
|
159387
159683
|
var node = getNodeOrParentOfParentheses(file, startPosition);
|
|
159388
159684
|
switch (actionName) {
|
|
@@ -159596,10 +159892,10 @@ var ts;
|
|
|
159596
159892
|
toNamedFunctionAction.kind,
|
|
159597
159893
|
toArrowFunctionAction.kind
|
|
159598
159894
|
],
|
|
159599
|
-
getEditsForAction:
|
|
159600
|
-
getAvailableActions:
|
|
159895
|
+
getEditsForAction: getRefactorEditsToConvertFunctionExpressions,
|
|
159896
|
+
getAvailableActions: getRefactorActionsToConvertFunctionExpressions
|
|
159601
159897
|
});
|
|
159602
|
-
function
|
|
159898
|
+
function getRefactorActionsToConvertFunctionExpressions(context) {
|
|
159603
159899
|
var file = context.file, startPosition = context.startPosition, program = context.program, kind = context.kind;
|
|
159604
159900
|
var info = getFunctionInfo(file, startPosition, program);
|
|
159605
159901
|
if (!info)
|
|
@@ -159643,7 +159939,7 @@ var ts;
|
|
|
159643
159939
|
errors : possibleActions
|
|
159644
159940
|
}];
|
|
159645
159941
|
}
|
|
159646
|
-
function
|
|
159942
|
+
function getRefactorEditsToConvertFunctionExpressions(context, actionName) {
|
|
159647
159943
|
var file = context.file, startPosition = context.startPosition, program = context.program;
|
|
159648
159944
|
var info = getFunctionInfo(file, startPosition, program);
|
|
159649
159945
|
if (!info)
|
|
@@ -159803,10 +160099,10 @@ var ts;
|
|
|
159803
160099
|
};
|
|
159804
160100
|
refactor.registerRefactor(refactorName, {
|
|
159805
160101
|
kinds: [inferReturnTypeAction.kind],
|
|
159806
|
-
getEditsForAction:
|
|
159807
|
-
getAvailableActions:
|
|
160102
|
+
getEditsForAction: getRefactorEditsToInferReturnType,
|
|
160103
|
+
getAvailableActions: getRefactorActionsToInferReturnType
|
|
159808
160104
|
});
|
|
159809
|
-
function
|
|
160105
|
+
function getRefactorEditsToInferReturnType(context) {
|
|
159810
160106
|
var info = getInfo(context);
|
|
159811
160107
|
if (info && !refactor.isRefactorErrorInfo(info)) {
|
|
159812
160108
|
var edits = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(context.file, t, info.declaration, info.returnTypeNode); });
|
|
@@ -159814,7 +160110,7 @@ var ts;
|
|
|
159814
160110
|
}
|
|
159815
160111
|
return undefined;
|
|
159816
160112
|
}
|
|
159817
|
-
function
|
|
160113
|
+
function getRefactorActionsToInferReturnType(context) {
|
|
159818
160114
|
var info = getInfo(context);
|
|
159819
160115
|
if (!info)
|
|
159820
160116
|
return ts.emptyArray;
|