@typescript-deploys/pr-build 4.6.0-pr-47183-2 → 4.6.0-pr-47400-2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/lib.es2020.intl.d.ts +1 -0
- package/lib/lib.es2022.error.d.ts +50 -3
- package/lib/tsc.js +272 -124
- package/lib/tsserver.js +672 -346
- package/lib/tsserverlibrary.d.ts +5 -3
- package/lib/tsserverlibrary.js +643 -345
- package/lib/typescript.d.ts +4 -3
- package/lib/typescript.js +585 -323
- package/lib/typescriptServices.d.ts +4 -3
- package/lib/typescriptServices.js +585 -323
- package/lib/typingsInstaller.js +467 -242
- package/package.json +1 -1
package/lib/tsserver.js
CHANGED
|
@@ -100,7 +100,7 @@ var ts;
|
|
|
100
100
|
// The following is baselined as a literal template type without intervention
|
|
101
101
|
/** The version of the TypeScript compiler release */
|
|
102
102
|
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
103
|
-
ts.version = ts.versionMajorMinor + ".0-insiders.
|
|
103
|
+
ts.version = ts.versionMajorMinor + ".0-insiders.20220113";
|
|
104
104
|
/* @internal */
|
|
105
105
|
var Comparison;
|
|
106
106
|
(function (Comparison) {
|
|
@@ -14456,7 +14456,8 @@ var ts;
|
|
|
14456
14456
|
Float64Array: ["at"],
|
|
14457
14457
|
BigInt64Array: ["at"],
|
|
14458
14458
|
BigUint64Array: ["at"],
|
|
14459
|
-
ObjectConstructor: ["hasOwn"]
|
|
14459
|
+
ObjectConstructor: ["hasOwn"],
|
|
14460
|
+
Error: ["cause"]
|
|
14460
14461
|
}
|
|
14461
14462
|
};
|
|
14462
14463
|
}
|
|
@@ -19790,16 +19791,6 @@ var ts;
|
|
|
19790
19791
|
(symlinkedDirectories || (symlinkedDirectories = new ts.Map())).set(symlinkPath, real);
|
|
19791
19792
|
}
|
|
19792
19793
|
},
|
|
19793
|
-
setSymlinkedDirectoryFromSymlinkedFile: function (symlink, real) {
|
|
19794
|
-
this.setSymlinkedFile(ts.toPath(symlink, cwd, getCanonicalFileName), real);
|
|
19795
|
-
var _a = guessDirectorySymlink(real, symlink, cwd, getCanonicalFileName) || ts.emptyArray, commonResolved = _a[0], commonOriginal = _a[1];
|
|
19796
|
-
if (commonResolved && commonOriginal) {
|
|
19797
|
-
this.setSymlinkedDirectory(commonOriginal, {
|
|
19798
|
-
real: commonResolved,
|
|
19799
|
-
realPath: ts.toPath(commonResolved, cwd, getCanonicalFileName),
|
|
19800
|
-
});
|
|
19801
|
-
}
|
|
19802
|
-
},
|
|
19803
19794
|
setSymlinksFromResolutions: function (files, typeReferenceDirectives) {
|
|
19804
19795
|
var _this = this;
|
|
19805
19796
|
var _a;
|
|
@@ -20767,9 +20758,40 @@ var ts;
|
|
|
20767
20758
|
}
|
|
20768
20759
|
ts.isFunctionExpressionOrArrowFunction = isFunctionExpressionOrArrowFunction;
|
|
20769
20760
|
function escapeSnippetText(text) {
|
|
20770
|
-
return text.replace(/\$/gm, "\\$");
|
|
20761
|
+
return text.replace(/\$/gm, function () { return "\\$"; });
|
|
20771
20762
|
}
|
|
20772
20763
|
ts.escapeSnippetText = escapeSnippetText;
|
|
20764
|
+
function isNumericLiteralName(name) {
|
|
20765
|
+
// The intent of numeric names is that
|
|
20766
|
+
// - they are names with text in a numeric form, and that
|
|
20767
|
+
// - setting properties/indexing with them is always equivalent to doing so with the numeric literal 'numLit',
|
|
20768
|
+
// acquired by applying the abstract 'ToNumber' operation on the name's text.
|
|
20769
|
+
//
|
|
20770
|
+
// The subtlety is in the latter portion, as we cannot reliably say that anything that looks like a numeric literal is a numeric name.
|
|
20771
|
+
// In fact, it is the case that the text of the name must be equal to 'ToString(numLit)' for this to hold.
|
|
20772
|
+
//
|
|
20773
|
+
// Consider the property name '"0xF00D"'. When one indexes with '0xF00D', they are actually indexing with the value of 'ToString(0xF00D)'
|
|
20774
|
+
// according to the ECMAScript specification, so it is actually as if the user indexed with the string '"61453"'.
|
|
20775
|
+
// Thus, the text of all numeric literals equivalent to '61543' such as '0xF00D', '0xf00D', '0170015', etc. are not valid numeric names
|
|
20776
|
+
// because their 'ToString' representation is not equal to their original text.
|
|
20777
|
+
// This is motivated by ECMA-262 sections 9.3.1, 9.8.1, 11.1.5, and 11.2.1.
|
|
20778
|
+
//
|
|
20779
|
+
// Here, we test whether 'ToString(ToNumber(name))' is exactly equal to 'name'.
|
|
20780
|
+
// The '+' prefix operator is equivalent here to applying the abstract ToNumber operation.
|
|
20781
|
+
// Applying the 'toString()' method on a number gives us the abstract ToString operation on a number.
|
|
20782
|
+
//
|
|
20783
|
+
// Note that this accepts the values 'Infinity', '-Infinity', and 'NaN', and that this is intentional.
|
|
20784
|
+
// This is desired behavior, because when indexing with them as numeric entities, you are indexing
|
|
20785
|
+
// with the strings '"Infinity"', '"-Infinity"', and '"NaN"' respectively.
|
|
20786
|
+
return (+name).toString() === name;
|
|
20787
|
+
}
|
|
20788
|
+
ts.isNumericLiteralName = isNumericLiteralName;
|
|
20789
|
+
function createPropertyNameNodeForIdentifierOrLiteral(name, target, singleQuote, stringNamed) {
|
|
20790
|
+
return ts.isIdentifierText(name, target) ? ts.factory.createIdentifier(name) :
|
|
20791
|
+
!stringNamed && isNumericLiteralName(name) && +name >= 0 ? ts.factory.createNumericLiteral(+name) :
|
|
20792
|
+
ts.factory.createStringLiteral(name, !!singleQuote);
|
|
20793
|
+
}
|
|
20794
|
+
ts.createPropertyNameNodeForIdentifierOrLiteral = createPropertyNameNodeForIdentifierOrLiteral;
|
|
20773
20795
|
function isThisTypeParameter(type) {
|
|
20774
20796
|
return !!(type.flags & 262144 /* TypeParameter */ && type.isThisType);
|
|
20775
20797
|
}
|
|
@@ -22242,7 +22264,7 @@ var ts;
|
|
|
22242
22264
|
result.push(createModifier(144 /* ReadonlyKeyword */));
|
|
22243
22265
|
if (flags & 256 /* Async */)
|
|
22244
22266
|
result.push(createModifier(131 /* AsyncKeyword */));
|
|
22245
|
-
return result;
|
|
22267
|
+
return result.length ? result : undefined;
|
|
22246
22268
|
}
|
|
22247
22269
|
//
|
|
22248
22270
|
// Names
|
|
@@ -26199,32 +26221,36 @@ var ts;
|
|
|
26199
26221
|
}
|
|
26200
26222
|
function updateModifiers(node, modifiers) {
|
|
26201
26223
|
var _a;
|
|
26224
|
+
var modifierArray;
|
|
26202
26225
|
if (typeof modifiers === "number") {
|
|
26203
|
-
|
|
26204
|
-
}
|
|
26205
|
-
|
|
26206
|
-
|
|
26207
|
-
|
|
26208
|
-
|
|
26209
|
-
|
|
26210
|
-
|
|
26211
|
-
|
|
26212
|
-
|
|
26213
|
-
|
|
26214
|
-
|
|
26215
|
-
|
|
26216
|
-
|
|
26217
|
-
|
|
26218
|
-
|
|
26219
|
-
|
|
26220
|
-
|
|
26221
|
-
|
|
26222
|
-
|
|
26223
|
-
|
|
26224
|
-
|
|
26225
|
-
|
|
26226
|
-
|
|
26227
|
-
|
|
26226
|
+
modifierArray = createModifiersFromModifierFlags(modifiers);
|
|
26227
|
+
}
|
|
26228
|
+
else {
|
|
26229
|
+
modifierArray = modifiers;
|
|
26230
|
+
}
|
|
26231
|
+
return ts.isParameter(node) ? updateParameterDeclaration(node, node.decorators, modifierArray, node.dotDotDotToken, node.name, node.questionToken, node.type, node.initializer) :
|
|
26232
|
+
ts.isPropertySignature(node) ? updatePropertySignature(node, modifierArray, node.name, node.questionToken, node.type) :
|
|
26233
|
+
ts.isPropertyDeclaration(node) ? updatePropertyDeclaration(node, node.decorators, modifierArray, node.name, (_a = node.questionToken) !== null && _a !== void 0 ? _a : node.exclamationToken, node.type, node.initializer) :
|
|
26234
|
+
ts.isMethodSignature(node) ? updateMethodSignature(node, modifierArray, node.name, node.questionToken, node.typeParameters, node.parameters, node.type) :
|
|
26235
|
+
ts.isMethodDeclaration(node) ? updateMethodDeclaration(node, node.decorators, modifierArray, node.asteriskToken, node.name, node.questionToken, node.typeParameters, node.parameters, node.type, node.body) :
|
|
26236
|
+
ts.isConstructorDeclaration(node) ? updateConstructorDeclaration(node, node.decorators, modifierArray, node.parameters, node.body) :
|
|
26237
|
+
ts.isGetAccessorDeclaration(node) ? updateGetAccessorDeclaration(node, node.decorators, modifierArray, node.name, node.parameters, node.type, node.body) :
|
|
26238
|
+
ts.isSetAccessorDeclaration(node) ? updateSetAccessorDeclaration(node, node.decorators, modifierArray, node.name, node.parameters, node.body) :
|
|
26239
|
+
ts.isIndexSignatureDeclaration(node) ? updateIndexSignature(node, node.decorators, modifierArray, node.parameters, node.type) :
|
|
26240
|
+
ts.isFunctionExpression(node) ? updateFunctionExpression(node, modifierArray, node.asteriskToken, node.name, node.typeParameters, node.parameters, node.type, node.body) :
|
|
26241
|
+
ts.isArrowFunction(node) ? updateArrowFunction(node, modifierArray, node.typeParameters, node.parameters, node.type, node.equalsGreaterThanToken, node.body) :
|
|
26242
|
+
ts.isClassExpression(node) ? updateClassExpression(node, node.decorators, modifierArray, node.name, node.typeParameters, node.heritageClauses, node.members) :
|
|
26243
|
+
ts.isVariableStatement(node) ? updateVariableStatement(node, modifierArray, node.declarationList) :
|
|
26244
|
+
ts.isFunctionDeclaration(node) ? updateFunctionDeclaration(node, node.decorators, modifierArray, node.asteriskToken, node.name, node.typeParameters, node.parameters, node.type, node.body) :
|
|
26245
|
+
ts.isClassDeclaration(node) ? updateClassDeclaration(node, node.decorators, modifierArray, node.name, node.typeParameters, node.heritageClauses, node.members) :
|
|
26246
|
+
ts.isInterfaceDeclaration(node) ? updateInterfaceDeclaration(node, node.decorators, modifierArray, node.name, node.typeParameters, node.heritageClauses, node.members) :
|
|
26247
|
+
ts.isTypeAliasDeclaration(node) ? updateTypeAliasDeclaration(node, node.decorators, modifierArray, node.name, node.typeParameters, node.type) :
|
|
26248
|
+
ts.isEnumDeclaration(node) ? updateEnumDeclaration(node, node.decorators, modifierArray, node.name, node.members) :
|
|
26249
|
+
ts.isModuleDeclaration(node) ? updateModuleDeclaration(node, node.decorators, modifierArray, node.name, node.body) :
|
|
26250
|
+
ts.isImportEqualsDeclaration(node) ? updateImportEqualsDeclaration(node, node.decorators, modifierArray, node.isTypeOnly, node.name, node.moduleReference) :
|
|
26251
|
+
ts.isImportDeclaration(node) ? updateImportDeclaration(node, node.decorators, modifierArray, node.importClause, node.moduleSpecifier, node.assertClause) :
|
|
26252
|
+
ts.isExportAssignment(node) ? updateExportAssignment(node, node.decorators, modifierArray, node.expression) :
|
|
26253
|
+
ts.isExportDeclaration(node) ? updateExportDeclaration(node, node.decorators, modifierArray, node.isTypeOnly, node.exportClause, node.moduleSpecifier, node.assertClause) :
|
|
26228
26254
|
ts.Debug.assertNever(node);
|
|
26229
26255
|
}
|
|
26230
26256
|
function asNodeArray(array) {
|
|
@@ -41473,9 +41499,7 @@ var ts;
|
|
|
41473
41499
|
}
|
|
41474
41500
|
}
|
|
41475
41501
|
var failedLookupLocations = [];
|
|
41476
|
-
var features =
|
|
41477
|
-
ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.NodeNext ? NodeResolutionFeatures.NodeNextDefault :
|
|
41478
|
-
NodeResolutionFeatures.None;
|
|
41502
|
+
var features = getDefaultNodeResolutionFeatures(options);
|
|
41479
41503
|
var moduleResolutionState = { compilerOptions: options, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: cache, features: features, conditions: ["node", "require", "types"] };
|
|
41480
41504
|
var resolved = primaryLookup();
|
|
41481
41505
|
var primary = true;
|
|
@@ -41560,6 +41584,34 @@ var ts;
|
|
|
41560
41584
|
}
|
|
41561
41585
|
}
|
|
41562
41586
|
ts.resolveTypeReferenceDirective = resolveTypeReferenceDirective;
|
|
41587
|
+
function getDefaultNodeResolutionFeatures(options) {
|
|
41588
|
+
return ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Node12 ? NodeResolutionFeatures.Node12Default :
|
|
41589
|
+
ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.NodeNext ? NodeResolutionFeatures.NodeNextDefault :
|
|
41590
|
+
NodeResolutionFeatures.None;
|
|
41591
|
+
}
|
|
41592
|
+
/**
|
|
41593
|
+
* @internal
|
|
41594
|
+
* Does not try `@types/${packageName}` - use a second pass if needed.
|
|
41595
|
+
*/
|
|
41596
|
+
function resolvePackageNameToPackageJson(packageName, containingDirectory, options, host, cache) {
|
|
41597
|
+
var moduleResolutionState = {
|
|
41598
|
+
compilerOptions: options,
|
|
41599
|
+
host: host,
|
|
41600
|
+
traceEnabled: isTraceEnabled(options, host),
|
|
41601
|
+
failedLookupLocations: [],
|
|
41602
|
+
packageJsonInfoCache: cache === null || cache === void 0 ? void 0 : cache.getPackageJsonInfoCache(),
|
|
41603
|
+
conditions: ts.emptyArray,
|
|
41604
|
+
features: NodeResolutionFeatures.None,
|
|
41605
|
+
};
|
|
41606
|
+
return ts.forEachAncestorDirectory(containingDirectory, function (ancestorDirectory) {
|
|
41607
|
+
if (ts.getBaseFileName(ancestorDirectory) !== "node_modules") {
|
|
41608
|
+
var nodeModulesFolder = ts.combinePaths(ancestorDirectory, "node_modules");
|
|
41609
|
+
var candidate = ts.combinePaths(nodeModulesFolder, packageName);
|
|
41610
|
+
return getPackageJsonInfo(candidate, /*onlyRecordFailures*/ false, moduleResolutionState);
|
|
41611
|
+
}
|
|
41612
|
+
});
|
|
41613
|
+
}
|
|
41614
|
+
ts.resolvePackageNameToPackageJson = resolvePackageNameToPackageJson;
|
|
41563
41615
|
/**
|
|
41564
41616
|
* Given a set of options, returns the set of type directive names
|
|
41565
41617
|
* that should be included for this program automatically.
|
|
@@ -42133,11 +42185,6 @@ var ts;
|
|
|
42133
42185
|
}
|
|
42134
42186
|
ts.resolveJSModule = resolveJSModule;
|
|
42135
42187
|
/* @internal */
|
|
42136
|
-
function tryResolveJSModule(moduleName, initialDir, host) {
|
|
42137
|
-
return tryResolveJSModuleWorker(moduleName, initialDir, host).resolvedModule;
|
|
42138
|
-
}
|
|
42139
|
-
ts.tryResolveJSModule = tryResolveJSModule;
|
|
42140
|
-
/* @internal */
|
|
42141
42188
|
var NodeResolutionFeatures;
|
|
42142
42189
|
(function (NodeResolutionFeatures) {
|
|
42143
42190
|
NodeResolutionFeatures[NodeResolutionFeatures["None"] = 0] = "None";
|
|
@@ -42445,6 +42492,97 @@ var ts;
|
|
|
42445
42492
|
var versionPaths = packageInfo && packageInfo.versionPaths;
|
|
42446
42493
|
return withPackageId(packageInfo, loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFailures, state, packageJsonContent, versionPaths));
|
|
42447
42494
|
}
|
|
42495
|
+
/* @internal */
|
|
42496
|
+
function getEntrypointsFromPackageJsonInfo(packageJsonInfo, options, host, cache, resolveJs) {
|
|
42497
|
+
if (!resolveJs && packageJsonInfo.resolvedEntrypoints !== undefined) {
|
|
42498
|
+
// Cached value excludes resolutions to JS files - those could be
|
|
42499
|
+
// cached separately, but they're used rarely.
|
|
42500
|
+
return packageJsonInfo.resolvedEntrypoints;
|
|
42501
|
+
}
|
|
42502
|
+
var entrypoints;
|
|
42503
|
+
var extensions = resolveJs ? Extensions.JavaScript : Extensions.TypeScript;
|
|
42504
|
+
var features = getDefaultNodeResolutionFeatures(options);
|
|
42505
|
+
var requireState = {
|
|
42506
|
+
compilerOptions: options,
|
|
42507
|
+
host: host,
|
|
42508
|
+
traceEnabled: isTraceEnabled(options, host),
|
|
42509
|
+
failedLookupLocations: [],
|
|
42510
|
+
packageJsonInfoCache: cache === null || cache === void 0 ? void 0 : cache.getPackageJsonInfoCache(),
|
|
42511
|
+
conditions: ["node", "require", "types"],
|
|
42512
|
+
features: features,
|
|
42513
|
+
};
|
|
42514
|
+
var requireResolution = loadNodeModuleFromDirectoryWorker(extensions, packageJsonInfo.packageDirectory,
|
|
42515
|
+
/*onlyRecordFailures*/ false, requireState, packageJsonInfo.packageJsonContent, packageJsonInfo.versionPaths);
|
|
42516
|
+
entrypoints = ts.append(entrypoints, requireResolution === null || requireResolution === void 0 ? void 0 : requireResolution.path);
|
|
42517
|
+
if (features & NodeResolutionFeatures.Exports && packageJsonInfo.packageJsonContent.exports) {
|
|
42518
|
+
for (var _i = 0, _a = [["node", "import", "types"], ["node", "require", "types"]]; _i < _a.length; _i++) {
|
|
42519
|
+
var conditions = _a[_i];
|
|
42520
|
+
var exportState = __assign(__assign({}, requireState), { failedLookupLocations: [], conditions: conditions });
|
|
42521
|
+
var exportResolutions = loadEntrypointsFromExportMap(packageJsonInfo, packageJsonInfo.packageJsonContent.exports, exportState, extensions);
|
|
42522
|
+
if (exportResolutions) {
|
|
42523
|
+
for (var _b = 0, exportResolutions_1 = exportResolutions; _b < exportResolutions_1.length; _b++) {
|
|
42524
|
+
var resolution = exportResolutions_1[_b];
|
|
42525
|
+
entrypoints = ts.appendIfUnique(entrypoints, resolution.path);
|
|
42526
|
+
}
|
|
42527
|
+
}
|
|
42528
|
+
}
|
|
42529
|
+
}
|
|
42530
|
+
return packageJsonInfo.resolvedEntrypoints = entrypoints || false;
|
|
42531
|
+
}
|
|
42532
|
+
ts.getEntrypointsFromPackageJsonInfo = getEntrypointsFromPackageJsonInfo;
|
|
42533
|
+
function loadEntrypointsFromExportMap(scope, exports, state, extensions) {
|
|
42534
|
+
var entrypoints;
|
|
42535
|
+
if (ts.isArray(exports)) {
|
|
42536
|
+
for (var _i = 0, exports_1 = exports; _i < exports_1.length; _i++) {
|
|
42537
|
+
var target = exports_1[_i];
|
|
42538
|
+
loadEntrypointsFromTargetExports(target);
|
|
42539
|
+
}
|
|
42540
|
+
}
|
|
42541
|
+
// eslint-disable-next-line no-null/no-null
|
|
42542
|
+
else if (typeof exports === "object" && exports !== null && allKeysStartWithDot(exports)) {
|
|
42543
|
+
for (var key in exports) {
|
|
42544
|
+
loadEntrypointsFromTargetExports(exports[key]);
|
|
42545
|
+
}
|
|
42546
|
+
}
|
|
42547
|
+
else {
|
|
42548
|
+
loadEntrypointsFromTargetExports(exports);
|
|
42549
|
+
}
|
|
42550
|
+
return entrypoints;
|
|
42551
|
+
function loadEntrypointsFromTargetExports(target) {
|
|
42552
|
+
var _a, _b;
|
|
42553
|
+
if (typeof target === "string" && ts.startsWith(target, "./") && target.indexOf("*") === -1) {
|
|
42554
|
+
var partsAfterFirst = ts.getPathComponents(target).slice(2);
|
|
42555
|
+
if (partsAfterFirst.indexOf("..") >= 0 || partsAfterFirst.indexOf(".") >= 0 || partsAfterFirst.indexOf("node_modules") >= 0) {
|
|
42556
|
+
return false;
|
|
42557
|
+
}
|
|
42558
|
+
var resolvedTarget = ts.combinePaths(scope.packageDirectory, target);
|
|
42559
|
+
var finalPath = ts.getNormalizedAbsolutePath(resolvedTarget, (_b = (_a = state.host).getCurrentDirectory) === null || _b === void 0 ? void 0 : _b.call(_a));
|
|
42560
|
+
var result = loadJSOrExactTSFileName(extensions, finalPath, /*recordOnlyFailures*/ false, state);
|
|
42561
|
+
if (result) {
|
|
42562
|
+
entrypoints = ts.appendIfUnique(entrypoints, result, function (a, b) { return a.path === b.path; });
|
|
42563
|
+
return true;
|
|
42564
|
+
}
|
|
42565
|
+
}
|
|
42566
|
+
else if (Array.isArray(target)) {
|
|
42567
|
+
for (var _i = 0, target_1 = target; _i < target_1.length; _i++) {
|
|
42568
|
+
var t = target_1[_i];
|
|
42569
|
+
var success = loadEntrypointsFromTargetExports(t);
|
|
42570
|
+
if (success) {
|
|
42571
|
+
return true;
|
|
42572
|
+
}
|
|
42573
|
+
}
|
|
42574
|
+
}
|
|
42575
|
+
// eslint-disable-next-line no-null/no-null
|
|
42576
|
+
else if (typeof target === "object" && target !== null) {
|
|
42577
|
+
return ts.forEach(ts.getOwnKeys(target), function (key) {
|
|
42578
|
+
if (key === "default" || ts.contains(state.conditions, key) || isApplicableVersionedTypesKey(state.conditions, key)) {
|
|
42579
|
+
loadEntrypointsFromTargetExports(target[key]);
|
|
42580
|
+
return true;
|
|
42581
|
+
}
|
|
42582
|
+
});
|
|
42583
|
+
}
|
|
42584
|
+
}
|
|
42585
|
+
}
|
|
42448
42586
|
/**
|
|
42449
42587
|
* A function for locating the package.json scope for a given path
|
|
42450
42588
|
*/
|
|
@@ -42501,7 +42639,7 @@ var ts;
|
|
|
42501
42639
|
trace(host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath);
|
|
42502
42640
|
}
|
|
42503
42641
|
var versionPaths = readPackageJsonTypesVersionPaths(packageJsonContent, state);
|
|
42504
|
-
var result = { packageDirectory: packageDirectory, packageJsonContent: packageJsonContent, versionPaths: versionPaths };
|
|
42642
|
+
var result = { packageDirectory: packageDirectory, packageJsonContent: packageJsonContent, versionPaths: versionPaths, resolvedEntrypoints: undefined };
|
|
42505
42643
|
(_b = state.packageJsonInfoCache) === null || _b === void 0 ? void 0 : _b.setPackageJsonInfo(packageJsonPath, result);
|
|
42506
42644
|
return result;
|
|
42507
42645
|
}
|
|
@@ -42798,8 +42936,8 @@ var ts;
|
|
|
42798
42936
|
}
|
|
42799
42937
|
return toSearchResult(/*value*/ undefined);
|
|
42800
42938
|
}
|
|
42801
|
-
for (var _d = 0,
|
|
42802
|
-
var elem =
|
|
42939
|
+
for (var _d = 0, target_2 = target; _d < target_2.length; _d++) {
|
|
42940
|
+
var elem = target_2[_d];
|
|
42803
42941
|
var result = loadModuleFromTargetImportOrExport(elem, subpath, pattern);
|
|
42804
42942
|
if (result) {
|
|
42805
42943
|
return result;
|
|
@@ -46838,6 +46976,7 @@ var ts;
|
|
|
46838
46976
|
var location = ts.getParseTreeNode(locationIn);
|
|
46839
46977
|
return location ? getTypeOfSymbolAtLocation(symbol, location) : errorType;
|
|
46840
46978
|
},
|
|
46979
|
+
getTypeOfSymbol: getTypeOfSymbol,
|
|
46841
46980
|
getSymbolsOfParameterPropertyDeclaration: function (parameterIn, parameterName) {
|
|
46842
46981
|
var parameter = ts.getParseTreeNode(parameterIn, ts.isParameter);
|
|
46843
46982
|
if (parameter === undefined)
|
|
@@ -49827,7 +49966,7 @@ var ts;
|
|
|
49827
49966
|
if (!sigs || !sigs.length) {
|
|
49828
49967
|
sigs = getSignaturesOfStructuredType(type, 1 /* Construct */);
|
|
49829
49968
|
}
|
|
49830
|
-
if ((sigs && sigs.length) || getPropertyOfType(type, "default" /* Default */)) {
|
|
49969
|
+
if ((sigs && sigs.length) || getPropertyOfType(type, "default" /* Default */, /*skipObjectFunctionPropertyAugment*/ true)) {
|
|
49831
49970
|
var moduleType = getTypeWithSyntheticDefaultImportType(type, symbol, moduleSymbol, reference);
|
|
49832
49971
|
return cloneTypeAsModuleType(symbol, moduleType, referenceParent);
|
|
49833
49972
|
}
|
|
@@ -52031,8 +52170,8 @@ var ts;
|
|
|
52031
52170
|
}
|
|
52032
52171
|
else {
|
|
52033
52172
|
if (parent && getExportsOfSymbol(parent)) {
|
|
52034
|
-
var
|
|
52035
|
-
ts.forEachEntry(
|
|
52173
|
+
var exports_2 = getExportsOfSymbol(parent);
|
|
52174
|
+
ts.forEachEntry(exports_2, function (ex, name) {
|
|
52036
52175
|
if (getSymbolIfSameReference(ex, symbol) && !isLateBoundName(name) && name !== "export=" /* ExportEquals */) {
|
|
52037
52176
|
symbolName = ts.unescapeLeadingUnderscores(name);
|
|
52038
52177
|
return true;
|
|
@@ -52193,7 +52332,7 @@ var ts;
|
|
|
52193
52332
|
}
|
|
52194
52333
|
var rawName = ts.unescapeLeadingUnderscores(symbol.escapedName);
|
|
52195
52334
|
var stringNamed = !!ts.length(symbol.declarations) && ts.every(symbol.declarations, isStringNamed);
|
|
52196
|
-
return createPropertyNameNodeForIdentifierOrLiteral(rawName,
|
|
52335
|
+
return ts.createPropertyNameNodeForIdentifierOrLiteral(rawName, ts.getEmitScriptTarget(compilerOptions), singleQuote, stringNamed);
|
|
52197
52336
|
}
|
|
52198
52337
|
// See getNameForSymbolFromNameType for a stringy equivalent
|
|
52199
52338
|
function getPropertyNameNodeForSymbolFromNameType(symbol, context, singleQuote) {
|
|
@@ -52201,24 +52340,19 @@ var ts;
|
|
|
52201
52340
|
if (nameType) {
|
|
52202
52341
|
if (nameType.flags & 384 /* StringOrNumberLiteral */) {
|
|
52203
52342
|
var name = "" + nameType.value;
|
|
52204
|
-
if (!ts.isIdentifierText(name, ts.getEmitScriptTarget(compilerOptions)) && !isNumericLiteralName(name)) {
|
|
52343
|
+
if (!ts.isIdentifierText(name, ts.getEmitScriptTarget(compilerOptions)) && !ts.isNumericLiteralName(name)) {
|
|
52205
52344
|
return ts.factory.createStringLiteral(name, !!singleQuote);
|
|
52206
52345
|
}
|
|
52207
|
-
if (isNumericLiteralName(name) && ts.startsWith(name, "-")) {
|
|
52346
|
+
if (ts.isNumericLiteralName(name) && ts.startsWith(name, "-")) {
|
|
52208
52347
|
return ts.factory.createComputedPropertyName(ts.factory.createNumericLiteral(+name));
|
|
52209
52348
|
}
|
|
52210
|
-
return createPropertyNameNodeForIdentifierOrLiteral(name);
|
|
52349
|
+
return ts.createPropertyNameNodeForIdentifierOrLiteral(name, ts.getEmitScriptTarget(compilerOptions));
|
|
52211
52350
|
}
|
|
52212
52351
|
if (nameType.flags & 8192 /* UniqueESSymbol */) {
|
|
52213
52352
|
return ts.factory.createComputedPropertyName(symbolToExpression(nameType.symbol, context, 111551 /* Value */));
|
|
52214
52353
|
}
|
|
52215
52354
|
}
|
|
52216
52355
|
}
|
|
52217
|
-
function createPropertyNameNodeForIdentifierOrLiteral(name, stringNamed, singleQuote) {
|
|
52218
|
-
return ts.isIdentifierText(name, ts.getEmitScriptTarget(compilerOptions)) ? ts.factory.createIdentifier(name) :
|
|
52219
|
-
!stringNamed && isNumericLiteralName(name) && +name >= 0 ? ts.factory.createNumericLiteral(+name) :
|
|
52220
|
-
ts.factory.createStringLiteral(name, !!singleQuote);
|
|
52221
|
-
}
|
|
52222
52356
|
function cloneNodeBuilderContext(context) {
|
|
52223
52357
|
var initial = __assign({}, context);
|
|
52224
52358
|
// Make type parameters created within this context not consume the name outside this context
|
|
@@ -53734,10 +53868,10 @@ var ts;
|
|
|
53734
53868
|
if (nameType) {
|
|
53735
53869
|
if (nameType.flags & 384 /* StringOrNumberLiteral */) {
|
|
53736
53870
|
var name = "" + nameType.value;
|
|
53737
|
-
if (!ts.isIdentifierText(name, ts.getEmitScriptTarget(compilerOptions)) && !isNumericLiteralName(name)) {
|
|
53871
|
+
if (!ts.isIdentifierText(name, ts.getEmitScriptTarget(compilerOptions)) && !ts.isNumericLiteralName(name)) {
|
|
53738
53872
|
return "\"" + ts.escapeString(name, 34 /* doubleQuote */) + "\"";
|
|
53739
53873
|
}
|
|
53740
|
-
if (isNumericLiteralName(name) && ts.startsWith(name, "-")) {
|
|
53874
|
+
if (ts.isNumericLiteralName(name) && ts.startsWith(name, "-")) {
|
|
53741
53875
|
return "[" + name + "]";
|
|
53742
53876
|
}
|
|
53743
53877
|
return name;
|
|
@@ -57148,6 +57282,11 @@ var ts;
|
|
|
57148
57282
|
return simplified !== type ? simplified : getConstraintOfType(type);
|
|
57149
57283
|
}
|
|
57150
57284
|
function getConstraintFromIndexedAccess(type) {
|
|
57285
|
+
if (isMappedTypeGenericIndexedAccess(type)) {
|
|
57286
|
+
// For indexed access types of the form { [P in K]: E }[X], where K is non-generic and X is generic,
|
|
57287
|
+
// we substitute an instantiation of E where P is replaced with X.
|
|
57288
|
+
return substituteIndexedMappedType(type.objectType, type.indexType);
|
|
57289
|
+
}
|
|
57151
57290
|
var indexConstraint = getSimplifiedTypeOrConstraint(type.indexType);
|
|
57152
57291
|
if (indexConstraint && indexConstraint !== type.indexType) {
|
|
57153
57292
|
var indexedAccess = getIndexedAccessTypeOrUndefined(type.objectType, indexConstraint, type.accessFlags);
|
|
@@ -57352,6 +57491,11 @@ var ts;
|
|
|
57352
57491
|
return constraint ? getStringMappingType(t.symbol, constraint) : stringType;
|
|
57353
57492
|
}
|
|
57354
57493
|
if (t.flags & 8388608 /* IndexedAccess */) {
|
|
57494
|
+
if (isMappedTypeGenericIndexedAccess(t)) {
|
|
57495
|
+
// For indexed access types of the form { [P in K]: E }[X], where K is non-generic and X is generic,
|
|
57496
|
+
// we substitute an instantiation of E where P is replaced with X.
|
|
57497
|
+
return getBaseConstraint(substituteIndexedMappedType(t.objectType, t.indexType));
|
|
57498
|
+
}
|
|
57355
57499
|
var baseObjectType = getBaseConstraint(t.objectType);
|
|
57356
57500
|
var baseIndexType = getBaseConstraint(t.indexType);
|
|
57357
57501
|
var baseIndexedAccess = baseObjectType && baseIndexType && getIndexedAccessTypeOrUndefined(baseObjectType, baseIndexType, t.accessFlags);
|
|
@@ -57436,13 +57580,7 @@ var ts;
|
|
|
57436
57580
|
* type itself.
|
|
57437
57581
|
*/
|
|
57438
57582
|
function getApparentType(type) {
|
|
57439
|
-
|
|
57440
|
-
// { [P in K]: E }[X], where K is non-generic and X is generic. For those types, we instead substitute an
|
|
57441
|
-
// instantiation of E where P is replaced with X. We do this because getBaseConstraintOfType directly
|
|
57442
|
-
// lowers to an instantiation where X's constraint is substituted for X, which isn't always desirable.
|
|
57443
|
-
var t = !(type.flags & 465829888 /* Instantiable */) ? type :
|
|
57444
|
-
isMappedTypeGenericIndexedAccess(type) ? substituteIndexedMappedType(type.objectType, type.indexType) :
|
|
57445
|
-
getBaseConstraintOfType(type) || unknownType;
|
|
57583
|
+
var t = !(type.flags & 465829888 /* Instantiable */) ? type : getBaseConstraintOfType(type) || unknownType;
|
|
57446
57584
|
return ts.getObjectFlags(t) & 32 /* Mapped */ ? getApparentTypeOfMappedType(t) :
|
|
57447
57585
|
t.flags & 2097152 /* Intersection */ ? getApparentTypeOfIntersectionType(t) :
|
|
57448
57586
|
t.flags & 402653316 /* StringLike */ ? globalStringType :
|
|
@@ -57724,7 +57862,7 @@ var ts;
|
|
|
57724
57862
|
return symbol_1;
|
|
57725
57863
|
}
|
|
57726
57864
|
}
|
|
57727
|
-
return
|
|
57865
|
+
return getPropertyOfObjectType(globalObjectType, name);
|
|
57728
57866
|
}
|
|
57729
57867
|
if (type.flags & 3145728 /* UnionOrIntersection */) {
|
|
57730
57868
|
return getPropertyOfUnionOrIntersectionType(type, name, skipObjectFunctionPropertyAugment);
|
|
@@ -57780,7 +57918,7 @@ var ts;
|
|
|
57780
57918
|
// signature applies to types assignable to 'number' and numeric string literal types.
|
|
57781
57919
|
return isTypeAssignableTo(source, target) ||
|
|
57782
57920
|
target === stringType && isTypeAssignableTo(source, numberType) ||
|
|
57783
|
-
target === numberType && !!(source.flags & 128 /* StringLiteral */) && isNumericLiteralName(source.value);
|
|
57921
|
+
target === numberType && !!(source.flags & 128 /* StringLiteral */) && ts.isNumericLiteralName(source.value);
|
|
57784
57922
|
}
|
|
57785
57923
|
function getIndexInfosOfStructuredType(type) {
|
|
57786
57924
|
if (type.flags & 3670016 /* StructuredType */) {
|
|
@@ -60346,7 +60484,7 @@ var ts;
|
|
|
60346
60484
|
getFlowTypeOfReference(accessExpression, propType) :
|
|
60347
60485
|
propType;
|
|
60348
60486
|
}
|
|
60349
|
-
if (everyType(objectType, isTupleType) && isNumericLiteralName(propName) && +propName >= 0) {
|
|
60487
|
+
if (everyType(objectType, isTupleType) && ts.isNumericLiteralName(propName) && +propName >= 0) {
|
|
60350
60488
|
if (accessNode && everyType(objectType, function (t) { return !t.target.hasRestElement; }) && !(accessFlags & 16 /* NoTupleBoundsCheck */)) {
|
|
60351
60489
|
var indexNode = getIndexNodeForAccessExpression(accessNode);
|
|
60352
60490
|
if (isTupleType(objectType)) {
|
|
@@ -60631,7 +60769,7 @@ var ts;
|
|
|
60631
60769
|
return everyType(indexType, function (t) {
|
|
60632
60770
|
if (t.flags & 384 /* StringOrNumberLiteral */) {
|
|
60633
60771
|
var propName = getPropertyNameFromType(t);
|
|
60634
|
-
if (isNumericLiteralName(propName)) {
|
|
60772
|
+
if (ts.isNumericLiteralName(propName)) {
|
|
60635
60773
|
var index = +propName;
|
|
60636
60774
|
return index >= 0 && index < limit;
|
|
60637
60775
|
}
|
|
@@ -64106,6 +64244,17 @@ var ts;
|
|
|
64106
64244
|
resetErrorInfo(saveErrorInfo);
|
|
64107
64245
|
return result;
|
|
64108
64246
|
}
|
|
64247
|
+
if (isMappedTypeGenericIndexedAccess(source)) {
|
|
64248
|
+
// For an indexed access type { [P in K]: E}[X], above we have already explored an instantiation of E with X
|
|
64249
|
+
// substituted for P. We also want to explore type { [P in K]: E }[C], where C is the constraint of X.
|
|
64250
|
+
var indexConstraint = getConstraintOfType(source.indexType);
|
|
64251
|
+
if (indexConstraint) {
|
|
64252
|
+
if (result = isRelatedTo(getIndexedAccessType(source.objectType, indexConstraint), target, 1 /* Source */, reportErrors)) {
|
|
64253
|
+
resetErrorInfo(saveErrorInfo);
|
|
64254
|
+
return result;
|
|
64255
|
+
}
|
|
64256
|
+
}
|
|
64257
|
+
}
|
|
64109
64258
|
}
|
|
64110
64259
|
}
|
|
64111
64260
|
else if (source.flags & 4194304 /* Index */) {
|
|
@@ -64173,7 +64322,7 @@ var ts;
|
|
|
64173
64322
|
else {
|
|
64174
64323
|
// conditionals aren't related to one another via distributive constraint as it is much too inaccurate and allows way
|
|
64175
64324
|
// more assignments than are desirable (since it maps the source check type to its constraint, it loses information)
|
|
64176
|
-
var distributiveConstraint = getConstraintOfDistributiveConditionalType(source);
|
|
64325
|
+
var distributiveConstraint = hasNonCircularBaseConstraint(source) ? getConstraintOfDistributiveConditionalType(source) : undefined;
|
|
64177
64326
|
if (distributiveConstraint) {
|
|
64178
64327
|
if (result = isRelatedTo(distributiveConstraint, target, 1 /* Source */, reportErrors)) {
|
|
64179
64328
|
resetErrorInfo(saveErrorInfo);
|
|
@@ -64719,7 +64868,7 @@ var ts;
|
|
|
64719
64868
|
for (var _b = 0, _c = excludeProperties(properties, excludedProperties); _b < _c.length; _b++) {
|
|
64720
64869
|
var targetProp = _c[_b];
|
|
64721
64870
|
var name = targetProp.escapedName;
|
|
64722
|
-
if (!(targetProp.flags & 4194304 /* Prototype */) && (!numericNamesOnly || isNumericLiteralName(name) || name === "length")) {
|
|
64871
|
+
if (!(targetProp.flags & 4194304 /* Prototype */) && (!numericNamesOnly || ts.isNumericLiteralName(name) || name === "length")) {
|
|
64723
64872
|
var sourceProp = getPropertyOfType(source, name);
|
|
64724
64873
|
if (sourceProp && sourceProp !== targetProp) {
|
|
64725
64874
|
var related = propertyRelatedTo(source, target, sourceProp, targetProp, getNonMissingTypeOfSymbol, reportErrors, intersectionState, relation === comparableRelation);
|
|
@@ -64792,7 +64941,8 @@ var ts;
|
|
|
64792
64941
|
var incompatibleReporter = kind === 1 /* Construct */ ? reportIncompatibleConstructSignatureReturn : reportIncompatibleCallSignatureReturn;
|
|
64793
64942
|
var sourceObjectFlags = ts.getObjectFlags(source);
|
|
64794
64943
|
var targetObjectFlags = ts.getObjectFlags(target);
|
|
64795
|
-
if (sourceObjectFlags & 64 /* Instantiated */ && targetObjectFlags & 64 /* Instantiated */ && source.symbol === target.symbol
|
|
64944
|
+
if (sourceObjectFlags & 64 /* Instantiated */ && targetObjectFlags & 64 /* Instantiated */ && source.symbol === target.symbol ||
|
|
64945
|
+
sourceObjectFlags & 4 /* Reference */ && targetObjectFlags & 4 /* Reference */ && source.target === target.target) {
|
|
64796
64946
|
// We have instantiations of the same anonymous type (which typically will be the type of a
|
|
64797
64947
|
// method). Simply do a pairwise comparison of the signatures in the two signature lists instead
|
|
64798
64948
|
// of the much more expensive N * M comparison matrix we explore below. We erase type parameters
|
|
@@ -65827,9 +65977,12 @@ var ts;
|
|
|
65827
65977
|
* with no call or construct signatures.
|
|
65828
65978
|
*/
|
|
65829
65979
|
function isObjectTypeWithInferableIndex(type) {
|
|
65830
|
-
return type.flags & 2097152 /* Intersection */
|
|
65831
|
-
|
|
65832
|
-
|
|
65980
|
+
return type.flags & 2097152 /* Intersection */
|
|
65981
|
+
? ts.every(type.types, isObjectTypeWithInferableIndex)
|
|
65982
|
+
: !!(type.symbol
|
|
65983
|
+
&& (type.symbol.flags & (4096 /* ObjectLiteral */ | 2048 /* TypeLiteral */ | 384 /* Enum */ | 512 /* ValueModule */)) !== 0
|
|
65984
|
+
&& !(type.symbol.flags & 32 /* Class */)
|
|
65985
|
+
&& !typeHasCallOrConstructSignatures(type)) || !!(ts.getObjectFlags(type) & 1024 /* ReverseMapped */ && isObjectTypeWithInferableIndex(type.source));
|
|
65833
65986
|
}
|
|
65834
65987
|
function createSymbolWithType(source, type) {
|
|
65835
65988
|
var symbol = createSymbol(source.flags, source.escapedName, ts.getCheckFlags(source) & 8 /* Readonly */);
|
|
@@ -67437,7 +67590,8 @@ var ts;
|
|
|
67437
67590
|
return access.kind === 205 /* PropertyAccessExpression */ ? access.name.escapedText :
|
|
67438
67591
|
access.kind === 206 /* ElementAccessExpression */ && ts.isStringOrNumericLiteralLike(access.argumentExpression) ? ts.escapeLeadingUnderscores(access.argumentExpression.text) :
|
|
67439
67592
|
access.kind === 202 /* BindingElement */ && (propertyName = getDestructuringPropertyName(access)) ? ts.escapeLeadingUnderscores(propertyName) :
|
|
67440
|
-
|
|
67593
|
+
access.kind === 163 /* Parameter */ ? ("" + access.parent.parameters.indexOf(access)) :
|
|
67594
|
+
undefined;
|
|
67441
67595
|
}
|
|
67442
67596
|
function containsMatchingReference(source, target) {
|
|
67443
67597
|
while (ts.isAccessExpression(source)) {
|
|
@@ -68777,13 +68931,14 @@ var ts;
|
|
|
68777
68931
|
return result;
|
|
68778
68932
|
}
|
|
68779
68933
|
function getCandidateDiscriminantPropertyAccess(expr) {
|
|
68780
|
-
if (ts.isBindingPattern(reference)) {
|
|
68781
|
-
// When the reference is a binding pattern, we are narrowing a pesudo-reference in
|
|
68782
|
-
// An identifier for a destructuring variable declared in the same binding pattern
|
|
68934
|
+
if (ts.isBindingPattern(reference) || ts.isFunctionExpressionOrArrowFunction(reference)) {
|
|
68935
|
+
// When the reference is a binding pattern or function or arrow expression, we are narrowing a pesudo-reference in
|
|
68936
|
+
// getNarrowedTypeOfSymbol. An identifier for a destructuring variable declared in the same binding pattern or
|
|
68937
|
+
// parameter declared in the same parameter list is a candidate.
|
|
68783
68938
|
if (ts.isIdentifier(expr)) {
|
|
68784
68939
|
var symbol = getResolvedSymbol(expr);
|
|
68785
68940
|
var declaration = symbol.valueDeclaration;
|
|
68786
|
-
if (declaration && ts.isBindingElement(declaration) &&
|
|
68941
|
+
if (declaration && (ts.isBindingElement(declaration) || ts.isParameter(declaration)) && reference === declaration.parent && !declaration.initializer && !declaration.dotDotDotToken) {
|
|
68787
68942
|
return declaration;
|
|
68788
68943
|
}
|
|
68789
68944
|
}
|
|
@@ -69585,42 +69740,78 @@ var ts;
|
|
|
69585
69740
|
}
|
|
69586
69741
|
}
|
|
69587
69742
|
function getNarrowedTypeOfSymbol(symbol, location) {
|
|
69588
|
-
// If we have a non-rest binding element with no initializer declared as a const variable or a const-like
|
|
69589
|
-
// parameter (a parameter for which there are no assignments in the function body), and if the parent type
|
|
69590
|
-
// for the destructuring is a union type, one or more of the binding elements may represent discriminant
|
|
69591
|
-
// properties, and we want the effects of conditional checks on such discriminants to affect the types of
|
|
69592
|
-
// other binding elements from the same destructuring. Consider:
|
|
69593
|
-
//
|
|
69594
|
-
// type Action =
|
|
69595
|
-
// | { kind: 'A', payload: number }
|
|
69596
|
-
// | { kind: 'B', payload: string };
|
|
69597
|
-
//
|
|
69598
|
-
// function f1({ kind, payload }: Action) {
|
|
69599
|
-
// if (kind === 'A') {
|
|
69600
|
-
// payload.toFixed();
|
|
69601
|
-
// }
|
|
69602
|
-
// if (kind === 'B') {
|
|
69603
|
-
// payload.toUpperCase();
|
|
69604
|
-
// }
|
|
69605
|
-
// }
|
|
69606
|
-
//
|
|
69607
|
-
// Above, we want the conditional checks on 'kind' to affect the type of 'payload'. To facilitate this, we use
|
|
69608
|
-
// the binding pattern AST instance for '{ kind, payload }' as a pseudo-reference and narrow this reference
|
|
69609
|
-
// as if it occurred in the specified location. We then recompute the narrowed binding element type by
|
|
69610
|
-
// destructuring from the narrowed parent type.
|
|
69611
69743
|
var declaration = symbol.valueDeclaration;
|
|
69612
|
-
if (declaration
|
|
69613
|
-
|
|
69614
|
-
|
|
69615
|
-
|
|
69616
|
-
|
|
69617
|
-
|
|
69618
|
-
|
|
69619
|
-
|
|
69620
|
-
|
|
69621
|
-
|
|
69622
|
-
|
|
69623
|
-
|
|
69744
|
+
if (declaration) {
|
|
69745
|
+
// If we have a non-rest binding element with no initializer declared as a const variable or a const-like
|
|
69746
|
+
// parameter (a parameter for which there are no assignments in the function body), and if the parent type
|
|
69747
|
+
// for the destructuring is a union type, one or more of the binding elements may represent discriminant
|
|
69748
|
+
// properties, and we want the effects of conditional checks on such discriminants to affect the types of
|
|
69749
|
+
// other binding elements from the same destructuring. Consider:
|
|
69750
|
+
//
|
|
69751
|
+
// type Action =
|
|
69752
|
+
// | { kind: 'A', payload: number }
|
|
69753
|
+
// | { kind: 'B', payload: string };
|
|
69754
|
+
//
|
|
69755
|
+
// function f({ kind, payload }: Action) {
|
|
69756
|
+
// if (kind === 'A') {
|
|
69757
|
+
// payload.toFixed();
|
|
69758
|
+
// }
|
|
69759
|
+
// if (kind === 'B') {
|
|
69760
|
+
// payload.toUpperCase();
|
|
69761
|
+
// }
|
|
69762
|
+
// }
|
|
69763
|
+
//
|
|
69764
|
+
// Above, we want the conditional checks on 'kind' to affect the type of 'payload'. To facilitate this, we use
|
|
69765
|
+
// the binding pattern AST instance for '{ kind, payload }' as a pseudo-reference and narrow this reference
|
|
69766
|
+
// as if it occurred in the specified location. We then recompute the narrowed binding element type by
|
|
69767
|
+
// destructuring from the narrowed parent type.
|
|
69768
|
+
if (ts.isBindingElement(declaration) && !declaration.initializer && !declaration.dotDotDotToken && declaration.parent.elements.length >= 2) {
|
|
69769
|
+
var parent = declaration.parent.parent;
|
|
69770
|
+
if (parent.kind === 253 /* VariableDeclaration */ && ts.getCombinedNodeFlags(declaration) & 2 /* Const */ || parent.kind === 163 /* Parameter */) {
|
|
69771
|
+
var links = getNodeLinks(location);
|
|
69772
|
+
if (!(links.flags & 268435456 /* InCheckIdentifier */)) {
|
|
69773
|
+
links.flags |= 268435456 /* InCheckIdentifier */;
|
|
69774
|
+
var parentType = getTypeForBindingElementParent(parent);
|
|
69775
|
+
links.flags &= ~268435456 /* InCheckIdentifier */;
|
|
69776
|
+
if (parentType && parentType.flags & 1048576 /* Union */ && !(parent.kind === 163 /* Parameter */ && isSymbolAssigned(symbol))) {
|
|
69777
|
+
var pattern = declaration.parent;
|
|
69778
|
+
var narrowedType = getFlowTypeOfReference(pattern, parentType, parentType, /*flowContainer*/ undefined, location.flowNode);
|
|
69779
|
+
return getBindingElementTypeFromParentType(declaration, narrowedType);
|
|
69780
|
+
}
|
|
69781
|
+
}
|
|
69782
|
+
}
|
|
69783
|
+
}
|
|
69784
|
+
// If we have a const-like parameter with no type annotation or initializer, and if the parameter is contextually
|
|
69785
|
+
// typed by a signature with a single rest parameter of a union of tuple types, one or more of the parameters may
|
|
69786
|
+
// represent discriminant tuple elements, and we want the effects of conditional checks on such discriminants to
|
|
69787
|
+
// affect the types of other parameters in the same parameter list. Consider:
|
|
69788
|
+
//
|
|
69789
|
+
// type Action = [kind: 'A', payload: number] | [kind: 'B', payload: string];
|
|
69790
|
+
//
|
|
69791
|
+
// const f: (...args: Action) => void = (kind, payload) => {
|
|
69792
|
+
// if (kind === 'A') {
|
|
69793
|
+
// payload.toFixed();
|
|
69794
|
+
// }
|
|
69795
|
+
// if (kind === 'B') {
|
|
69796
|
+
// payload.toUpperCase();
|
|
69797
|
+
// }
|
|
69798
|
+
// }
|
|
69799
|
+
//
|
|
69800
|
+
// Above, we want the conditional checks on 'kind' to affect the type of 'payload'. To facilitate this, we use
|
|
69801
|
+
// the arrow function AST node for '(kind, payload) => ...' as a pseudo-reference and narrow this reference as
|
|
69802
|
+
// if it occurred in the specified location. We then recompute the narrowed parameter type by indexing into the
|
|
69803
|
+
// narrowed tuple type.
|
|
69804
|
+
if (ts.isParameter(declaration) && !declaration.type && !declaration.initializer && !declaration.dotDotDotToken) {
|
|
69805
|
+
var func = declaration.parent;
|
|
69806
|
+
if (func.parameters.length >= 2 && isContextSensitiveFunctionOrObjectLiteralMethod(func)) {
|
|
69807
|
+
var contextualSignature = getContextualSignature(func);
|
|
69808
|
+
if (contextualSignature && contextualSignature.parameters.length === 1 && signatureHasRestParameter(contextualSignature)) {
|
|
69809
|
+
var restType = getTypeOfSymbol(contextualSignature.parameters[0]);
|
|
69810
|
+
if (restType.flags & 1048576 /* Union */ && everyType(restType, isTupleType) && !isSymbolAssigned(symbol)) {
|
|
69811
|
+
var narrowedType = getFlowTypeOfReference(func, restType, restType, /*flowContainer*/ undefined, location.flowNode);
|
|
69812
|
+
var index = func.parameters.indexOf(declaration) - (ts.getThisParameter(func) ? 1 : 0);
|
|
69813
|
+
return getIndexedAccessType(narrowedType, getNumberLiteralType(index));
|
|
69814
|
+
}
|
|
69624
69815
|
}
|
|
69625
69816
|
}
|
|
69626
69817
|
}
|
|
@@ -70761,7 +70952,7 @@ var ts;
|
|
|
70761
70952
|
}
|
|
70762
70953
|
if (isTupleType(t)) {
|
|
70763
70954
|
var restType = getRestTypeOfTupleType(t);
|
|
70764
|
-
if (restType && isNumericLiteralName(name) && +name >= 0) {
|
|
70955
|
+
if (restType && ts.isNumericLiteralName(name) && +name >= 0) {
|
|
70765
70956
|
return restType;
|
|
70766
70957
|
}
|
|
70767
70958
|
}
|
|
@@ -71402,10 +71593,10 @@ var ts;
|
|
|
71402
71593
|
case 161 /* ComputedPropertyName */:
|
|
71403
71594
|
return isNumericComputedName(name);
|
|
71404
71595
|
case 79 /* Identifier */:
|
|
71405
|
-
return isNumericLiteralName(name.escapedText);
|
|
71596
|
+
return ts.isNumericLiteralName(name.escapedText);
|
|
71406
71597
|
case 8 /* NumericLiteral */:
|
|
71407
71598
|
case 10 /* StringLiteral */:
|
|
71408
|
-
return isNumericLiteralName(name.text);
|
|
71599
|
+
return ts.isNumericLiteralName(name.text);
|
|
71409
71600
|
default:
|
|
71410
71601
|
return false;
|
|
71411
71602
|
}
|
|
@@ -71415,30 +71606,6 @@ var ts;
|
|
|
71415
71606
|
// but this behavior is consistent with checkIndexedAccess
|
|
71416
71607
|
return isTypeAssignableToKind(checkComputedPropertyName(name), 296 /* NumberLike */);
|
|
71417
71608
|
}
|
|
71418
|
-
function isNumericLiteralName(name) {
|
|
71419
|
-
// The intent of numeric names is that
|
|
71420
|
-
// - they are names with text in a numeric form, and that
|
|
71421
|
-
// - setting properties/indexing with them is always equivalent to doing so with the numeric literal 'numLit',
|
|
71422
|
-
// acquired by applying the abstract 'ToNumber' operation on the name's text.
|
|
71423
|
-
//
|
|
71424
|
-
// The subtlety is in the latter portion, as we cannot reliably say that anything that looks like a numeric literal is a numeric name.
|
|
71425
|
-
// In fact, it is the case that the text of the name must be equal to 'ToString(numLit)' for this to hold.
|
|
71426
|
-
//
|
|
71427
|
-
// Consider the property name '"0xF00D"'. When one indexes with '0xF00D', they are actually indexing with the value of 'ToString(0xF00D)'
|
|
71428
|
-
// according to the ECMAScript specification, so it is actually as if the user indexed with the string '"61453"'.
|
|
71429
|
-
// Thus, the text of all numeric literals equivalent to '61543' such as '0xF00D', '0xf00D', '0170015', etc. are not valid numeric names
|
|
71430
|
-
// because their 'ToString' representation is not equal to their original text.
|
|
71431
|
-
// This is motivated by ECMA-262 sections 9.3.1, 9.8.1, 11.1.5, and 11.2.1.
|
|
71432
|
-
//
|
|
71433
|
-
// Here, we test whether 'ToString(ToNumber(name))' is exactly equal to 'name'.
|
|
71434
|
-
// The '+' prefix operator is equivalent here to applying the abstract ToNumber operation.
|
|
71435
|
-
// Applying the 'toString()' method on a number gives us the abstract ToString operation on a number.
|
|
71436
|
-
//
|
|
71437
|
-
// Note that this accepts the values 'Infinity', '-Infinity', and 'NaN', and that this is intentional.
|
|
71438
|
-
// This is desired behavior, because when indexing with them as numeric entities, you are indexing
|
|
71439
|
-
// with the strings '"Infinity"', '"-Infinity"', and '"NaN"' respectively.
|
|
71440
|
-
return (+name).toString() === name;
|
|
71441
|
-
}
|
|
71442
71609
|
function checkComputedPropertyName(node) {
|
|
71443
71610
|
var links = getNodeLinks(node.expression);
|
|
71444
71611
|
if (!links.resolvedType) {
|
|
@@ -71474,7 +71641,7 @@ var ts;
|
|
|
71474
71641
|
function isSymbolWithNumericName(symbol) {
|
|
71475
71642
|
var _a;
|
|
71476
71643
|
var firstDecl = (_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a[0];
|
|
71477
|
-
return isNumericLiteralName(symbol.escapedName) || (firstDecl && ts.isNamedDeclaration(firstDecl) && isNumericName(firstDecl.name));
|
|
71644
|
+
return ts.isNumericLiteralName(symbol.escapedName) || (firstDecl && ts.isNamedDeclaration(firstDecl) && isNumericName(firstDecl.name));
|
|
71478
71645
|
}
|
|
71479
71646
|
function isSymbolWithSymbolName(symbol) {
|
|
71480
71647
|
var _a;
|
|
@@ -72697,6 +72864,9 @@ var ts;
|
|
|
72697
72864
|
if (compilerOptions.noPropertyAccessFromIndexSignature && ts.isPropertyAccessExpression(node)) {
|
|
72698
72865
|
error(right, ts.Diagnostics.Property_0_comes_from_an_index_signature_so_it_must_be_accessed_with_0, ts.unescapeLeadingUnderscores(right.escapedText));
|
|
72699
72866
|
}
|
|
72867
|
+
if (indexInfo.declaration && ts.getCombinedNodeFlags(indexInfo.declaration) & 134217728 /* Deprecated */) {
|
|
72868
|
+
addDeprecatedSuggestion(right, [indexInfo.declaration], right.escapedText);
|
|
72869
|
+
}
|
|
72700
72870
|
}
|
|
72701
72871
|
else {
|
|
72702
72872
|
if (prop.declarations && getDeclarationNodeFlagsFromSymbol(prop) & 134217728 /* Deprecated */ && isUncalledFunctionReference(node, prop)) {
|
|
@@ -82412,7 +82582,7 @@ var ts;
|
|
|
82412
82582
|
}
|
|
82413
82583
|
else {
|
|
82414
82584
|
var text = ts.getTextOfPropertyName(member.name);
|
|
82415
|
-
if (isNumericLiteralName(text) && !ts.isInfinityOrNaNString(text)) {
|
|
82585
|
+
if (ts.isNumericLiteralName(text) && !ts.isInfinityOrNaNString(text)) {
|
|
82416
82586
|
error(member.name, ts.Diagnostics.An_enum_member_cannot_have_a_numeric_name);
|
|
82417
82587
|
}
|
|
82418
82588
|
}
|
|
@@ -83206,9 +83376,9 @@ var ts;
|
|
|
83206
83376
|
}
|
|
83207
83377
|
}
|
|
83208
83378
|
// Checks for export * conflicts
|
|
83209
|
-
var
|
|
83210
|
-
if (
|
|
83211
|
-
|
|
83379
|
+
var exports_3 = getExportsOfModule(moduleSymbol);
|
|
83380
|
+
if (exports_3) {
|
|
83381
|
+
exports_3.forEach(function (_a, id) {
|
|
83212
83382
|
var declarations = _a.declarations, flags = _a.flags;
|
|
83213
83383
|
if (id === "__export") {
|
|
83214
83384
|
return;
|
|
@@ -92764,6 +92934,11 @@ var ts;
|
|
|
92764
92934
|
ts.setSourceMapRange(statement, ts.moveRangePastModifiers(property));
|
|
92765
92935
|
ts.setCommentRange(statement, property);
|
|
92766
92936
|
ts.setOriginalNode(statement, property);
|
|
92937
|
+
// `setOriginalNode` *copies* the `emitNode` from `property`, so now both
|
|
92938
|
+
// `statement` and `expression` have a copy of the synthesized comments.
|
|
92939
|
+
// Drop the comments from expression to avoid printing them twice.
|
|
92940
|
+
ts.setSyntheticLeadingComments(expression, undefined);
|
|
92941
|
+
ts.setSyntheticTrailingComments(expression, undefined);
|
|
92767
92942
|
statements.push(statement);
|
|
92768
92943
|
}
|
|
92769
92944
|
}
|
|
@@ -109018,7 +109193,7 @@ var ts;
|
|
|
109018
109193
|
emitPlaceholder(hint, node, snippet);
|
|
109019
109194
|
break;
|
|
109020
109195
|
case 0 /* TabStop */:
|
|
109021
|
-
emitTabStop(snippet);
|
|
109196
|
+
emitTabStop(hint, node, snippet);
|
|
109022
109197
|
break;
|
|
109023
109198
|
}
|
|
109024
109199
|
}
|
|
@@ -109028,7 +109203,10 @@ var ts;
|
|
|
109028
109203
|
nonEscapingWrite("}"); // `}`
|
|
109029
109204
|
// `${2:...}`
|
|
109030
109205
|
}
|
|
109031
|
-
function emitTabStop(snippet) {
|
|
109206
|
+
function emitTabStop(hint, node, snippet) {
|
|
109207
|
+
// A tab stop should only be attached to an empty node, i.e. a node that doesn't emit any text.
|
|
109208
|
+
ts.Debug.assert(node.kind === 235 /* EmptyStatement */, "A tab stop cannot be attached to a node of kind " + ts.Debug.formatSyntaxKind(node.kind) + ".");
|
|
109209
|
+
ts.Debug.assert(hint !== 5 /* EmbeddedStatement */, "A tab stop cannot be attached to an embedded statement.");
|
|
109032
109210
|
nonEscapingWrite("$" + snippet.order);
|
|
109033
109211
|
}
|
|
109034
109212
|
//
|
|
@@ -119101,28 +119279,37 @@ var ts;
|
|
|
119101
119279
|
useCaseSensitiveFileNames: (_a = host.useCaseSensitiveFileNames) === null || _a === void 0 ? void 0 : _a.call(host),
|
|
119102
119280
|
};
|
|
119103
119281
|
}
|
|
119104
|
-
|
|
119105
|
-
|
|
119282
|
+
// `importingSourceFile` and `importingSourceFileName`? Why not just use `importingSourceFile.path`?
|
|
119283
|
+
// Because when this is called by the file renamer, `importingSourceFile` is the file being renamed,
|
|
119284
|
+
// while `importingSourceFileName` its *new* name. We need a source file just to get its
|
|
119285
|
+
// `impliedNodeFormat` and to detect certain preferences from existing import module specifiers.
|
|
119286
|
+
function updateModuleSpecifier(compilerOptions, importingSourceFile, importingSourceFileName, toFileName, host, oldImportSpecifier) {
|
|
119287
|
+
var res = getModuleSpecifierWorker(compilerOptions, importingSourceFile, importingSourceFileName, toFileName, host, getPreferencesForUpdate(compilerOptions, oldImportSpecifier, importingSourceFileName, host), {});
|
|
119106
119288
|
if (res === oldImportSpecifier)
|
|
119107
119289
|
return undefined;
|
|
119108
119290
|
return res;
|
|
119109
119291
|
}
|
|
119110
119292
|
moduleSpecifiers_1.updateModuleSpecifier = updateModuleSpecifier;
|
|
119111
|
-
//
|
|
119293
|
+
// `importingSourceFile` and `importingSourceFileName`? Why not just use `importingSourceFile.path`?
|
|
119294
|
+
// Because when this is called by the declaration emitter, `importingSourceFile` is the implementation
|
|
119295
|
+
// file, but `importingSourceFileName` and `toFileName` refer to declaration files (the former to the
|
|
119296
|
+
// one currently being produced; the latter to the one being imported). We need an implementation file
|
|
119297
|
+
// just to get its `impliedNodeFormat` and to detect certain preferences from existing import module
|
|
119298
|
+
// specifiers.
|
|
119112
119299
|
function getModuleSpecifier(compilerOptions, importingSourceFile, importingSourceFileName, toFileName, host) {
|
|
119113
|
-
return getModuleSpecifierWorker(compilerOptions, importingSourceFileName, toFileName, host, getPreferences(host, {}, compilerOptions, importingSourceFile), {});
|
|
119300
|
+
return getModuleSpecifierWorker(compilerOptions, importingSourceFile, importingSourceFileName, toFileName, host, getPreferences(host, {}, compilerOptions, importingSourceFile), {});
|
|
119114
119301
|
}
|
|
119115
119302
|
moduleSpecifiers_1.getModuleSpecifier = getModuleSpecifier;
|
|
119116
|
-
function getNodeModulesPackageName(compilerOptions,
|
|
119117
|
-
var info = getInfo(
|
|
119118
|
-
var modulePaths = getAllModulePaths(
|
|
119119
|
-
return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, host, compilerOptions, /*packageNameOnly*/ true); });
|
|
119303
|
+
function getNodeModulesPackageName(compilerOptions, importingSourceFile, nodeModulesFileName, host, preferences) {
|
|
119304
|
+
var info = getInfo(importingSourceFile.path, host);
|
|
119305
|
+
var modulePaths = getAllModulePaths(importingSourceFile.path, nodeModulesFileName, host, preferences);
|
|
119306
|
+
return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, /*packageNameOnly*/ true); });
|
|
119120
119307
|
}
|
|
119121
119308
|
moduleSpecifiers_1.getNodeModulesPackageName = getNodeModulesPackageName;
|
|
119122
|
-
function getModuleSpecifierWorker(compilerOptions, importingSourceFileName, toFileName, host, preferences, userPreferences) {
|
|
119309
|
+
function getModuleSpecifierWorker(compilerOptions, importingSourceFile, importingSourceFileName, toFileName, host, preferences, userPreferences) {
|
|
119123
119310
|
var info = getInfo(importingSourceFileName, host);
|
|
119124
119311
|
var modulePaths = getAllModulePaths(importingSourceFileName, toFileName, host, userPreferences);
|
|
119125
|
-
return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, host, compilerOptions); }) ||
|
|
119312
|
+
return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions); }) ||
|
|
119126
119313
|
getLocalModuleSpecifier(toFileName, info, compilerOptions, host, preferences);
|
|
119127
119314
|
}
|
|
119128
119315
|
function tryGetModuleSpecifiersFromCache(moduleSymbol, importingSourceFile, host, userPreferences) {
|
|
@@ -119189,7 +119376,7 @@ var ts;
|
|
|
119189
119376
|
var relativeSpecifiers;
|
|
119190
119377
|
for (var _i = 0, modulePaths_1 = modulePaths; _i < modulePaths_1.length; _i++) {
|
|
119191
119378
|
var modulePath = modulePaths_1[_i];
|
|
119192
|
-
var specifier = tryGetModuleNameAsNodeModule(modulePath, info, host, compilerOptions);
|
|
119379
|
+
var specifier = tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions);
|
|
119193
119380
|
nodeModulesSpecifiers = ts.append(nodeModulesSpecifiers, specifier);
|
|
119194
119381
|
if (specifier && modulePath.isRedirect) {
|
|
119195
119382
|
// If we got a specifier for a redirect, it was a bare package specifier (e.g. "@foo/bar",
|
|
@@ -119581,7 +119768,7 @@ var ts;
|
|
|
119581
119768
|
? removeExtensionAndIndexPostFix(relativePath, ending, compilerOptions)
|
|
119582
119769
|
: ts.removeFileExtension(relativePath);
|
|
119583
119770
|
}
|
|
119584
|
-
function tryGetModuleNameAsNodeModule(_a, _b, host, options, packageNameOnly) {
|
|
119771
|
+
function tryGetModuleNameAsNodeModule(_a, _b, importingSourceFile, host, options, packageNameOnly) {
|
|
119585
119772
|
var path = _a.path, isRedirect = _a.isRedirect;
|
|
119586
119773
|
var getCanonicalFileName = _b.getCanonicalFileName, sourceDirectory = _b.sourceDirectory;
|
|
119587
119774
|
if (!host.fileExists || !host.readFile) {
|
|
@@ -119644,11 +119831,19 @@ var ts;
|
|
|
119644
119831
|
var moduleFileToTry = path;
|
|
119645
119832
|
if (host.fileExists(packageJsonPath)) {
|
|
119646
119833
|
var packageJsonContent = JSON.parse(host.readFile(packageJsonPath));
|
|
119647
|
-
// TODO: Inject `require` or `import` condition based on the intended import mode
|
|
119648
119834
|
if (ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Node12 || ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.NodeNext) {
|
|
119649
|
-
|
|
119835
|
+
// `conditions` *could* be made to go against `importingSourceFile.impliedNodeFormat` if something wanted to generate
|
|
119836
|
+
// an ImportEqualsDeclaration in an ESM-implied file or an ImportCall in a CJS-implied file. But since this function is
|
|
119837
|
+
// usually called to conjure an import out of thin air, we don't have an existing usage to call `getModeForUsageAtIndex`
|
|
119838
|
+
// with, so for now we just stick with the mode of the file.
|
|
119839
|
+
var conditions = ["node", importingSourceFile.impliedNodeFormat === ts.ModuleKind.ESNext ? "import" : "require", "types"];
|
|
119840
|
+
var fromExports = packageJsonContent.exports && typeof packageJsonContent.name === "string"
|
|
119841
|
+
? tryGetModuleNameFromExports(options, path, packageRootPath, ts.getPackageNameFromTypesPackageName(packageJsonContent.name), packageJsonContent.exports, conditions)
|
|
119842
|
+
: undefined;
|
|
119650
119843
|
if (fromExports) {
|
|
119651
|
-
var withJsExtension = !ts.hasTSFileExtension(fromExports.moduleFileToTry)
|
|
119844
|
+
var withJsExtension = !ts.hasTSFileExtension(fromExports.moduleFileToTry)
|
|
119845
|
+
? fromExports
|
|
119846
|
+
: { moduleFileToTry: ts.removeFileExtension(fromExports.moduleFileToTry) + tryGetJSExtensionForFile(fromExports.moduleFileToTry, options) };
|
|
119652
119847
|
return __assign(__assign({}, withJsExtension), { verbatimFromExports: true });
|
|
119653
119848
|
}
|
|
119654
119849
|
if (packageJsonContent.exports) {
|
|
@@ -119754,8 +119949,8 @@ var ts;
|
|
|
119754
119949
|
}
|
|
119755
119950
|
function getPathRelativeToRootDirs(path, rootDirs, getCanonicalFileName) {
|
|
119756
119951
|
return ts.firstDefined(rootDirs, function (rootDir) {
|
|
119757
|
-
var relativePath = getRelativePathIfInDirectory(path, rootDir, getCanonicalFileName);
|
|
119758
|
-
return isPathRelativeToParent(relativePath) ? undefined : relativePath;
|
|
119952
|
+
var relativePath = getRelativePathIfInDirectory(path, rootDir, getCanonicalFileName);
|
|
119953
|
+
return relativePath !== undefined && isPathRelativeToParent(relativePath) ? undefined : relativePath;
|
|
119759
119954
|
});
|
|
119760
119955
|
}
|
|
119761
119956
|
function removeExtensionAndIndexPostFix(fileName, ending, options) {
|
|
@@ -119874,7 +120069,7 @@ var ts;
|
|
|
119874
120069
|
}
|
|
119875
120070
|
ts.getLocaleTimeString = getLocaleTimeString;
|
|
119876
120071
|
/**
|
|
119877
|
-
* Create a function that reports watch status by writing to the system and handles the
|
|
120072
|
+
* Create a function that reports watch status by writing to the system and handles the formatting of the diagnostic
|
|
119878
120073
|
*/
|
|
119879
120074
|
function createWatchStatusReporter(system, pretty) {
|
|
119880
120075
|
return pretty ?
|
|
@@ -119935,7 +120130,7 @@ var ts;
|
|
|
119935
120130
|
ts.Diagnostics.Found_0_errors_Watching_for_file_changes;
|
|
119936
120131
|
}
|
|
119937
120132
|
ts.getWatchErrorSummaryDiagnosticMessage = getWatchErrorSummaryDiagnosticMessage;
|
|
119938
|
-
function getErrorSummaryText(errorCount, filesInError, newLine) {
|
|
120133
|
+
function getErrorSummaryText(errorCount, filesInError, newLine, host) {
|
|
119939
120134
|
if (errorCount === 0)
|
|
119940
120135
|
return "";
|
|
119941
120136
|
var nonNilFiles = filesInError.filter(function (fileInError) { return fileInError !== undefined; });
|
|
@@ -119950,10 +120145,10 @@ var ts;
|
|
|
119950
120145
|
distinctFileNamesWithLines.length === 1 ?
|
|
119951
120146
|
ts.Diagnostics.Found_0_errors_in_1_file :
|
|
119952
120147
|
ts.Diagnostics.Found_0_errors_in_1_files, errorCount, distinctFileNamesWithLines.length);
|
|
119953
|
-
return "" + newLine + ts.flattenDiagnosticMessageText(d.messageText, newLine) + newLine + newLine + (errorCount > 1 ? createTabularErrorsDisplay(nonNilFiles) : "");
|
|
120148
|
+
return "" + newLine + ts.flattenDiagnosticMessageText(d.messageText, newLine) + newLine + newLine + (errorCount > 1 ? createTabularErrorsDisplay(nonNilFiles, host) : "");
|
|
119954
120149
|
}
|
|
119955
120150
|
ts.getErrorSummaryText = getErrorSummaryText;
|
|
119956
|
-
function createTabularErrorsDisplay(filesInError) {
|
|
120151
|
+
function createTabularErrorsDisplay(filesInError, host) {
|
|
119957
120152
|
var distinctFiles = filesInError.filter(function (value, index, self) { return index === self.findIndex(function (file) { return (file === null || file === void 0 ? void 0 : file.fileName) === (value === null || value === void 0 ? void 0 : value.fileName); }); });
|
|
119958
120153
|
if (distinctFiles.length === 0)
|
|
119959
120154
|
return "";
|
|
@@ -119972,7 +120167,8 @@ var ts;
|
|
|
119972
120167
|
var leftPadding = errorCountDigitsLength < leftPaddingGoal ?
|
|
119973
120168
|
" ".repeat(leftPaddingGoal - errorCountDigitsLength)
|
|
119974
120169
|
: "";
|
|
119975
|
-
|
|
120170
|
+
var relativePath = ts.getRelativePathFromDirectory(host.getCurrentDirectory(), file.fileName, /* ignoreCase */ false);
|
|
120171
|
+
tabularData += "" + leftPadding + errorCount + " " + relativePath + ":" + file.line + "\n";
|
|
119976
120172
|
});
|
|
119977
120173
|
return tabularData;
|
|
119978
120174
|
}
|
|
@@ -120390,7 +120586,7 @@ var ts;
|
|
|
120390
120586
|
var system = input.system || ts.sys;
|
|
120391
120587
|
var host = input.host || (input.host = ts.createIncrementalCompilerHost(input.options, system));
|
|
120392
120588
|
var builderProgram = ts.createIncrementalProgram(input);
|
|
120393
|
-
var exitStatus = emitFilesAndReportErrorsAndGetExitStatus(builderProgram, input.reportDiagnostic || createDiagnosticReporter(system), function (s) { return host.trace && host.trace(s); }, input.reportErrorSummary || input.options.pretty ? function (errorCount, filesInError) { return system.write(getErrorSummaryText(errorCount, filesInError, system.newLine)); } : undefined);
|
|
120589
|
+
var exitStatus = emitFilesAndReportErrorsAndGetExitStatus(builderProgram, input.reportDiagnostic || createDiagnosticReporter(system), function (s) { return host.trace && host.trace(s); }, input.reportErrorSummary || input.options.pretty ? function (errorCount, filesInError) { return system.write(getErrorSummaryText(errorCount, filesInError, system.newLine, host)); } : undefined);
|
|
120394
120590
|
if (input.afterProgramEmitAndDiagnostics)
|
|
120395
120591
|
input.afterProgramEmitAndDiagnostics(builderProgram);
|
|
120396
120592
|
return exitStatus;
|
|
@@ -125966,7 +126162,7 @@ var ts;
|
|
|
125966
126162
|
if (!ts.stringContains(importedFileName, "node_modules")) {
|
|
125967
126163
|
return undefined;
|
|
125968
126164
|
}
|
|
125969
|
-
var specifier = ts.moduleSpecifiers.getNodeModulesPackageName(host.getCompilationSettings(), fromFile
|
|
126165
|
+
var specifier = ts.moduleSpecifiers.getNodeModulesPackageName(host.getCompilationSettings(), fromFile, importedFileName, moduleSpecifierResolutionHost, preferences);
|
|
125970
126166
|
if (!specifier) {
|
|
125971
126167
|
return undefined;
|
|
125972
126168
|
}
|
|
@@ -126166,6 +126362,16 @@ var ts;
|
|
|
126166
126362
|
: ts.getLocaleSpecificMessage(diag);
|
|
126167
126363
|
}
|
|
126168
126364
|
ts.diagnosticToString = diagnosticToString;
|
|
126365
|
+
/**
|
|
126366
|
+
* Get format code settings for a code writing context (e.g. when formatting text changes or completions code).
|
|
126367
|
+
*/
|
|
126368
|
+
function getFormatCodeSettingsForWriting(_a, sourceFile) {
|
|
126369
|
+
var options = _a.options;
|
|
126370
|
+
var shouldAutoDetectSemicolonPreference = !options.semicolons || options.semicolons === ts.SemicolonPreference.Ignore;
|
|
126371
|
+
var shouldRemoveSemicolons = options.semicolons === ts.SemicolonPreference.Remove || shouldAutoDetectSemicolonPreference && !probablyUsesSemicolons(sourceFile);
|
|
126372
|
+
return __assign(__assign({}, options), { semicolons: shouldRemoveSemicolons ? ts.SemicolonPreference.Remove : ts.SemicolonPreference.Ignore });
|
|
126373
|
+
}
|
|
126374
|
+
ts.getFormatCodeSettingsForWriting = getFormatCodeSettingsForWriting;
|
|
126169
126375
|
// #endregion
|
|
126170
126376
|
})(ts || (ts = {}));
|
|
126171
126377
|
/*@internal*/
|
|
@@ -127789,7 +127995,8 @@ var ts;
|
|
|
127789
127995
|
return convertPathCompletions(completion.paths);
|
|
127790
127996
|
case 1 /* Properties */: {
|
|
127791
127997
|
var entries = ts.createSortedArray();
|
|
127792
|
-
Completions.getCompletionEntriesFromSymbols(completion.symbols, entries, contextToken, contextToken, sourceFile, sourceFile, host, program, 99 /* ESNext */, log, 4 /* String */, preferences, options
|
|
127998
|
+
Completions.getCompletionEntriesFromSymbols(completion.symbols, entries, contextToken, contextToken, sourceFile, sourceFile, host, program, 99 /* ESNext */, log, 4 /* String */, preferences, options,
|
|
127999
|
+
/*formatContext*/ undefined); // Target will not be used, so arbitrary
|
|
127793
128000
|
return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: completion.hasIndexSignature, optionalReplacementSpan: optionalReplacementSpan, entries: entries };
|
|
127794
128001
|
}
|
|
127795
128002
|
case 2 /* Types */: {
|
|
@@ -128610,7 +128817,7 @@ var ts;
|
|
|
128610
128817
|
return result;
|
|
128611
128818
|
}
|
|
128612
128819
|
}
|
|
128613
|
-
function getCompletionsAtPosition(host, program, log, sourceFile, position, preferences, triggerCharacter, completionKind, cancellationToken) {
|
|
128820
|
+
function getCompletionsAtPosition(host, program, log, sourceFile, position, preferences, triggerCharacter, completionKind, cancellationToken, formatContext) {
|
|
128614
128821
|
var _a;
|
|
128615
128822
|
var previousToken = getRelevantTokens(position, sourceFile).previousToken;
|
|
128616
128823
|
if (triggerCharacter && !ts.isInString(sourceFile, position, previousToken) && !isValidTrigger(sourceFile, triggerCharacter, previousToken, position)) {
|
|
@@ -128650,7 +128857,7 @@ var ts;
|
|
|
128650
128857
|
}
|
|
128651
128858
|
switch (completionData.kind) {
|
|
128652
128859
|
case 0 /* Data */:
|
|
128653
|
-
var response = completionInfoFromData(sourceFile, host, program, compilerOptions, log, completionData, preferences);
|
|
128860
|
+
var response = completionInfoFromData(sourceFile, host, program, compilerOptions, log, completionData, preferences, formatContext);
|
|
128654
128861
|
if (response === null || response === void 0 ? void 0 : response.isIncomplete) {
|
|
128655
128862
|
incompleteCompletionsCache === null || incompleteCompletionsCache === void 0 ? void 0 : incompleteCompletionsCache.set(response);
|
|
128656
128863
|
}
|
|
@@ -128770,7 +128977,7 @@ var ts;
|
|
|
128770
128977
|
// StringLiteralLike locations are handled separately in stringCompletions.ts
|
|
128771
128978
|
return (location === null || location === void 0 ? void 0 : location.kind) === 79 /* Identifier */ ? ts.createTextSpanFromNode(location) : undefined;
|
|
128772
128979
|
}
|
|
128773
|
-
function completionInfoFromData(sourceFile, host, program, compilerOptions, log, completionData, preferences) {
|
|
128980
|
+
function completionInfoFromData(sourceFile, host, program, compilerOptions, log, completionData, preferences, formatContext) {
|
|
128774
128981
|
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;
|
|
128775
128982
|
// Verify if the file is JSX language variant
|
|
128776
128983
|
if (ts.getLanguageVariant(sourceFile.scriptKind) === 1 /* JSX */) {
|
|
@@ -128782,7 +128989,7 @@ var ts;
|
|
|
128782
128989
|
var entries = ts.createSortedArray();
|
|
128783
128990
|
if (isUncheckedFile(sourceFile, compilerOptions)) {
|
|
128784
128991
|
var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries,
|
|
128785
|
-
/*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap);
|
|
128992
|
+
/*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, formatContext, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap);
|
|
128786
128993
|
getJSCompletionEntries(sourceFile, location.pos, uniqueNames, ts.getEmitScriptTarget(compilerOptions), entries); // TODO: GH#18217
|
|
128787
128994
|
}
|
|
128788
128995
|
else {
|
|
@@ -128790,7 +128997,7 @@ var ts;
|
|
|
128790
128997
|
return undefined;
|
|
128791
128998
|
}
|
|
128792
128999
|
getCompletionEntriesFromSymbols(symbols, entries,
|
|
128793
|
-
/*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap);
|
|
129000
|
+
/*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, formatContext, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap);
|
|
128794
129001
|
}
|
|
128795
129002
|
if (keywordFilters !== 0 /* None */) {
|
|
128796
129003
|
var entryNames = new ts.Set(entries.map(function (e) { return e.name; }));
|
|
@@ -128896,7 +129103,7 @@ var ts;
|
|
|
128896
129103
|
function createCompletionEntryForLiteral(sourceFile, preferences, literal) {
|
|
128897
129104
|
return { name: completionNameForLiteral(sourceFile, preferences, literal), kind: "string" /* string */, kindModifiers: "" /* none */, sortText: SortText.LocationPriority };
|
|
128898
129105
|
}
|
|
128899
|
-
function createCompletionEntry(symbol, sortText, replacementToken, contextToken, location, sourceFile, host, program, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importCompletionNode, useSemicolons, options, preferences, completionKind) {
|
|
129106
|
+
function createCompletionEntry(symbol, sortText, replacementToken, contextToken, location, sourceFile, host, program, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importCompletionNode, useSemicolons, options, preferences, completionKind, formatContext) {
|
|
128900
129107
|
var _a, _b;
|
|
128901
129108
|
var insertText;
|
|
128902
129109
|
var replacementSpan = ts.getReplacementSpanForContextToken(replacementToken);
|
|
@@ -128961,7 +129168,7 @@ var ts;
|
|
|
128961
129168
|
completionKind === 3 /* MemberLike */ &&
|
|
128962
129169
|
isClassLikeMemberCompletion(symbol, location)) {
|
|
128963
129170
|
var importAdder = void 0;
|
|
128964
|
-
(_b = getEntryForMemberCompletion(host, program, options, preferences, name, symbol, location, contextToken), insertText = _b.insertText, isSnippet = _b.isSnippet, importAdder = _b.importAdder);
|
|
129171
|
+
(_b = getEntryForMemberCompletion(host, program, options, preferences, name, symbol, location, contextToken, formatContext), insertText = _b.insertText, isSnippet = _b.isSnippet, importAdder = _b.importAdder);
|
|
128965
129172
|
if (importAdder === null || importAdder === void 0 ? void 0 : importAdder.hasFixes()) {
|
|
128966
129173
|
hasAction = true;
|
|
128967
129174
|
source = CompletionSource.ClassMemberSnippet;
|
|
@@ -129060,7 +129267,7 @@ var ts;
|
|
|
129060
129267
|
ts.isSyntaxList(location) &&
|
|
129061
129268
|
ts.isClassLike(location.parent)));
|
|
129062
129269
|
}
|
|
129063
|
-
function getEntryForMemberCompletion(host, program, options, preferences, name, symbol, location, contextToken) {
|
|
129270
|
+
function getEntryForMemberCompletion(host, program, options, preferences, name, symbol, location, contextToken, formatContext) {
|
|
129064
129271
|
var classLikeDeclaration = ts.findAncestor(location, ts.isClassLike);
|
|
129065
129272
|
if (!classLikeDeclaration) {
|
|
129066
129273
|
return { insertText: name };
|
|
@@ -129077,15 +129284,16 @@ var ts;
|
|
|
129077
129284
|
newLine: ts.getNewLineKind(ts.getNewLineCharacter(options, ts.maybeBind(host, host.getNewLine))),
|
|
129078
129285
|
});
|
|
129079
129286
|
var importAdder = ts.codefix.createImportAdder(sourceFile, program, preferences, host);
|
|
129287
|
+
// Create empty body for possible method implementation.
|
|
129080
129288
|
var body;
|
|
129081
129289
|
if (preferences.includeCompletionsWithSnippetText) {
|
|
129082
129290
|
isSnippet = true;
|
|
129083
129291
|
// We are adding a tabstop (i.e. `$0`) in the body of the suggested member,
|
|
129084
129292
|
// if it has one, so that the cursor ends up in the body once the completion is inserted.
|
|
129085
129293
|
// Note: this assumes we won't have more than one body in the completion nodes, which should be the case.
|
|
129086
|
-
var
|
|
129087
|
-
ts.
|
|
129088
|
-
|
|
129294
|
+
var emptyStmt = ts.factory.createEmptyStatement();
|
|
129295
|
+
body = ts.factory.createBlock([emptyStmt], /* multiline */ true);
|
|
129296
|
+
ts.setSnippetElement(emptyStmt, { kind: 0 /* TabStop */, order: 0 });
|
|
129089
129297
|
}
|
|
129090
129298
|
else {
|
|
129091
129299
|
body = ts.factory.createBlock([], /* multiline */ true);
|
|
@@ -129131,7 +129339,27 @@ var ts;
|
|
|
129131
129339
|
completionNodes.push(node);
|
|
129132
129340
|
}, body, 2 /* Property */, isAbstract);
|
|
129133
129341
|
if (completionNodes.length) {
|
|
129134
|
-
|
|
129342
|
+
// If we have access to formatting settings, we print the nodes using the emitter,
|
|
129343
|
+
// and then format the printed text.
|
|
129344
|
+
if (formatContext) {
|
|
129345
|
+
var syntheticFile_1 = {
|
|
129346
|
+
text: printer.printSnippetList(1 /* MultiLine */ | 131072 /* NoTrailingNewLine */, ts.factory.createNodeArray(completionNodes), sourceFile),
|
|
129347
|
+
getLineAndCharacterOfPosition: function (pos) {
|
|
129348
|
+
return ts.getLineAndCharacterOfPosition(this, pos);
|
|
129349
|
+
},
|
|
129350
|
+
};
|
|
129351
|
+
var formatOptions_1 = ts.getFormatCodeSettingsForWriting(formatContext, sourceFile);
|
|
129352
|
+
var changes = ts.flatMap(completionNodes, function (node) {
|
|
129353
|
+
var nodeWithPos = ts.textChanges.assignPositionsToNode(node);
|
|
129354
|
+
return ts.formatting.formatNodeGivenIndentation(nodeWithPos, syntheticFile_1, sourceFile.languageVariant,
|
|
129355
|
+
/* indentation */ 0,
|
|
129356
|
+
/* delta */ 0, __assign(__assign({}, formatContext), { options: formatOptions_1 }));
|
|
129357
|
+
});
|
|
129358
|
+
insertText = ts.textChanges.applyChanges(syntheticFile_1.text, changes);
|
|
129359
|
+
}
|
|
129360
|
+
else { // Otherwise, just use emitter to print the new nodes.
|
|
129361
|
+
insertText = printer.printSnippetList(1 /* MultiLine */ | 131072 /* NoTrailingNewLine */, ts.factory.createNodeArray(completionNodes), sourceFile);
|
|
129362
|
+
}
|
|
129135
129363
|
}
|
|
129136
129364
|
return { insertText: insertText, isSnippet: isSnippet, importAdder: importAdder };
|
|
129137
129365
|
}
|
|
@@ -129175,8 +129403,8 @@ var ts;
|
|
|
129175
129403
|
return undefined;
|
|
129176
129404
|
}
|
|
129177
129405
|
function createSnippetPrinter(printerOptions) {
|
|
129178
|
-
var
|
|
129179
|
-
var
|
|
129406
|
+
var baseWriter = ts.textChanges.createWriter(ts.getNewLineCharacter(printerOptions));
|
|
129407
|
+
var printer = ts.createPrinter(printerOptions, baseWriter);
|
|
129180
129408
|
var writer = __assign(__assign({}, baseWriter), { write: function (s) { return baseWriter.write(ts.escapeSnippetText(s)); }, nonEscapingWrite: baseWriter.write, writeLiteral: function (s) { return baseWriter.writeLiteral(ts.escapeSnippetText(s)); }, writeStringLiteral: function (s) { return baseWriter.writeStringLiteral(ts.escapeSnippetText(s)); }, writeSymbol: function (s, symbol) { return baseWriter.writeSymbol(ts.escapeSnippetText(s), symbol); }, writeParameter: function (s) { return baseWriter.writeParameter(ts.escapeSnippetText(s)); }, writeComment: function (s) { return baseWriter.writeComment(ts.escapeSnippetText(s)); }, writeProperty: function (s) { return baseWriter.writeProperty(ts.escapeSnippetText(s)); } });
|
|
129181
129409
|
return {
|
|
129182
129410
|
printSnippetList: printSnippetList,
|
|
@@ -129281,7 +129509,7 @@ var ts;
|
|
|
129281
129509
|
return CompletionSource.ThisProperty;
|
|
129282
129510
|
}
|
|
129283
129511
|
}
|
|
129284
|
-
function getCompletionEntriesFromSymbols(symbols, entries, replacementToken, contextToken, location, sourceFile, host, program, target, log, kind, preferences, compilerOptions, isTypeOnlyLocation, propertyAccessToConvert, jsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap) {
|
|
129512
|
+
function getCompletionEntriesFromSymbols(symbols, entries, replacementToken, contextToken, location, sourceFile, host, program, target, log, kind, preferences, compilerOptions, formatContext, isTypeOnlyLocation, propertyAccessToConvert, jsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap) {
|
|
129285
129513
|
var _a;
|
|
129286
129514
|
var start = ts.timestamp();
|
|
129287
129515
|
var variableDeclaration = getVariableDeclaration(location);
|
|
@@ -129302,7 +129530,7 @@ var ts;
|
|
|
129302
129530
|
var name = info.name, needsConvertPropertyAccess = info.needsConvertPropertyAccess;
|
|
129303
129531
|
var sortTextId = (_a = symbolToSortTextIdMap === null || symbolToSortTextIdMap === void 0 ? void 0 : symbolToSortTextIdMap[ts.getSymbolId(symbol)]) !== null && _a !== void 0 ? _a : 11 /* LocationPriority */;
|
|
129304
129532
|
var sortText = (isDeprecated(symbol, typeChecker) ? 8 /* DeprecatedOffset */ + sortTextId : sortTextId).toString();
|
|
129305
|
-
var entry = createCompletionEntry(symbol, sortText, replacementToken, contextToken, location, sourceFile, host, program, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importCompletionNode, useSemicolons, compilerOptions, preferences, kind);
|
|
129533
|
+
var entry = createCompletionEntry(symbol, sortText, replacementToken, contextToken, location, sourceFile, host, program, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importCompletionNode, useSemicolons, compilerOptions, preferences, kind, formatContext);
|
|
129306
129534
|
if (!entry) {
|
|
129307
129535
|
continue;
|
|
129308
129536
|
}
|
|
@@ -129498,7 +129726,7 @@ var ts;
|
|
|
129498
129726
|
}
|
|
129499
129727
|
}
|
|
129500
129728
|
if (source === CompletionSource.ClassMemberSnippet) {
|
|
129501
|
-
var importAdder = getEntryForMemberCompletion(host, program, compilerOptions, preferences, name, symbol, location, contextToken).importAdder;
|
|
129729
|
+
var importAdder = getEntryForMemberCompletion(host, program, compilerOptions, preferences, name, symbol, location, contextToken, formatContext).importAdder;
|
|
129502
129730
|
if (importAdder) {
|
|
129503
129731
|
var changes = ts.textChanges.ChangeTracker.with({ host: host, formatContext: formatContext, preferences: preferences }, importAdder.writeFixes);
|
|
129504
129732
|
return {
|
|
@@ -135580,7 +135808,7 @@ var ts;
|
|
|
135580
135808
|
: getSourceFileToImport(importedModuleSymbol, importLiteral, sourceFile, program, host, oldToNew);
|
|
135581
135809
|
// Need an update if the imported file moved, or the importing file moved and was using a relative path.
|
|
135582
135810
|
return toImport !== undefined && (toImport.updated || (importingSourceFileMoved && ts.pathIsRelative(importLiteral.text)))
|
|
135583
|
-
? ts.moduleSpecifiers.updateModuleSpecifier(program.getCompilerOptions(), getCanonicalFileName(newImportFromPath), toImport.newFileName, ts.createModuleSpecifierResolutionHost(program, host), importLiteral.text)
|
|
135811
|
+
? ts.moduleSpecifiers.updateModuleSpecifier(program.getCompilerOptions(), sourceFile, getCanonicalFileName(newImportFromPath), toImport.newFileName, ts.createModuleSpecifierResolutionHost(program, host), importLiteral.text)
|
|
135584
135812
|
: undefined;
|
|
135585
135813
|
});
|
|
135586
135814
|
};
|
|
@@ -137225,6 +137453,9 @@ var ts;
|
|
|
137225
137453
|
// We use 1 NavNode to represent 'A.B.C', but there are multiple source nodes.
|
|
137226
137454
|
// Only merge module nodes that have the same chain. Don't merge 'A.B.C' with 'A'!
|
|
137227
137455
|
function areSameModule(a, b) {
|
|
137456
|
+
if (!a.body || !b.body) {
|
|
137457
|
+
return a.body === b.body;
|
|
137458
|
+
}
|
|
137228
137459
|
return a.body.kind === b.body.kind && (a.body.kind !== 260 /* ModuleDeclaration */ || areSameModule(a.body, b.body));
|
|
137229
137460
|
}
|
|
137230
137461
|
/** Merge source into target. Source should be thrown away after this is called. */
|
|
@@ -145382,19 +145613,13 @@ var ts;
|
|
|
145382
145613
|
+ ((!options.suffix || ts.endsWith(noIndent, options.suffix))
|
|
145383
145614
|
? "" : options.suffix);
|
|
145384
145615
|
}
|
|
145385
|
-
function getFormatCodeSettingsForWriting(_a, sourceFile) {
|
|
145386
|
-
var options = _a.options;
|
|
145387
|
-
var shouldAutoDetectSemicolonPreference = !options.semicolons || options.semicolons === ts.SemicolonPreference.Ignore;
|
|
145388
|
-
var shouldRemoveSemicolons = options.semicolons === ts.SemicolonPreference.Remove || shouldAutoDetectSemicolonPreference && !ts.probablyUsesSemicolons(sourceFile);
|
|
145389
|
-
return __assign(__assign({}, options), { semicolons: shouldRemoveSemicolons ? ts.SemicolonPreference.Remove : ts.SemicolonPreference.Ignore });
|
|
145390
|
-
}
|
|
145391
145616
|
/** Note: this may mutate `nodeIn`. */
|
|
145392
145617
|
function getFormattedTextOfNode(nodeIn, sourceFile, pos, _a, newLineCharacter, formatContext, validate) {
|
|
145393
145618
|
var indentation = _a.indentation, prefix = _a.prefix, delta = _a.delta;
|
|
145394
145619
|
var _b = getNonformattedText(nodeIn, sourceFile, newLineCharacter), node = _b.node, text = _b.text;
|
|
145395
145620
|
if (validate)
|
|
145396
145621
|
validate(node, text);
|
|
145397
|
-
var formatOptions = getFormatCodeSettingsForWriting(formatContext, sourceFile);
|
|
145622
|
+
var formatOptions = ts.getFormatCodeSettingsForWriting(formatContext, sourceFile);
|
|
145398
145623
|
var initialIndentation = indentation !== undefined
|
|
145399
145624
|
? indentation
|
|
145400
145625
|
: ts.formatting.SmartIndenter.getIndentation(pos, sourceFile, formatOptions, prefix === newLineCharacter || ts.getLineStartPositionForPosition(pos, sourceFile) === pos);
|
|
@@ -145442,6 +145667,7 @@ var ts;
|
|
|
145442
145667
|
ts.setTextRangePosEnd(newNode, getPos(node), getEnd(node));
|
|
145443
145668
|
return newNode;
|
|
145444
145669
|
}
|
|
145670
|
+
textChanges_3.assignPositionsToNode = assignPositionsToNode;
|
|
145445
145671
|
function assignPositionsToNodeArray(nodes, visitor, test, start, count) {
|
|
145446
145672
|
var visited = ts.visitNodes(nodes, visitor, test, start, count);
|
|
145447
145673
|
if (!visited) {
|
|
@@ -145612,6 +145838,7 @@ var ts;
|
|
|
145612
145838
|
clear: clear
|
|
145613
145839
|
};
|
|
145614
145840
|
}
|
|
145841
|
+
textChanges_3.createWriter = createWriter;
|
|
145615
145842
|
function getInsertionPositionAtSourceFileTop(sourceFile) {
|
|
145616
145843
|
var lastPrologue;
|
|
145617
145844
|
for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) {
|
|
@@ -150347,7 +150574,8 @@ var ts;
|
|
|
150347
150574
|
return { kind: 3 /* ObjectLiteral */, token: token, properties: properties, indentation: undefined, parentDeclaration: parent.initializer };
|
|
150348
150575
|
}
|
|
150349
150576
|
if (ts.isIdentifier(token) && ts.isJsxOpeningLikeElement(token.parent)) {
|
|
150350
|
-
var
|
|
150577
|
+
var target = ts.getEmitScriptTarget(program.getCompilerOptions());
|
|
150578
|
+
var attributes = getUnmatchedAttributes(checker, target, token.parent);
|
|
150351
150579
|
if (!ts.length(attributes))
|
|
150352
150580
|
return undefined;
|
|
150353
150581
|
return { kind: 4 /* JsxAttributes */, token: token, attributes: attributes, parentDeclaration: token.parent };
|
|
@@ -150582,8 +150810,12 @@ var ts;
|
|
|
150582
150810
|
var jsxAttributesNode = info.parentDeclaration.attributes;
|
|
150583
150811
|
var hasSpreadAttribute = ts.some(jsxAttributesNode.properties, ts.isJsxSpreadAttribute);
|
|
150584
150812
|
var attrs = ts.map(info.attributes, function (attr) {
|
|
150585
|
-
var value =
|
|
150586
|
-
|
|
150813
|
+
var value = tryGetValueFromType(context, checker, importAdder, quotePreference, checker.getTypeOfSymbol(attr));
|
|
150814
|
+
var name = ts.factory.createIdentifier(attr.name);
|
|
150815
|
+
var jsxAttribute = ts.factory.createJsxAttribute(name, ts.factory.createJsxExpression(/*dotDotDotToken*/ undefined, value));
|
|
150816
|
+
// formattingScanner requires the Identifier to have a context for scanning attributes with "-" (data-foo).
|
|
150817
|
+
ts.setParent(name, jsxAttribute);
|
|
150818
|
+
return jsxAttribute;
|
|
150587
150819
|
});
|
|
150588
150820
|
var jsxAttributes = ts.factory.createJsxAttributes(hasSpreadAttribute ? __spreadArray(__spreadArray([], attrs, true), jsxAttributesNode.properties, true) : __spreadArray(__spreadArray([], jsxAttributesNode.properties, true), attrs, true));
|
|
150589
150821
|
var options = { prefix: jsxAttributesNode.pos === jsxAttributesNode.end ? " " : undefined };
|
|
@@ -150592,10 +150824,11 @@ var ts;
|
|
|
150592
150824
|
function addObjectLiteralProperties(changes, context, info) {
|
|
150593
150825
|
var importAdder = codefix.createImportAdder(context.sourceFile, context.program, context.preferences, context.host);
|
|
150594
150826
|
var quotePreference = ts.getQuotePreference(context.sourceFile, context.preferences);
|
|
150827
|
+
var target = ts.getEmitScriptTarget(context.program.getCompilerOptions());
|
|
150595
150828
|
var checker = context.program.getTypeChecker();
|
|
150596
150829
|
var props = ts.map(info.properties, function (prop) {
|
|
150597
|
-
var initializer =
|
|
150598
|
-
return ts.factory.createPropertyAssignment(prop.name, initializer);
|
|
150830
|
+
var initializer = tryGetValueFromType(context, checker, importAdder, quotePreference, checker.getTypeOfSymbol(prop));
|
|
150831
|
+
return ts.factory.createPropertyAssignment(ts.createPropertyNameNodeForIdentifierOrLiteral(prop.name, target, quotePreference === 0 /* Single */), initializer);
|
|
150599
150832
|
});
|
|
150600
150833
|
var options = {
|
|
150601
150834
|
leadingTriviaOption: ts.textChanges.LeadingTriviaOption.Exclude,
|
|
@@ -150682,7 +150915,7 @@ var ts;
|
|
|
150682
150915
|
return (type.flags & 524288 /* Object */) &&
|
|
150683
150916
|
((ts.getObjectFlags(type) & 128 /* ObjectLiteral */) || (type.symbol && ts.tryCast(ts.singleOrUndefined(type.symbol.declarations), ts.isTypeLiteralNode)));
|
|
150684
150917
|
}
|
|
150685
|
-
function getUnmatchedAttributes(checker, source) {
|
|
150918
|
+
function getUnmatchedAttributes(checker, target, source) {
|
|
150686
150919
|
var attrsType = checker.getContextualType(source.attributes);
|
|
150687
150920
|
if (attrsType === undefined)
|
|
150688
150921
|
return ts.emptyArray;
|
|
@@ -150704,7 +150937,7 @@ var ts;
|
|
|
150704
150937
|
}
|
|
150705
150938
|
}
|
|
150706
150939
|
return ts.filter(targetProps, function (targetProp) {
|
|
150707
|
-
return !((targetProp.flags & 16777216 /* Optional */ || ts.getCheckFlags(targetProp) & 48 /* Partial */) || seenNames.has(targetProp.escapedName));
|
|
150940
|
+
return ts.isIdentifierText(targetProp.name, target, 1 /* JSX */) && !((targetProp.flags & 16777216 /* Optional */ || ts.getCheckFlags(targetProp) & 48 /* Partial */) || seenNames.has(targetProp.escapedName));
|
|
150708
150941
|
});
|
|
150709
150942
|
}
|
|
150710
150943
|
})(codefix = ts.codefix || (ts.codefix = {}));
|
|
@@ -154437,7 +154670,7 @@ var ts;
|
|
|
154437
154670
|
defaultToNamedAction.kind,
|
|
154438
154671
|
namedToDefaultAction.kind
|
|
154439
154672
|
],
|
|
154440
|
-
getAvailableActions: function (context) {
|
|
154673
|
+
getAvailableActions: function getRefactorActionsToConvertBetweenNamedAndDefaultExports(context) {
|
|
154441
154674
|
var info = getInfo(context, context.triggerReason === "invoked");
|
|
154442
154675
|
if (!info)
|
|
154443
154676
|
return ts.emptyArray;
|
|
@@ -154455,7 +154688,7 @@ var ts;
|
|
|
154455
154688
|
}
|
|
154456
154689
|
return ts.emptyArray;
|
|
154457
154690
|
},
|
|
154458
|
-
getEditsForAction: function (context, actionName) {
|
|
154691
|
+
getEditsForAction: function getRefactorEditsToConvertBetweenNamedAndDefaultExports(context, actionName) {
|
|
154459
154692
|
ts.Debug.assert(actionName === defaultToNamedAction.name || actionName === namedToDefaultAction.name, "Unexpected action name");
|
|
154460
154693
|
var info = getInfo(context);
|
|
154461
154694
|
ts.Debug.assert(info && !refactor.isRefactorErrorInfo(info), "Expected applicable refactor info");
|
|
@@ -154683,7 +154916,7 @@ var ts;
|
|
|
154683
154916
|
namespaceToNamedAction.kind,
|
|
154684
154917
|
namedToNamespaceAction.kind
|
|
154685
154918
|
],
|
|
154686
|
-
getAvailableActions: function (context) {
|
|
154919
|
+
getAvailableActions: function getRefactorActionsToConvertBetweenNamedAndNamespacedImports(context) {
|
|
154687
154920
|
var info = getImportToConvert(context, context.triggerReason === "invoked");
|
|
154688
154921
|
if (!info)
|
|
154689
154922
|
return ts.emptyArray;
|
|
@@ -154702,7 +154935,7 @@ var ts;
|
|
|
154702
154935
|
}
|
|
154703
154936
|
return ts.emptyArray;
|
|
154704
154937
|
},
|
|
154705
|
-
getEditsForAction: function (context, actionName) {
|
|
154938
|
+
getEditsForAction: function getRefactorEditsToConvertBetweenNamedAndNamespacedImports(context, actionName) {
|
|
154706
154939
|
ts.Debug.assert(actionName === namespaceToNamedAction.name || actionName === namedToNamespaceAction.name, "Unexpected action name");
|
|
154707
154940
|
var info = getImportToConvert(context);
|
|
154708
154941
|
ts.Debug.assert(info && !refactor.isRefactorErrorInfo(info), "Expected applicable refactor info");
|
|
@@ -154868,10 +155101,10 @@ var ts;
|
|
|
154868
155101
|
};
|
|
154869
155102
|
refactor.registerRefactor(refactorName, {
|
|
154870
155103
|
kinds: [toOptionalChainAction.kind],
|
|
154871
|
-
|
|
154872
|
-
|
|
155104
|
+
getEditsForAction: getRefactorEditsToConvertToOptionalChain,
|
|
155105
|
+
getAvailableActions: getRefactorActionsToConvertToOptionalChain,
|
|
154873
155106
|
});
|
|
154874
|
-
function
|
|
155107
|
+
function getRefactorActionsToConvertToOptionalChain(context) {
|
|
154875
155108
|
var info = getInfo(context, context.triggerReason === "invoked");
|
|
154876
155109
|
if (!info)
|
|
154877
155110
|
return ts.emptyArray;
|
|
@@ -154891,7 +155124,7 @@ var ts;
|
|
|
154891
155124
|
}
|
|
154892
155125
|
return ts.emptyArray;
|
|
154893
155126
|
}
|
|
154894
|
-
function
|
|
155127
|
+
function getRefactorEditsToConvertToOptionalChain(context, actionName) {
|
|
154895
155128
|
var info = getInfo(context);
|
|
154896
155129
|
ts.Debug.assert(info && !refactor.isRefactorErrorInfo(info), "Expected applicable refactor info");
|
|
154897
155130
|
var edits = ts.textChanges.ChangeTracker.with(context, function (t) {
|
|
@@ -155134,10 +155367,10 @@ var ts;
|
|
|
155134
155367
|
};
|
|
155135
155368
|
refactor.registerRefactor(refactorName, {
|
|
155136
155369
|
kinds: [functionOverloadAction.kind],
|
|
155137
|
-
getEditsForAction:
|
|
155138
|
-
getAvailableActions:
|
|
155370
|
+
getEditsForAction: getRefactorEditsToConvertOverloadsToOneSignature,
|
|
155371
|
+
getAvailableActions: getRefactorActionsToConvertOverloadsToOneSignature
|
|
155139
155372
|
});
|
|
155140
|
-
function
|
|
155373
|
+
function getRefactorActionsToConvertOverloadsToOneSignature(context) {
|
|
155141
155374
|
var file = context.file, startPosition = context.startPosition, program = context.program;
|
|
155142
155375
|
var info = getConvertableOverloadListAtPosition(file, startPosition, program);
|
|
155143
155376
|
if (!info)
|
|
@@ -155148,7 +155381,7 @@ var ts;
|
|
|
155148
155381
|
actions: [functionOverloadAction]
|
|
155149
155382
|
}];
|
|
155150
155383
|
}
|
|
155151
|
-
function
|
|
155384
|
+
function getRefactorEditsToConvertOverloadsToOneSignature(context) {
|
|
155152
155385
|
var file = context.file, startPosition = context.startPosition, program = context.program;
|
|
155153
155386
|
var signatureDecls = getConvertableOverloadListAtPosition(file, startPosition, program);
|
|
155154
155387
|
if (!signatureDecls)
|
|
@@ -155304,14 +155537,14 @@ var ts;
|
|
|
155304
155537
|
extractConstantAction.kind,
|
|
155305
155538
|
extractFunctionAction.kind
|
|
155306
155539
|
],
|
|
155307
|
-
|
|
155308
|
-
|
|
155540
|
+
getEditsForAction: getRefactorEditsToExtractSymbol,
|
|
155541
|
+
getAvailableActions: getRefactorActionsToExtractSymbol,
|
|
155309
155542
|
});
|
|
155310
155543
|
/**
|
|
155311
155544
|
* Compute the associated code actions
|
|
155312
155545
|
* Exported for tests.
|
|
155313
155546
|
*/
|
|
155314
|
-
function
|
|
155547
|
+
function getRefactorActionsToExtractSymbol(context) {
|
|
155315
155548
|
var requestedRefactor = context.kind;
|
|
155316
155549
|
var rangeToExtract = getRangeToExtract(context.file, ts.getRefactorContextSpan(context), context.triggerReason === "invoked");
|
|
155317
155550
|
var targetRange = rangeToExtract.targetRange;
|
|
@@ -155440,9 +155673,9 @@ var ts;
|
|
|
155440
155673
|
return error;
|
|
155441
155674
|
}
|
|
155442
155675
|
}
|
|
155443
|
-
extractSymbol.
|
|
155676
|
+
extractSymbol.getRefactorActionsToExtractSymbol = getRefactorActionsToExtractSymbol;
|
|
155444
155677
|
/* Exported for tests */
|
|
155445
|
-
function
|
|
155678
|
+
function getRefactorEditsToExtractSymbol(context, actionName) {
|
|
155446
155679
|
var rangeToExtract = getRangeToExtract(context.file, ts.getRefactorContextSpan(context));
|
|
155447
155680
|
var targetRange = rangeToExtract.targetRange; // TODO:GH#18217
|
|
155448
155681
|
var parsedFunctionIndexMatch = /^function_scope_(\d+)$/.exec(actionName);
|
|
@@ -155459,7 +155692,7 @@ var ts;
|
|
|
155459
155692
|
}
|
|
155460
155693
|
ts.Debug.fail("Unrecognized action name");
|
|
155461
155694
|
}
|
|
155462
|
-
extractSymbol.
|
|
155695
|
+
extractSymbol.getRefactorEditsToExtractSymbol = getRefactorEditsToExtractSymbol;
|
|
155463
155696
|
// Move these into diagnostic messages if they become user-facing
|
|
155464
155697
|
var Messages;
|
|
155465
155698
|
(function (Messages) {
|
|
@@ -157010,7 +157243,7 @@ var ts;
|
|
|
157010
157243
|
extractToInterfaceAction.kind,
|
|
157011
157244
|
extractToTypeDefAction.kind
|
|
157012
157245
|
],
|
|
157013
|
-
getAvailableActions: function (context) {
|
|
157246
|
+
getAvailableActions: function getRefactorActionsToExtractType(context) {
|
|
157014
157247
|
var info = getRangeToExtract(context, context.triggerReason === "invoked");
|
|
157015
157248
|
if (!info)
|
|
157016
157249
|
return ts.emptyArray;
|
|
@@ -157035,7 +157268,7 @@ var ts;
|
|
|
157035
157268
|
}
|
|
157036
157269
|
return ts.emptyArray;
|
|
157037
157270
|
},
|
|
157038
|
-
getEditsForAction: function (context, actionName) {
|
|
157271
|
+
getEditsForAction: function getRefactorEditsToExtractType(context, actionName) {
|
|
157039
157272
|
var file = context.file;
|
|
157040
157273
|
var info = getRangeToExtract(context);
|
|
157041
157274
|
ts.Debug.assert(info && !refactor.isRefactorErrorInfo(info), "Expected to find a range to extract");
|
|
@@ -157203,7 +157436,7 @@ var ts;
|
|
|
157203
157436
|
};
|
|
157204
157437
|
refactor.registerRefactor(actionName, {
|
|
157205
157438
|
kinds: [generateGetSetAction.kind],
|
|
157206
|
-
getEditsForAction: function (context, actionName) {
|
|
157439
|
+
getEditsForAction: function getRefactorActionsToGenerateGetAndSetAccessors(context, actionName) {
|
|
157207
157440
|
if (!context.endPosition)
|
|
157208
157441
|
return undefined;
|
|
157209
157442
|
var info = ts.codefix.getAccessorConvertiblePropertyAtPosition(context.file, context.program, context.startPosition, context.endPosition);
|
|
@@ -157282,7 +157515,7 @@ var ts;
|
|
|
157282
157515
|
};
|
|
157283
157516
|
refactor.registerRefactor(refactorName, {
|
|
157284
157517
|
kinds: [moveToNewFileAction.kind],
|
|
157285
|
-
getAvailableActions: function (context) {
|
|
157518
|
+
getAvailableActions: function getRefactorActionsToMoveToNewFile(context) {
|
|
157286
157519
|
var statements = getStatementsToMove(context);
|
|
157287
157520
|
if (context.preferences.allowTextChangesInNewFiles && statements) {
|
|
157288
157521
|
return [{ name: refactorName, description: description, actions: [moveToNewFileAction] }];
|
|
@@ -157293,7 +157526,7 @@ var ts;
|
|
|
157293
157526
|
}
|
|
157294
157527
|
return ts.emptyArray;
|
|
157295
157528
|
},
|
|
157296
|
-
getEditsForAction: function (context, actionName) {
|
|
157529
|
+
getEditsForAction: function getRefactorEditsToMoveToNewFile(context, actionName) {
|
|
157297
157530
|
ts.Debug.assert(actionName === refactorName, "Wrong refactor invoked");
|
|
157298
157531
|
var statements = ts.Debug.checkDefined(getStatementsToMove(context));
|
|
157299
157532
|
var edits = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(context.file, context.program, statements, t, context.host, context.preferences); });
|
|
@@ -158024,10 +158257,10 @@ var ts;
|
|
|
158024
158257
|
};
|
|
158025
158258
|
refactor.registerRefactor(refactorName, {
|
|
158026
158259
|
kinds: [removeBracesAction.kind],
|
|
158027
|
-
getEditsForAction:
|
|
158028
|
-
getAvailableActions:
|
|
158260
|
+
getEditsForAction: getRefactorEditsToRemoveFunctionBraces,
|
|
158261
|
+
getAvailableActions: getRefactorActionsToRemoveFunctionBraces
|
|
158029
158262
|
});
|
|
158030
|
-
function
|
|
158263
|
+
function getRefactorActionsToRemoveFunctionBraces(context) {
|
|
158031
158264
|
var file = context.file, startPosition = context.startPosition, triggerReason = context.triggerReason;
|
|
158032
158265
|
var info = getConvertibleArrowFunctionAtPosition(file, startPosition, triggerReason === "invoked");
|
|
158033
158266
|
if (!info)
|
|
@@ -158053,7 +158286,7 @@ var ts;
|
|
|
158053
158286
|
}
|
|
158054
158287
|
return ts.emptyArray;
|
|
158055
158288
|
}
|
|
158056
|
-
function
|
|
158289
|
+
function getRefactorEditsToRemoveFunctionBraces(context, actionName) {
|
|
158057
158290
|
var file = context.file, startPosition = context.startPosition;
|
|
158058
158291
|
var info = getConvertibleArrowFunctionAtPosition(file, startPosition);
|
|
158059
158292
|
ts.Debug.assert(info && !refactor.isRefactorErrorInfo(info), "Expected applicable refactor info");
|
|
@@ -158127,10 +158360,10 @@ var ts;
|
|
|
158127
158360
|
};
|
|
158128
158361
|
refactor.registerRefactor(refactorName, {
|
|
158129
158362
|
kinds: [toDestructuredAction.kind],
|
|
158130
|
-
getEditsForAction:
|
|
158131
|
-
getAvailableActions:
|
|
158363
|
+
getEditsForAction: getRefactorEditsToConvertParametersToDestructuredObject,
|
|
158364
|
+
getAvailableActions: getRefactorActionsToConvertParametersToDestructuredObject
|
|
158132
158365
|
});
|
|
158133
|
-
function
|
|
158366
|
+
function getRefactorActionsToConvertParametersToDestructuredObject(context) {
|
|
158134
158367
|
var file = context.file, startPosition = context.startPosition;
|
|
158135
158368
|
var isJSFile = ts.isSourceFileJS(file);
|
|
158136
158369
|
if (isJSFile)
|
|
@@ -158144,7 +158377,7 @@ var ts;
|
|
|
158144
158377
|
actions: [toDestructuredAction]
|
|
158145
158378
|
}];
|
|
158146
158379
|
}
|
|
158147
|
-
function
|
|
158380
|
+
function getRefactorEditsToConvertParametersToDestructuredObject(context, actionName) {
|
|
158148
158381
|
ts.Debug.assert(actionName === refactorName, "Unexpected action name");
|
|
158149
158382
|
var file = context.file, startPosition = context.startPosition, program = context.program, cancellationToken = context.cancellationToken, host = context.host;
|
|
158150
158383
|
var functionDeclaration = getFunctionDeclarationAtPosition(file, startPosition, program.getTypeChecker());
|
|
@@ -158654,10 +158887,10 @@ var ts;
|
|
|
158654
158887
|
};
|
|
158655
158888
|
refactor.registerRefactor(refactorName, {
|
|
158656
158889
|
kinds: [convertStringAction.kind],
|
|
158657
|
-
getEditsForAction:
|
|
158658
|
-
getAvailableActions:
|
|
158890
|
+
getEditsForAction: getRefactorEditsToConvertToTemplateString,
|
|
158891
|
+
getAvailableActions: getRefactorActionsToConvertToTemplateString
|
|
158659
158892
|
});
|
|
158660
|
-
function
|
|
158893
|
+
function getRefactorActionsToConvertToTemplateString(context) {
|
|
158661
158894
|
var file = context.file, startPosition = context.startPosition;
|
|
158662
158895
|
var node = getNodeOrParentOfParentheses(file, startPosition);
|
|
158663
158896
|
var maybeBinary = getParentBinaryExpression(node);
|
|
@@ -158683,7 +158916,7 @@ var ts;
|
|
|
158683
158916
|
}
|
|
158684
158917
|
return node;
|
|
158685
158918
|
}
|
|
158686
|
-
function
|
|
158919
|
+
function getRefactorEditsToConvertToTemplateString(context, actionName) {
|
|
158687
158920
|
var file = context.file, startPosition = context.startPosition;
|
|
158688
158921
|
var node = getNodeOrParentOfParentheses(file, startPosition);
|
|
158689
158922
|
switch (actionName) {
|
|
@@ -158897,10 +159130,10 @@ var ts;
|
|
|
158897
159130
|
toNamedFunctionAction.kind,
|
|
158898
159131
|
toArrowFunctionAction.kind
|
|
158899
159132
|
],
|
|
158900
|
-
getEditsForAction:
|
|
158901
|
-
getAvailableActions:
|
|
159133
|
+
getEditsForAction: getRefactorEditsToConvertFunctionExpressions,
|
|
159134
|
+
getAvailableActions: getRefactorActionsToConvertFunctionExpressions
|
|
158902
159135
|
});
|
|
158903
|
-
function
|
|
159136
|
+
function getRefactorActionsToConvertFunctionExpressions(context) {
|
|
158904
159137
|
var file = context.file, startPosition = context.startPosition, program = context.program, kind = context.kind;
|
|
158905
159138
|
var info = getFunctionInfo(file, startPosition, program);
|
|
158906
159139
|
if (!info)
|
|
@@ -158944,7 +159177,7 @@ var ts;
|
|
|
158944
159177
|
errors : possibleActions
|
|
158945
159178
|
}];
|
|
158946
159179
|
}
|
|
158947
|
-
function
|
|
159180
|
+
function getRefactorEditsToConvertFunctionExpressions(context, actionName) {
|
|
158948
159181
|
var file = context.file, startPosition = context.startPosition, program = context.program;
|
|
158949
159182
|
var info = getFunctionInfo(file, startPosition, program);
|
|
158950
159183
|
if (!info)
|
|
@@ -159104,10 +159337,10 @@ var ts;
|
|
|
159104
159337
|
};
|
|
159105
159338
|
refactor.registerRefactor(refactorName, {
|
|
159106
159339
|
kinds: [inferReturnTypeAction.kind],
|
|
159107
|
-
getEditsForAction:
|
|
159108
|
-
getAvailableActions:
|
|
159340
|
+
getEditsForAction: getRefactorEditsToInferReturnType,
|
|
159341
|
+
getAvailableActions: getRefactorActionsToInferReturnType
|
|
159109
159342
|
});
|
|
159110
|
-
function
|
|
159343
|
+
function getRefactorEditsToInferReturnType(context) {
|
|
159111
159344
|
var info = getInfo(context);
|
|
159112
159345
|
if (info && !refactor.isRefactorErrorInfo(info)) {
|
|
159113
159346
|
var edits = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(context.file, t, info.declaration, info.returnTypeNode); });
|
|
@@ -159115,7 +159348,7 @@ var ts;
|
|
|
159115
159348
|
}
|
|
159116
159349
|
return undefined;
|
|
159117
159350
|
}
|
|
159118
|
-
function
|
|
159351
|
+
function getRefactorActionsToInferReturnType(context) {
|
|
159119
159352
|
var info = getInfo(context);
|
|
159120
159353
|
if (!info)
|
|
159121
159354
|
return ts.emptyArray;
|
|
@@ -160509,12 +160742,12 @@ var ts;
|
|
|
160509
160742
|
synchronizeHostData();
|
|
160510
160743
|
return __spreadArray(__spreadArray([], program.getOptionsDiagnostics(cancellationToken), true), program.getGlobalDiagnostics(cancellationToken), true);
|
|
160511
160744
|
}
|
|
160512
|
-
function getCompletionsAtPosition(fileName, position, options) {
|
|
160745
|
+
function getCompletionsAtPosition(fileName, position, options, formattingSettings) {
|
|
160513
160746
|
if (options === void 0) { options = ts.emptyOptions; }
|
|
160514
160747
|
// Convert from deprecated options names to new names
|
|
160515
160748
|
var fullPreferences = __assign(__assign({}, ts.identity(options)), { includeCompletionsForModuleExports: options.includeCompletionsForModuleExports || options.includeExternalModuleExports, includeCompletionsWithInsertText: options.includeCompletionsWithInsertText || options.includeInsertTextCompletions });
|
|
160516
160749
|
synchronizeHostData();
|
|
160517
|
-
return ts.Completions.getCompletionsAtPosition(host, program, log, getValidSourceFile(fileName), position, fullPreferences, options.triggerCharacter, options.triggerKind, cancellationToken);
|
|
160750
|
+
return ts.Completions.getCompletionsAtPosition(host, program, log, getValidSourceFile(fileName), position, fullPreferences, options.triggerCharacter, options.triggerKind, cancellationToken, formattingSettings && ts.formatting.getFormatContext(formattingSettings, host));
|
|
160518
160751
|
}
|
|
160519
160752
|
function getCompletionEntryDetails(fileName, position, name, formattingOptions, source, preferences, data) {
|
|
160520
160753
|
if (preferences === void 0) { preferences = ts.emptyOptions; }
|
|
@@ -162677,9 +162910,9 @@ var ts;
|
|
|
162677
162910
|
* to provide at the given source position and providing a member completion
|
|
162678
162911
|
* list if requested.
|
|
162679
162912
|
*/
|
|
162680
|
-
LanguageServiceShimObject.prototype.getCompletionsAtPosition = function (fileName, position, preferences) {
|
|
162913
|
+
LanguageServiceShimObject.prototype.getCompletionsAtPosition = function (fileName, position, preferences, formattingSettings) {
|
|
162681
162914
|
var _this = this;
|
|
162682
|
-
return this.forwardJSONCall("getCompletionsAtPosition('" + fileName + "', " + position + ", " + preferences + ")", function () { return _this.languageService.getCompletionsAtPosition(fileName, position, preferences); });
|
|
162915
|
+
return this.forwardJSONCall("getCompletionsAtPosition('" + fileName + "', " + position + ", " + preferences + ", " + formattingSettings + ")", function () { return _this.languageService.getCompletionsAtPosition(fileName, position, preferences, formattingSettings); });
|
|
162683
162916
|
};
|
|
162684
162917
|
/** Get a string based representation of a completion list entry details */
|
|
162685
162918
|
LanguageServiceShimObject.prototype.getCompletionEntryDetails = function (fileName, position, entryName, formatOptions, source, preferences, data) {
|
|
@@ -163208,14 +163441,8 @@ var ts;
|
|
|
163208
163441
|
var possibleSearchDirs = new ts.Set(fileNames.map(ts.getDirectoryPath));
|
|
163209
163442
|
possibleSearchDirs.add(projectRootPath);
|
|
163210
163443
|
possibleSearchDirs.forEach(function (searchDir) {
|
|
163211
|
-
|
|
163212
|
-
|
|
163213
|
-
var bowerJsonPath = ts.combinePaths(searchDir, "bower.json");
|
|
163214
|
-
getTypingNamesFromJson(bowerJsonPath, filesToWatch);
|
|
163215
|
-
var bowerComponentsPath = ts.combinePaths(searchDir, "bower_components");
|
|
163216
|
-
getTypingNamesFromPackagesFolder(bowerComponentsPath, filesToWatch);
|
|
163217
|
-
var nodeModulesPath = ts.combinePaths(searchDir, "node_modules");
|
|
163218
|
-
getTypingNamesFromPackagesFolder(nodeModulesPath, filesToWatch);
|
|
163444
|
+
getTypingNames(searchDir, "bower.json", "bower_components", filesToWatch);
|
|
163445
|
+
getTypingNames(searchDir, "package.json", "node_modules", filesToWatch);
|
|
163219
163446
|
});
|
|
163220
163447
|
if (!typeAcquisition.disableFilenameBasedTypeAcquisition) {
|
|
163221
163448
|
getTypingNamesFromSourceFileNames(fileNames);
|
|
@@ -163264,16 +163491,100 @@ var ts;
|
|
|
163264
163491
|
ts.forEach(typingNames, addInferredTyping);
|
|
163265
163492
|
}
|
|
163266
163493
|
/**
|
|
163267
|
-
*
|
|
163494
|
+
* Adds inferred typings from manifest/module pairs (think package.json + node_modules)
|
|
163495
|
+
*
|
|
163496
|
+
* @param projectRootPath is the path to the directory where to look for package.json, bower.json and other typing information
|
|
163497
|
+
* @param manifestName is the name of the manifest (package.json or bower.json)
|
|
163498
|
+
* @param modulesDirName is the directory name for modules (node_modules or bower_components). Should be lowercase!
|
|
163499
|
+
* @param filesToWatch are the files to watch for changes. We will push things into this array.
|
|
163268
163500
|
*/
|
|
163269
|
-
function
|
|
163270
|
-
|
|
163501
|
+
function getTypingNames(projectRootPath, manifestName, modulesDirName, filesToWatch) {
|
|
163502
|
+
// First, we check the manifests themselves. They're not
|
|
163503
|
+
// _required_, but they allow us to do some filtering when dealing
|
|
163504
|
+
// with big flat dep directories.
|
|
163505
|
+
var manifestPath = ts.combinePaths(projectRootPath, manifestName);
|
|
163506
|
+
var manifest;
|
|
163507
|
+
var manifestTypingNames;
|
|
163508
|
+
if (host.fileExists(manifestPath)) {
|
|
163509
|
+
filesToWatch.push(manifestPath);
|
|
163510
|
+
manifest = ts.readConfigFile(manifestPath, function (path) { return host.readFile(path); }).config;
|
|
163511
|
+
manifestTypingNames = ts.flatMap([manifest.dependencies, manifest.devDependencies, manifest.optionalDependencies, manifest.peerDependencies], ts.getOwnKeys);
|
|
163512
|
+
addInferredTypings(manifestTypingNames, "Typing names in '" + manifestPath + "' dependencies");
|
|
163513
|
+
}
|
|
163514
|
+
// Now we scan the directories for typing information in
|
|
163515
|
+
// already-installed dependencies (if present). Note that this
|
|
163516
|
+
// step happens regardless of whether a manifest was present,
|
|
163517
|
+
// which is certainly a valid configuration, if an unusual one.
|
|
163518
|
+
var packagesFolderPath = ts.combinePaths(projectRootPath, modulesDirName);
|
|
163519
|
+
filesToWatch.push(packagesFolderPath);
|
|
163520
|
+
if (!host.directoryExists(packagesFolderPath)) {
|
|
163271
163521
|
return;
|
|
163272
163522
|
}
|
|
163273
|
-
|
|
163274
|
-
|
|
163275
|
-
|
|
163276
|
-
|
|
163523
|
+
// There's two cases we have to take into account here:
|
|
163524
|
+
// 1. If manifest is undefined, then we're not using a manifest.
|
|
163525
|
+
// That means that we should scan _all_ dependencies at the top
|
|
163526
|
+
// level of the modulesDir.
|
|
163527
|
+
// 2. If manifest is defined, then we can do some special
|
|
163528
|
+
// filtering to reduce the amount of scanning we need to do.
|
|
163529
|
+
//
|
|
163530
|
+
// Previous versions of this algorithm checked for a `_requiredBy`
|
|
163531
|
+
// field in the package.json, but that field is only present in
|
|
163532
|
+
// `npm@>=3 <7`.
|
|
163533
|
+
// Package names that do **not** provide their own typings, so
|
|
163534
|
+
// we'll look them up.
|
|
163535
|
+
var packageNames = [];
|
|
163536
|
+
var dependencyManifestNames = manifestTypingNames
|
|
163537
|
+
// This is #1 described above.
|
|
163538
|
+
? manifestTypingNames.map(function (typingName) { return ts.combinePaths(packagesFolderPath, typingName, manifestName); })
|
|
163539
|
+
// And #2. Depth = 3 because scoped packages look like `node_modules/@foo/bar/package.json`
|
|
163540
|
+
: host.readDirectory(packagesFolderPath, [".json" /* Json */], /*excludes*/ undefined, /*includes*/ undefined, /*depth*/ 3)
|
|
163541
|
+
.filter(function (manifestPath) {
|
|
163542
|
+
if (ts.getBaseFileName(manifestPath) !== manifestName) {
|
|
163543
|
+
return false;
|
|
163544
|
+
}
|
|
163545
|
+
// It's ok to treat
|
|
163546
|
+
// `node_modules/@foo/bar/package.json` as a manifest,
|
|
163547
|
+
// but not `node_modules/jquery/nested/package.json`.
|
|
163548
|
+
// We only assume depth 3 is ok for formally scoped
|
|
163549
|
+
// packages. So that needs this dance here.
|
|
163550
|
+
var pathComponents = ts.getPathComponents(ts.normalizePath(manifestPath));
|
|
163551
|
+
var isScoped = pathComponents[pathComponents.length - 3][0] === "@";
|
|
163552
|
+
return isScoped && pathComponents[pathComponents.length - 4].toLowerCase() === modulesDirName || // `node_modules/@foo/bar`
|
|
163553
|
+
!isScoped && pathComponents[pathComponents.length - 3].toLowerCase() === modulesDirName; // `node_modules/foo`
|
|
163554
|
+
});
|
|
163555
|
+
if (log)
|
|
163556
|
+
log("Searching for typing names in " + packagesFolderPath + "; all files: " + JSON.stringify(dependencyManifestNames));
|
|
163557
|
+
// Once we have the names of things to look up, we iterate over
|
|
163558
|
+
// and either collect their included typings, or add them to the
|
|
163559
|
+
// list of typings we need to look up separately.
|
|
163560
|
+
for (var _i = 0, dependencyManifestNames_1 = dependencyManifestNames; _i < dependencyManifestNames_1.length; _i++) {
|
|
163561
|
+
var manifestPath_1 = dependencyManifestNames_1[_i];
|
|
163562
|
+
var normalizedFileName = ts.normalizePath(manifestPath_1);
|
|
163563
|
+
var result_1 = ts.readConfigFile(normalizedFileName, function (path) { return host.readFile(path); });
|
|
163564
|
+
var manifest_1 = result_1.config;
|
|
163565
|
+
// If the package has its own d.ts typings, those will take precedence. Otherwise the package name will be used
|
|
163566
|
+
// to download d.ts files from DefinitelyTyped
|
|
163567
|
+
if (!manifest_1.name) {
|
|
163568
|
+
continue;
|
|
163569
|
+
}
|
|
163570
|
+
var ownTypes = manifest_1.types || manifest_1.typings;
|
|
163571
|
+
if (ownTypes) {
|
|
163572
|
+
var absolutePath = ts.getNormalizedAbsolutePath(ownTypes, ts.getDirectoryPath(normalizedFileName));
|
|
163573
|
+
if (host.fileExists(absolutePath)) {
|
|
163574
|
+
if (log)
|
|
163575
|
+
log(" Package '" + manifest_1.name + "' provides its own types.");
|
|
163576
|
+
inferredTypings.set(manifest_1.name, absolutePath);
|
|
163577
|
+
}
|
|
163578
|
+
else {
|
|
163579
|
+
if (log)
|
|
163580
|
+
log(" Package '" + manifest_1.name + "' provides its own types but they are missing.");
|
|
163581
|
+
}
|
|
163582
|
+
}
|
|
163583
|
+
else {
|
|
163584
|
+
packageNames.push(manifest_1.name);
|
|
163585
|
+
}
|
|
163586
|
+
}
|
|
163587
|
+
addInferredTypings(packageNames, " Found package names");
|
|
163277
163588
|
}
|
|
163278
163589
|
/**
|
|
163279
163590
|
* Infer typing names from given file names. For example, the file name "jquery-min.2.3.4.js"
|
|
@@ -163299,55 +163610,6 @@ var ts;
|
|
|
163299
163610
|
addInferredTyping("react");
|
|
163300
163611
|
}
|
|
163301
163612
|
}
|
|
163302
|
-
/**
|
|
163303
|
-
* Infer typing names from packages folder (ex: node_module, bower_components)
|
|
163304
|
-
* @param packagesFolderPath is the path to the packages folder
|
|
163305
|
-
*/
|
|
163306
|
-
function getTypingNamesFromPackagesFolder(packagesFolderPath, filesToWatch) {
|
|
163307
|
-
filesToWatch.push(packagesFolderPath);
|
|
163308
|
-
// Todo: add support for ModuleResolutionHost too
|
|
163309
|
-
if (!host.directoryExists(packagesFolderPath)) {
|
|
163310
|
-
return;
|
|
163311
|
-
}
|
|
163312
|
-
// depth of 2, so we access `node_modules/foo` but not `node_modules/foo/bar`
|
|
163313
|
-
var fileNames = host.readDirectory(packagesFolderPath, [".json" /* Json */], /*excludes*/ undefined, /*includes*/ undefined, /*depth*/ 2);
|
|
163314
|
-
if (log)
|
|
163315
|
-
log("Searching for typing names in " + packagesFolderPath + "; all files: " + JSON.stringify(fileNames));
|
|
163316
|
-
var packageNames = [];
|
|
163317
|
-
for (var _i = 0, fileNames_1 = fileNames; _i < fileNames_1.length; _i++) {
|
|
163318
|
-
var fileName = fileNames_1[_i];
|
|
163319
|
-
var normalizedFileName = ts.normalizePath(fileName);
|
|
163320
|
-
var baseFileName = ts.getBaseFileName(normalizedFileName);
|
|
163321
|
-
if (baseFileName !== "package.json" && baseFileName !== "bower.json") {
|
|
163322
|
-
continue;
|
|
163323
|
-
}
|
|
163324
|
-
var result_1 = ts.readConfigFile(normalizedFileName, function (path) { return host.readFile(path); });
|
|
163325
|
-
var packageJson = result_1.config;
|
|
163326
|
-
// npm 3's package.json contains a "_requiredBy" field
|
|
163327
|
-
// we should include all the top level module names for npm 2, and only module names whose
|
|
163328
|
-
// "_requiredBy" field starts with "#" or equals "/" for npm 3.
|
|
163329
|
-
if (baseFileName === "package.json" && packageJson._requiredBy &&
|
|
163330
|
-
ts.filter(packageJson._requiredBy, function (r) { return r[0] === "#" || r === "/"; }).length === 0) {
|
|
163331
|
-
continue;
|
|
163332
|
-
}
|
|
163333
|
-
// If the package has its own d.ts typings, those will take precedence. Otherwise the package name will be used
|
|
163334
|
-
// to download d.ts files from DefinitelyTyped
|
|
163335
|
-
if (!packageJson.name) {
|
|
163336
|
-
continue;
|
|
163337
|
-
}
|
|
163338
|
-
var ownTypes = packageJson.types || packageJson.typings;
|
|
163339
|
-
if (ownTypes) {
|
|
163340
|
-
var absolutePath = ts.getNormalizedAbsolutePath(ownTypes, ts.getDirectoryPath(normalizedFileName));
|
|
163341
|
-
if (log)
|
|
163342
|
-
log(" Package '" + packageJson.name + "' provides its own types.");
|
|
163343
|
-
inferredTypings.set(packageJson.name, absolutePath);
|
|
163344
|
-
}
|
|
163345
|
-
else {
|
|
163346
|
-
packageNames.push(packageJson.name);
|
|
163347
|
-
}
|
|
163348
|
-
}
|
|
163349
|
-
addInferredTypings(packageNames, " Found package names");
|
|
163350
|
-
}
|
|
163351
163613
|
}
|
|
163352
163614
|
JsTyping.discoverTypings = discoverTypings;
|
|
163353
163615
|
var NameValidationResult;
|
|
@@ -166186,30 +166448,43 @@ var ts;
|
|
|
166186
166448
|
(_b = packageJson.peerDependencies) === null || _b === void 0 ? void 0 : _b.forEach(function (_, dependencyName) { return addDependency(dependencyName); });
|
|
166187
166449
|
}
|
|
166188
166450
|
if (dependencyNames) {
|
|
166189
|
-
var
|
|
166190
|
-
var types = ts.resolveTypeReferenceDirective(name, rootFileName, compilerOptions, moduleResolutionHost);
|
|
166191
|
-
if (types.resolvedTypeReferenceDirective) {
|
|
166192
|
-
return types.resolvedTypeReferenceDirective;
|
|
166193
|
-
}
|
|
166194
|
-
if (compilerOptions.allowJs && compilerOptions.maxNodeModuleJsDepth) {
|
|
166195
|
-
return ts.tryResolveJSModule(name, hostProject.currentDirectory, moduleResolutionHost);
|
|
166196
|
-
}
|
|
166197
|
-
});
|
|
166451
|
+
var dependenciesAdded = 0;
|
|
166198
166452
|
var symlinkCache = hostProject.getSymlinkCache();
|
|
166199
|
-
for (var _c = 0,
|
|
166200
|
-
var
|
|
166201
|
-
|
|
166453
|
+
for (var _c = 0, _d = ts.arrayFrom(dependencyNames.keys()); _c < _d.length; _c++) {
|
|
166454
|
+
var name = _d[_c];
|
|
166455
|
+
// Avoid creating a large project that would significantly slow down time to editor interactivity
|
|
166456
|
+
if (dependencySelection === 2 /* Auto */ && dependenciesAdded > this.maxDependencies) {
|
|
166457
|
+
hostProject.log("Auto-import provider attempted to add more than " + this.maxDependencies + " dependencies.");
|
|
166458
|
+
return ts.emptyArray;
|
|
166459
|
+
}
|
|
166460
|
+
// 1. Try to load from the implementation package. For many dependencies, the
|
|
166461
|
+
// package.json will exist, but the package will not contain any typings,
|
|
166462
|
+
// so `entrypoints` will be undefined. In that case, or if the dependency
|
|
166463
|
+
// is missing altogether, we will move on to trying the @types package (2).
|
|
166464
|
+
var packageJson = ts.resolvePackageNameToPackageJson(name, hostProject.currentDirectory, compilerOptions, moduleResolutionHost, program.getModuleResolutionCache());
|
|
166465
|
+
if (packageJson) {
|
|
166466
|
+
var entrypoints = getRootNamesFromPackageJson(packageJson, program, symlinkCache);
|
|
166467
|
+
if (entrypoints) {
|
|
166468
|
+
rootNames = ts.concatenate(rootNames, entrypoints);
|
|
166469
|
+
dependenciesAdded += entrypoints.length ? 1 : 0;
|
|
166470
|
+
continue;
|
|
166471
|
+
}
|
|
166472
|
+
}
|
|
166473
|
+
// 2. Try to load from the @types package.
|
|
166474
|
+
var typesPackageJson = ts.resolvePackageNameToPackageJson("@types/" + name, hostProject.currentDirectory, compilerOptions, moduleResolutionHost, program.getModuleResolutionCache());
|
|
166475
|
+
if (typesPackageJson) {
|
|
166476
|
+
var entrypoints = getRootNamesFromPackageJson(typesPackageJson, program, symlinkCache);
|
|
166477
|
+
rootNames = ts.concatenate(rootNames, entrypoints);
|
|
166478
|
+
dependenciesAdded += (entrypoints === null || entrypoints === void 0 ? void 0 : entrypoints.length) ? 1 : 0;
|
|
166202
166479
|
continue;
|
|
166203
|
-
var resolvedFileName = resolution.resolvedFileName, originalPath = resolution.originalPath;
|
|
166204
|
-
if (originalPath) {
|
|
166205
|
-
symlinkCache.setSymlinkedDirectoryFromSymlinkedFile(originalPath, resolvedFileName);
|
|
166206
166480
|
}
|
|
166207
|
-
|
|
166208
|
-
|
|
166209
|
-
|
|
166210
|
-
|
|
166211
|
-
|
|
166212
|
-
|
|
166481
|
+
// 3. If the @types package did not exist and the user has settings that
|
|
166482
|
+
// allow processing JS from node_modules, go back to the implementation
|
|
166483
|
+
// package and load the JS.
|
|
166484
|
+
if (packageJson && compilerOptions.allowJs && compilerOptions.maxNodeModuleJsDepth) {
|
|
166485
|
+
var entrypoints = getRootNamesFromPackageJson(packageJson, program, symlinkCache, /*allowJs*/ true);
|
|
166486
|
+
rootNames = ts.concatenate(rootNames, entrypoints);
|
|
166487
|
+
dependenciesAdded += (entrypoints === null || entrypoints === void 0 ? void 0 : entrypoints.length) ? 1 : 0;
|
|
166213
166488
|
}
|
|
166214
166489
|
}
|
|
166215
166490
|
}
|
|
@@ -166219,6 +166494,26 @@ var ts;
|
|
|
166219
166494
|
(dependencyNames || (dependencyNames = new ts.Set())).add(dependency);
|
|
166220
166495
|
}
|
|
166221
166496
|
}
|
|
166497
|
+
function getRootNamesFromPackageJson(packageJson, program, symlinkCache, resolveJs) {
|
|
166498
|
+
var _a;
|
|
166499
|
+
var entrypoints = ts.getEntrypointsFromPackageJsonInfo(packageJson, compilerOptions, moduleResolutionHost, program.getModuleResolutionCache(), resolveJs);
|
|
166500
|
+
if (entrypoints) {
|
|
166501
|
+
var real_1 = (_a = moduleResolutionHost.realpath) === null || _a === void 0 ? void 0 : _a.call(moduleResolutionHost, packageJson.packageDirectory);
|
|
166502
|
+
var isSymlink_1 = real_1 && real_1 !== packageJson.packageDirectory;
|
|
166503
|
+
if (isSymlink_1) {
|
|
166504
|
+
symlinkCache.setSymlinkedDirectory(packageJson.packageDirectory, {
|
|
166505
|
+
real: real_1,
|
|
166506
|
+
realPath: hostProject.toPath(real_1),
|
|
166507
|
+
});
|
|
166508
|
+
}
|
|
166509
|
+
return ts.mapDefined(entrypoints, function (entrypoint) {
|
|
166510
|
+
var resolvedFileName = isSymlink_1 ? entrypoint.replace(packageJson.packageDirectory, real_1) : entrypoint;
|
|
166511
|
+
if (!program.getSourceFile(resolvedFileName) && !(isSymlink_1 && program.getSourceFile(entrypoint))) {
|
|
166512
|
+
return resolvedFileName;
|
|
166513
|
+
}
|
|
166514
|
+
});
|
|
166515
|
+
}
|
|
166516
|
+
}
|
|
166222
166517
|
};
|
|
166223
166518
|
/*@internal*/
|
|
166224
166519
|
AutoImportProviderProject.create = function (dependencySelection, hostProject, moduleResolutionHost, documentRegistry) {
|
|
@@ -171233,6 +171528,9 @@ var ts;
|
|
|
171233
171528
|
}
|
|
171234
171529
|
return;
|
|
171235
171530
|
}
|
|
171531
|
+
this.writeMessage(msg);
|
|
171532
|
+
};
|
|
171533
|
+
Session.prototype.writeMessage = function (msg) {
|
|
171236
171534
|
var msgText = formatMessage(msg, this.logger, this.byteLength, this.host.newLine);
|
|
171237
171535
|
ts.perfLogger.logEvent("Response message size: " + msgText.length);
|
|
171238
171536
|
this.host.write(msgText);
|
|
@@ -171984,7 +172282,7 @@ var ts;
|
|
|
171984
172282
|
var _a = this.getFileAndProject(args), file = _a.file, project = _a.project;
|
|
171985
172283
|
var scriptInfo = this.projectService.getScriptInfoForNormalizedPath(file);
|
|
171986
172284
|
var position = this.getPosition(args, scriptInfo);
|
|
171987
|
-
var completions = project.getLanguageService().getCompletionsAtPosition(file, position, __assign(__assign({}, server.convertUserPreferences(this.getPreferences(file))), { triggerCharacter: args.triggerCharacter, triggerKind: args.triggerKind, includeExternalModuleExports: args.includeExternalModuleExports, includeInsertTextCompletions: args.includeInsertTextCompletions }));
|
|
172285
|
+
var completions = project.getLanguageService().getCompletionsAtPosition(file, position, __assign(__assign({}, server.convertUserPreferences(this.getPreferences(file))), { triggerCharacter: args.triggerCharacter, triggerKind: args.triggerKind, includeExternalModuleExports: args.includeExternalModuleExports, includeInsertTextCompletions: args.includeInsertTextCompletions }), project.projectService.getFormatCodeOptions(file));
|
|
171988
172286
|
if (completions === undefined)
|
|
171989
172287
|
return undefined;
|
|
171990
172288
|
if (kind === "completions-full" /* CompletionsFull */)
|
|
@@ -175272,12 +175570,40 @@ var ts;
|
|
|
175272
175570
|
};
|
|
175273
175571
|
return IOSession;
|
|
175274
175572
|
}(server.Session));
|
|
175573
|
+
var IpcIOSession = /** @class */ (function (_super) {
|
|
175574
|
+
__extends(IpcIOSession, _super);
|
|
175575
|
+
function IpcIOSession() {
|
|
175576
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
175577
|
+
}
|
|
175578
|
+
IpcIOSession.prototype.writeMessage = function (msg) {
|
|
175579
|
+
var verboseLogging = logger.hasLevel(server.LogLevel.verbose);
|
|
175580
|
+
if (verboseLogging) {
|
|
175581
|
+
var json = JSON.stringify(msg);
|
|
175582
|
+
logger.info(msg.type + ":" + server.indent(json));
|
|
175583
|
+
}
|
|
175584
|
+
process.send(msg);
|
|
175585
|
+
};
|
|
175586
|
+
IpcIOSession.prototype.parseMessage = function (message) {
|
|
175587
|
+
return message;
|
|
175588
|
+
};
|
|
175589
|
+
IpcIOSession.prototype.toStringMessage = function (message) {
|
|
175590
|
+
return JSON.stringify(message, undefined, 2);
|
|
175591
|
+
};
|
|
175592
|
+
IpcIOSession.prototype.listen = function () {
|
|
175593
|
+
var _this = this;
|
|
175594
|
+
process.on("message", function (e) {
|
|
175595
|
+
_this.onMessage(e);
|
|
175596
|
+
});
|
|
175597
|
+
};
|
|
175598
|
+
return IpcIOSession;
|
|
175599
|
+
}(IOSession));
|
|
175275
175600
|
var eventPort = parseEventPort(server.findArgument("--eventPort"));
|
|
175276
175601
|
var typingSafeListLocation = server.findArgument(server.Arguments.TypingSafeListLocation); // TODO: GH#18217
|
|
175277
175602
|
var typesMapLocation = server.findArgument(server.Arguments.TypesMapLocation) || ts.combinePaths(ts.getDirectoryPath(ts.sys.getExecutingFilePath()), "typesMap.json");
|
|
175278
175603
|
var npmLocation = server.findArgument(server.Arguments.NpmLocation);
|
|
175279
175604
|
var validateDefaultNpmLocation = server.hasArgument(server.Arguments.ValidateDefaultNpmLocation);
|
|
175280
175605
|
var disableAutomaticTypingAcquisition = server.hasArgument("--disableAutomaticTypingAcquisition");
|
|
175606
|
+
var useNodeIpc = server.hasArgument("--useNodeIpc");
|
|
175281
175607
|
var telemetryEnabled = server.hasArgument(server.Arguments.EnableTelemetry);
|
|
175282
175608
|
var commandLineTraceDir = server.findArgument("--traceDirectory");
|
|
175283
175609
|
var traceDir = commandLineTraceDir
|
|
@@ -175286,7 +175612,7 @@ var ts;
|
|
|
175286
175612
|
if (traceDir) {
|
|
175287
175613
|
ts.startTracing("server", traceDir);
|
|
175288
175614
|
}
|
|
175289
|
-
var ioSession = new IOSession();
|
|
175615
|
+
var ioSession = useNodeIpc ? new IpcIOSession() : new IOSession();
|
|
175290
175616
|
process.on("uncaughtException", function (err) {
|
|
175291
175617
|
ioSession.logError(err, "unknown");
|
|
175292
175618
|
});
|