typescript 4.9.0-dev.20221006 → 4.9.0-dev.20221011
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/protocol.d.ts +11 -5
- package/lib/tsc.js +29 -12
- package/lib/tsserver.js +72 -39
- package/lib/tsserverlibrary.d.ts +11 -6
- package/lib/tsserverlibrary.js +69 -39
- package/lib/typescript.js +44 -25
- package/lib/typescriptServices.js +44 -25
- package/lib/typingsInstaller.js +35 -13
- package/package.json +5 -4
package/lib/tsserverlibrary.js
CHANGED
|
@@ -108,7 +108,7 @@ var ts;
|
|
|
108
108
|
// The following is baselined as a literal template type without intervention
|
|
109
109
|
/** The version of the TypeScript compiler release */
|
|
110
110
|
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
111
|
-
ts.version = "".concat(ts.versionMajorMinor, ".0-dev.
|
|
111
|
+
ts.version = "".concat(ts.versionMajorMinor, ".0-dev.20221011");
|
|
112
112
|
/* @internal */
|
|
113
113
|
var Comparison;
|
|
114
114
|
(function (Comparison) {
|
|
@@ -59872,7 +59872,20 @@ var ts;
|
|
|
59872
59872
|
return !!(ts.getObjectFlags(type) & 32 /* ObjectFlags.Mapped */ && getMappedTypeModifiers(type) & 4 /* MappedTypeModifiers.IncludeOptional */);
|
|
59873
59873
|
}
|
|
59874
59874
|
function isGenericMappedType(type) {
|
|
59875
|
-
|
|
59875
|
+
if (ts.getObjectFlags(type) & 32 /* ObjectFlags.Mapped */) {
|
|
59876
|
+
var constraint = getConstraintTypeFromMappedType(type);
|
|
59877
|
+
if (isGenericIndexType(constraint)) {
|
|
59878
|
+
return true;
|
|
59879
|
+
}
|
|
59880
|
+
// A mapped type is generic if the 'as' clause references generic types other than the iteration type.
|
|
59881
|
+
// To determine this, we substitute the constraint type (that we now know isn't generic) for the iteration
|
|
59882
|
+
// type and check whether the resulting type is generic.
|
|
59883
|
+
var nameType = getNameTypeFromMappedType(type);
|
|
59884
|
+
if (nameType && isGenericIndexType(instantiateType(nameType, makeUnaryTypeMapper(getTypeParameterFromMappedType(type), constraint)))) {
|
|
59885
|
+
return true;
|
|
59886
|
+
}
|
|
59887
|
+
}
|
|
59888
|
+
return false;
|
|
59876
59889
|
}
|
|
59877
59890
|
function resolveStructuredTypeMembers(type) {
|
|
59878
59891
|
if (!type.members) {
|
|
@@ -63192,8 +63205,14 @@ var ts;
|
|
|
63192
63205
|
return getStringLiteralType(text);
|
|
63193
63206
|
}
|
|
63194
63207
|
newTexts.push(text);
|
|
63195
|
-
if (ts.every(newTexts, function (t) { return t === ""; })
|
|
63196
|
-
return
|
|
63208
|
+
if (ts.every(newTexts, function (t) { return t === ""; })) {
|
|
63209
|
+
if (ts.every(newTypes, function (t) { return !!(t.flags & 4 /* TypeFlags.String */); })) {
|
|
63210
|
+
return stringType;
|
|
63211
|
+
}
|
|
63212
|
+
// Normalize `${Mapping<xxx>}` into Mapping<xxx>
|
|
63213
|
+
if (newTypes.length === 1 && isPatternLiteralType(newTypes[0])) {
|
|
63214
|
+
return newTypes[0];
|
|
63215
|
+
}
|
|
63197
63216
|
}
|
|
63198
63217
|
var id = "".concat(getTypeListId(newTypes), "|").concat(ts.map(newTexts, function (t) { return t.length; }).join(","), "|").concat(newTexts.join(""));
|
|
63199
63218
|
var type = templateLiteralTypes.get(id);
|
|
@@ -63252,12 +63271,14 @@ var ts;
|
|
|
63252
63271
|
}
|
|
63253
63272
|
function getStringMappingType(symbol, type) {
|
|
63254
63273
|
return type.flags & (1048576 /* TypeFlags.Union */ | 131072 /* TypeFlags.Never */) ? mapType(type, function (t) { return getStringMappingType(symbol, t); }) :
|
|
63255
|
-
|
|
63256
|
-
|
|
63257
|
-
|
|
63258
|
-
type.flags &
|
|
63259
|
-
type.flags &
|
|
63260
|
-
|
|
63274
|
+
type.flags & 128 /* TypeFlags.StringLiteral */ ? getStringLiteralType(applyStringMapping(symbol, type.value)) :
|
|
63275
|
+
type.flags & 134217728 /* TypeFlags.TemplateLiteral */ ? getTemplateLiteralType.apply(void 0, applyTemplateStringMapping(symbol, type.texts, type.types)) :
|
|
63276
|
+
// Mapping<Mapping<T>> === Mapping<T>
|
|
63277
|
+
type.flags & 268435456 /* TypeFlags.StringMapping */ && symbol === type.symbol ? type :
|
|
63278
|
+
type.flags & (1 /* TypeFlags.Any */ | 4 /* TypeFlags.String */ || type.flags & 268435456 /* TypeFlags.StringMapping */) || isGenericIndexType(type) ? getStringMappingTypeForGenericType(symbol, type) :
|
|
63279
|
+
// This handles Mapping<`${number}`> and Mapping<`${bigint}`>
|
|
63280
|
+
isPatternLiteralPlaceholderType(type) ? getStringMappingTypeForGenericType(symbol, getTemplateLiteralType(["", ""], [type])) :
|
|
63281
|
+
type;
|
|
63261
63282
|
}
|
|
63262
63283
|
function applyStringMapping(symbol, str) {
|
|
63263
63284
|
switch (intrinsicTypeKinds.get(symbol.escapedName)) {
|
|
@@ -63536,10 +63557,11 @@ var ts;
|
|
|
63536
63557
|
accessNode;
|
|
63537
63558
|
}
|
|
63538
63559
|
function isPatternLiteralPlaceholderType(type) {
|
|
63539
|
-
return !!(type.flags & (1 /* TypeFlags.Any */ | 4 /* TypeFlags.String */ | 8 /* TypeFlags.Number */ | 64 /* TypeFlags.BigInt */)) ||
|
|
63560
|
+
return !!(type.flags & (1 /* TypeFlags.Any */ | 4 /* TypeFlags.String */ | 8 /* TypeFlags.Number */ | 64 /* TypeFlags.BigInt */)) || isPatternLiteralType(type);
|
|
63540
63561
|
}
|
|
63541
63562
|
function isPatternLiteralType(type) {
|
|
63542
|
-
return !!(type.flags & 134217728 /* TypeFlags.TemplateLiteral */) && ts.every(type.types, isPatternLiteralPlaceholderType)
|
|
63563
|
+
return !!(type.flags & 134217728 /* TypeFlags.TemplateLiteral */) && ts.every(type.types, isPatternLiteralPlaceholderType) ||
|
|
63564
|
+
!!(type.flags & 268435456 /* TypeFlags.StringMapping */) && isPatternLiteralPlaceholderType(type.type);
|
|
63543
63565
|
}
|
|
63544
63566
|
function isGenericType(type) {
|
|
63545
63567
|
return !!getGenericObjectFlags(type);
|
|
@@ -69726,7 +69748,7 @@ var ts;
|
|
|
69726
69748
|
&& (!roundTripOnly || s === ts.pseudoBigIntToString({ negative: negative, base10Value: ts.parsePseudoBigInt(scanner.getTokenValue()) }));
|
|
69727
69749
|
}
|
|
69728
69750
|
function isMemberOfStringMapping(source, target) {
|
|
69729
|
-
if (target.flags & (4 /* TypeFlags.String */ |
|
|
69751
|
+
if (target.flags & (4 /* TypeFlags.String */ | 1 /* TypeFlags.Any */)) {
|
|
69730
69752
|
return true;
|
|
69731
69753
|
}
|
|
69732
69754
|
if (target.flags & 134217728 /* TypeFlags.TemplateLiteral */) {
|
|
@@ -146632,8 +146654,8 @@ var ts;
|
|
|
146632
146654
|
}
|
|
146633
146655
|
if (ts.scanner.getToken() === 15 /* SyntaxKind.TemplateHead */) {
|
|
146634
146656
|
var stack = [ts.scanner.getToken()];
|
|
146635
|
-
var token = ts.scanner.scan();
|
|
146636
146657
|
loop: while (ts.length(stack)) {
|
|
146658
|
+
var token = ts.scanner.scan();
|
|
146637
146659
|
switch (token) {
|
|
146638
146660
|
case 1 /* SyntaxKind.EndOfFileToken */:
|
|
146639
146661
|
break loop;
|
|
@@ -146661,7 +146683,6 @@ var ts;
|
|
|
146661
146683
|
}
|
|
146662
146684
|
break;
|
|
146663
146685
|
}
|
|
146664
|
-
token = ts.scanner.scan();
|
|
146665
146686
|
}
|
|
146666
146687
|
nextToken();
|
|
146667
146688
|
}
|
|
@@ -164150,7 +164171,6 @@ var ts;
|
|
|
164150
164171
|
var start = cursorRequest ? getExtractableParent(startToken) : ts.getParentNodeInSpan(startToken, sourceFile, adjustedSpan);
|
|
164151
164172
|
// Do the same for the ending position
|
|
164152
164173
|
var end = cursorRequest ? start : ts.getParentNodeInSpan(endToken, sourceFile, adjustedSpan);
|
|
164153
|
-
var declarations = [];
|
|
164154
164174
|
// We'll modify these flags as we walk the tree to collect data
|
|
164155
164175
|
// about what things need to be done as part of the extraction.
|
|
164156
164176
|
var rangeFacts = RangeFacts.None;
|
|
@@ -164193,7 +164213,7 @@ var ts;
|
|
|
164193
164213
|
// the expression.
|
|
164194
164214
|
return { errors: [ts.createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractRange)] };
|
|
164195
164215
|
}
|
|
164196
|
-
return { targetRange: { range: statements, facts: rangeFacts,
|
|
164216
|
+
return { targetRange: { range: statements, facts: rangeFacts, thisNode: thisNode } };
|
|
164197
164217
|
}
|
|
164198
164218
|
if (ts.isReturnStatement(start) && !start.expression) {
|
|
164199
164219
|
// Makes no sense to extract an expression-less return statement.
|
|
@@ -164205,7 +164225,7 @@ var ts;
|
|
|
164205
164225
|
if (errors) {
|
|
164206
164226
|
return { errors: errors };
|
|
164207
164227
|
}
|
|
164208
|
-
return { targetRange: { range: getStatementOrExpressionRange(node), facts: rangeFacts,
|
|
164228
|
+
return { targetRange: { range: getStatementOrExpressionRange(node), facts: rangeFacts, thisNode: thisNode } }; // TODO: GH#18217
|
|
164209
164229
|
/**
|
|
164210
164230
|
* Attempt to refine the extraction node (generally, by shrinking it) to produce better results.
|
|
164211
164231
|
* @param node The unrefined extraction node.
|
|
@@ -164217,10 +164237,10 @@ var ts;
|
|
|
164217
164237
|
}
|
|
164218
164238
|
}
|
|
164219
164239
|
else if (ts.isVariableStatement(node) || ts.isVariableDeclarationList(node)) {
|
|
164220
|
-
var
|
|
164240
|
+
var declarations = ts.isVariableStatement(node) ? node.declarationList.declarations : node.declarations;
|
|
164221
164241
|
var numInitializers = 0;
|
|
164222
164242
|
var lastInitializer = void 0;
|
|
164223
|
-
for (var _i = 0, declarations_5 =
|
|
164243
|
+
for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) {
|
|
164224
164244
|
var declaration = declarations_5[_i];
|
|
164225
164245
|
if (declaration.initializer) {
|
|
164226
164246
|
numInitializers++;
|
|
@@ -164320,7 +164340,6 @@ var ts;
|
|
|
164320
164340
|
(errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractExportedEntity));
|
|
164321
164341
|
return true;
|
|
164322
164342
|
}
|
|
164323
|
-
declarations.push(node.symbol);
|
|
164324
164343
|
}
|
|
164325
164344
|
// Some things can't be extracted in certain situations
|
|
164326
164345
|
switch (node.kind) {
|
|
@@ -168366,8 +168385,8 @@ var ts;
|
|
|
168366
168385
|
tags = __spreadArray(__spreadArray([], inheritedTags, true), tags, true);
|
|
168367
168386
|
}
|
|
168368
168387
|
};
|
|
168369
|
-
for (var _i = 0,
|
|
168370
|
-
var declaration =
|
|
168388
|
+
for (var _i = 0, declarations_6 = declarations; _i < declarations_6.length; _i++) {
|
|
168389
|
+
var declaration = declarations_6[_i];
|
|
168371
168390
|
_loop_20(declaration);
|
|
168372
168391
|
}
|
|
168373
168392
|
}
|
|
@@ -168393,8 +168412,8 @@ var ts;
|
|
|
168393
168412
|
if (inheritedDocs)
|
|
168394
168413
|
doc = doc.length === 0 ? inheritedDocs.slice() : inheritedDocs.concat(ts.lineBreakPart(), doc);
|
|
168395
168414
|
};
|
|
168396
|
-
for (var _i = 0,
|
|
168397
|
-
var declaration =
|
|
168415
|
+
for (var _i = 0, declarations_7 = declarations; _i < declarations_7.length; _i++) {
|
|
168416
|
+
var declaration = declarations_7[_i];
|
|
168398
168417
|
_loop_21(declaration);
|
|
168399
168418
|
}
|
|
168400
168419
|
}
|
|
@@ -173043,6 +173062,7 @@ var ts;
|
|
|
173043
173062
|
this.watchOptions = watchOptions;
|
|
173044
173063
|
this.rootFiles = [];
|
|
173045
173064
|
this.rootFilesMap = new ts.Map();
|
|
173065
|
+
/*@internal*/
|
|
173046
173066
|
this.plugins = [];
|
|
173047
173067
|
/*@internal*/
|
|
173048
173068
|
/**
|
|
@@ -173571,6 +173591,7 @@ var ts;
|
|
|
173571
173591
|
this.directoryStructureHost = undefined;
|
|
173572
173592
|
this.exportMapCache = undefined;
|
|
173573
173593
|
this.projectErrors = undefined;
|
|
173594
|
+
this.plugins.length = 0;
|
|
173574
173595
|
// Clean up file watchers waiting for missing files
|
|
173575
173596
|
if (this.missingFilesMap) {
|
|
173576
173597
|
ts.clearMap(this.missingFilesMap, ts.closeFileWatcher);
|
|
@@ -174244,6 +174265,14 @@ var ts;
|
|
|
174244
174265
|
Project.prototype.isSourceOfProjectReferenceRedirect = function (fileName) {
|
|
174245
174266
|
return !!this.program && this.program.isSourceOfProjectReferenceRedirect(fileName);
|
|
174246
174267
|
};
|
|
174268
|
+
/*@internal*/
|
|
174269
|
+
Project.prototype.getGlobalPluginSearchPaths = function () {
|
|
174270
|
+
// Search any globally-specified probe paths, then our peer node_modules
|
|
174271
|
+
return __spreadArray(__spreadArray([], this.projectService.pluginProbeLocations, true), [
|
|
174272
|
+
// ../../.. to walk from X/node_modules/typescript/lib/tsserver.js to X/node_modules/
|
|
174273
|
+
ts.combinePaths(this.projectService.getExecutingFilePath(), "../../.."),
|
|
174274
|
+
], false);
|
|
174275
|
+
};
|
|
174247
174276
|
Project.prototype.enableGlobalPlugins = function (options, pluginConfigOverrides) {
|
|
174248
174277
|
if (!this.projectService.globalPlugins.length)
|
|
174249
174278
|
return;
|
|
@@ -174252,11 +174281,8 @@ var ts;
|
|
|
174252
174281
|
this.projectService.logger.info("Plugins were requested but not running in environment that supports 'require'. Nothing will be loaded");
|
|
174253
174282
|
return;
|
|
174254
174283
|
}
|
|
174255
|
-
//
|
|
174256
|
-
var searchPaths =
|
|
174257
|
-
// ../../.. to walk from X/node_modules/typescript/lib/tsserver.js to X/node_modules/
|
|
174258
|
-
ts.combinePaths(this.projectService.getExecutingFilePath(), "../../.."),
|
|
174259
|
-
], false);
|
|
174284
|
+
// Enable global plugins with synthetic configuration entries
|
|
174285
|
+
var searchPaths = this.getGlobalPluginSearchPaths();
|
|
174260
174286
|
var _loop_1 = function (globalPluginName) {
|
|
174261
174287
|
// Skip empty names from odd commandline parses
|
|
174262
174288
|
if (!globalPluginName)
|
|
@@ -174269,7 +174295,6 @@ var ts;
|
|
|
174269
174295
|
this_1.enablePlugin({ name: globalPluginName, global: true }, searchPaths, pluginConfigOverrides);
|
|
174270
174296
|
};
|
|
174271
174297
|
var this_1 = this;
|
|
174272
|
-
// Enable global plugins with synthetic configuration entries
|
|
174273
174298
|
for (var _i = 0, _a = this.projectService.globalPlugins; _i < _a.length; _i++) {
|
|
174274
174299
|
var globalPluginName = _a[_i];
|
|
174275
174300
|
_loop_1(globalPluginName);
|
|
@@ -175004,6 +175029,7 @@ var ts;
|
|
|
175004
175029
|
/*@internal*/
|
|
175005
175030
|
ConfiguredProject.prototype.enablePluginsWithOptions = function (options, pluginConfigOverrides) {
|
|
175006
175031
|
var _a;
|
|
175032
|
+
this.plugins.length = 0;
|
|
175007
175033
|
if (!((_a = options.plugins) === null || _a === void 0 ? void 0 : _a.length) && !this.projectService.globalPlugins.length)
|
|
175008
175034
|
return;
|
|
175009
175035
|
var host = this.projectService.host;
|
|
@@ -175011,9 +175037,7 @@ var ts;
|
|
|
175011
175037
|
this.projectService.logger.info("Plugins were requested but not running in environment that supports 'require'. Nothing will be loaded");
|
|
175012
175038
|
return;
|
|
175013
175039
|
}
|
|
175014
|
-
|
|
175015
|
-
// ../../.. to walk from X/node_modules/typescript/lib/tsserver.js to X/node_modules/
|
|
175016
|
-
var searchPaths = __spreadArray([ts.combinePaths(this.projectService.getExecutingFilePath(), "../../..")], this.projectService.pluginProbeLocations, true);
|
|
175040
|
+
var searchPaths = this.getGlobalPluginSearchPaths();
|
|
175017
175041
|
if (this.projectService.allowLocalPluginLoads) {
|
|
175018
175042
|
var local = ts.getDirectoryPath(this.canonicalConfigFilePath);
|
|
175019
175043
|
this.projectService.logger.info("Local plugin loading enabled; adding ".concat(local, " to search paths"));
|
|
@@ -180724,6 +180748,7 @@ var ts;
|
|
|
180724
180748
|
var references = getReferencesWorker(projects, this.getDefaultProject(args), { fileName: args.file, pos: position }, this.logger);
|
|
180725
180749
|
if (!simplifiedResult)
|
|
180726
180750
|
return references;
|
|
180751
|
+
var preferences = this.getPreferences(file);
|
|
180727
180752
|
var defaultProject = this.getDefaultProject(args);
|
|
180728
180753
|
var scriptInfo = defaultProject.getScriptInfoForNormalizedPath(file);
|
|
180729
180754
|
var nameInfo = defaultProject.getLanguageService().getQuickInfoAtPosition(file, position);
|
|
@@ -180732,7 +180757,7 @@ var ts;
|
|
|
180732
180757
|
var symbolStartOffset = nameSpan ? scriptInfo.positionToLineOffset(nameSpan.start).offset : 0;
|
|
180733
180758
|
var symbolName = nameSpan ? scriptInfo.getSnapshot().getText(nameSpan.start, ts.textSpanEnd(nameSpan)) : "";
|
|
180734
180759
|
var refs = ts.flatMap(references, function (referencedSymbol) {
|
|
180735
|
-
return referencedSymbol.references.map(function (entry) { return referenceEntryToReferencesResponseItem(_this.projectService, entry); });
|
|
180760
|
+
return referencedSymbol.references.map(function (entry) { return referenceEntryToReferencesResponseItem(_this.projectService, entry, preferences); });
|
|
180736
180761
|
});
|
|
180737
180762
|
return { refs: refs, symbolName: symbolName, symbolStartOffset: symbolStartOffset, symbolDisplayString: symbolDisplayString };
|
|
180738
180763
|
};
|
|
@@ -180740,6 +180765,7 @@ var ts;
|
|
|
180740
180765
|
var _this = this;
|
|
180741
180766
|
var projects = this.getProjects(args);
|
|
180742
180767
|
var fileName = args.file;
|
|
180768
|
+
var preferences = this.getPreferences(server.toNormalizedPath(fileName));
|
|
180743
180769
|
var references = [];
|
|
180744
180770
|
var seen = createDocumentSpanSet();
|
|
180745
180771
|
forEachProjectInProjects(projects, /*path*/ undefined, function (project) {
|
|
@@ -180758,7 +180784,7 @@ var ts;
|
|
|
180758
180784
|
});
|
|
180759
180785
|
if (!simplifiedResult)
|
|
180760
180786
|
return references;
|
|
180761
|
-
var refs = references.map(function (entry) { return referenceEntryToReferencesResponseItem(_this.projectService, entry); });
|
|
180787
|
+
var refs = references.map(function (entry) { return referenceEntryToReferencesResponseItem(_this.projectService, entry, preferences); });
|
|
180762
180788
|
return {
|
|
180763
180789
|
refs: refs,
|
|
180764
180790
|
symbolName: "\"".concat(args.file, "\"")
|
|
@@ -181822,14 +181848,18 @@ var ts;
|
|
|
181822
181848
|
}
|
|
181823
181849
|
return text;
|
|
181824
181850
|
}
|
|
181825
|
-
function referenceEntryToReferencesResponseItem(projectService, _a) {
|
|
181851
|
+
function referenceEntryToReferencesResponseItem(projectService, _a, _b) {
|
|
181826
181852
|
var fileName = _a.fileName, textSpan = _a.textSpan, contextSpan = _a.contextSpan, isWriteAccess = _a.isWriteAccess, isDefinition = _a.isDefinition;
|
|
181853
|
+
var disableLineTextInReferences = _b.disableLineTextInReferences;
|
|
181827
181854
|
var scriptInfo = ts.Debug.checkDefined(projectService.getScriptInfo(fileName));
|
|
181828
181855
|
var span = toProtocolTextSpanWithContext(textSpan, contextSpan, scriptInfo);
|
|
181829
|
-
var
|
|
181830
|
-
var lineText = scriptInfo.getSnapshot().getText(lineSpan.start, ts.textSpanEnd(lineSpan)).replace(/\r|\n/g, "");
|
|
181856
|
+
var lineText = disableLineTextInReferences ? undefined : getLineText(scriptInfo, span);
|
|
181831
181857
|
return __assign(__assign({ file: fileName }, span), { lineText: lineText, isWriteAccess: isWriteAccess, isDefinition: isDefinition });
|
|
181832
181858
|
}
|
|
181859
|
+
function getLineText(scriptInfo, span) {
|
|
181860
|
+
var lineSpan = scriptInfo.lineToTextSpan(span.start.line - 1);
|
|
181861
|
+
return scriptInfo.getSnapshot().getText(lineSpan.start, ts.textSpanEnd(lineSpan)).replace(/\r|\n/g, "");
|
|
181862
|
+
}
|
|
181833
181863
|
function isCompletionEntryData(data) {
|
|
181834
181864
|
return data === undefined || data && typeof data === "object"
|
|
181835
181865
|
&& typeof data.exportName === "string"
|
package/lib/typescript.js
CHANGED
|
@@ -99,7 +99,7 @@ var ts;
|
|
|
99
99
|
// The following is baselined as a literal template type without intervention
|
|
100
100
|
/** The version of the TypeScript compiler release */
|
|
101
101
|
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
102
|
-
ts.version = "".concat(ts.versionMajorMinor, ".0-dev.
|
|
102
|
+
ts.version = "".concat(ts.versionMajorMinor, ".0-dev.20221011");
|
|
103
103
|
/* @internal */
|
|
104
104
|
var Comparison;
|
|
105
105
|
(function (Comparison) {
|
|
@@ -59863,7 +59863,20 @@ var ts;
|
|
|
59863
59863
|
return !!(ts.getObjectFlags(type) & 32 /* ObjectFlags.Mapped */ && getMappedTypeModifiers(type) & 4 /* MappedTypeModifiers.IncludeOptional */);
|
|
59864
59864
|
}
|
|
59865
59865
|
function isGenericMappedType(type) {
|
|
59866
|
-
|
|
59866
|
+
if (ts.getObjectFlags(type) & 32 /* ObjectFlags.Mapped */) {
|
|
59867
|
+
var constraint = getConstraintTypeFromMappedType(type);
|
|
59868
|
+
if (isGenericIndexType(constraint)) {
|
|
59869
|
+
return true;
|
|
59870
|
+
}
|
|
59871
|
+
// A mapped type is generic if the 'as' clause references generic types other than the iteration type.
|
|
59872
|
+
// To determine this, we substitute the constraint type (that we now know isn't generic) for the iteration
|
|
59873
|
+
// type and check whether the resulting type is generic.
|
|
59874
|
+
var nameType = getNameTypeFromMappedType(type);
|
|
59875
|
+
if (nameType && isGenericIndexType(instantiateType(nameType, makeUnaryTypeMapper(getTypeParameterFromMappedType(type), constraint)))) {
|
|
59876
|
+
return true;
|
|
59877
|
+
}
|
|
59878
|
+
}
|
|
59879
|
+
return false;
|
|
59867
59880
|
}
|
|
59868
59881
|
function resolveStructuredTypeMembers(type) {
|
|
59869
59882
|
if (!type.members) {
|
|
@@ -63183,8 +63196,14 @@ var ts;
|
|
|
63183
63196
|
return getStringLiteralType(text);
|
|
63184
63197
|
}
|
|
63185
63198
|
newTexts.push(text);
|
|
63186
|
-
if (ts.every(newTexts, function (t) { return t === ""; })
|
|
63187
|
-
return
|
|
63199
|
+
if (ts.every(newTexts, function (t) { return t === ""; })) {
|
|
63200
|
+
if (ts.every(newTypes, function (t) { return !!(t.flags & 4 /* TypeFlags.String */); })) {
|
|
63201
|
+
return stringType;
|
|
63202
|
+
}
|
|
63203
|
+
// Normalize `${Mapping<xxx>}` into Mapping<xxx>
|
|
63204
|
+
if (newTypes.length === 1 && isPatternLiteralType(newTypes[0])) {
|
|
63205
|
+
return newTypes[0];
|
|
63206
|
+
}
|
|
63188
63207
|
}
|
|
63189
63208
|
var id = "".concat(getTypeListId(newTypes), "|").concat(ts.map(newTexts, function (t) { return t.length; }).join(","), "|").concat(newTexts.join(""));
|
|
63190
63209
|
var type = templateLiteralTypes.get(id);
|
|
@@ -63243,12 +63262,14 @@ var ts;
|
|
|
63243
63262
|
}
|
|
63244
63263
|
function getStringMappingType(symbol, type) {
|
|
63245
63264
|
return type.flags & (1048576 /* TypeFlags.Union */ | 131072 /* TypeFlags.Never */) ? mapType(type, function (t) { return getStringMappingType(symbol, t); }) :
|
|
63246
|
-
|
|
63247
|
-
|
|
63248
|
-
|
|
63249
|
-
type.flags &
|
|
63250
|
-
type.flags &
|
|
63251
|
-
|
|
63265
|
+
type.flags & 128 /* TypeFlags.StringLiteral */ ? getStringLiteralType(applyStringMapping(symbol, type.value)) :
|
|
63266
|
+
type.flags & 134217728 /* TypeFlags.TemplateLiteral */ ? getTemplateLiteralType.apply(void 0, applyTemplateStringMapping(symbol, type.texts, type.types)) :
|
|
63267
|
+
// Mapping<Mapping<T>> === Mapping<T>
|
|
63268
|
+
type.flags & 268435456 /* TypeFlags.StringMapping */ && symbol === type.symbol ? type :
|
|
63269
|
+
type.flags & (1 /* TypeFlags.Any */ | 4 /* TypeFlags.String */ || type.flags & 268435456 /* TypeFlags.StringMapping */) || isGenericIndexType(type) ? getStringMappingTypeForGenericType(symbol, type) :
|
|
63270
|
+
// This handles Mapping<`${number}`> and Mapping<`${bigint}`>
|
|
63271
|
+
isPatternLiteralPlaceholderType(type) ? getStringMappingTypeForGenericType(symbol, getTemplateLiteralType(["", ""], [type])) :
|
|
63272
|
+
type;
|
|
63252
63273
|
}
|
|
63253
63274
|
function applyStringMapping(symbol, str) {
|
|
63254
63275
|
switch (intrinsicTypeKinds.get(symbol.escapedName)) {
|
|
@@ -63527,10 +63548,11 @@ var ts;
|
|
|
63527
63548
|
accessNode;
|
|
63528
63549
|
}
|
|
63529
63550
|
function isPatternLiteralPlaceholderType(type) {
|
|
63530
|
-
return !!(type.flags & (1 /* TypeFlags.Any */ | 4 /* TypeFlags.String */ | 8 /* TypeFlags.Number */ | 64 /* TypeFlags.BigInt */)) ||
|
|
63551
|
+
return !!(type.flags & (1 /* TypeFlags.Any */ | 4 /* TypeFlags.String */ | 8 /* TypeFlags.Number */ | 64 /* TypeFlags.BigInt */)) || isPatternLiteralType(type);
|
|
63531
63552
|
}
|
|
63532
63553
|
function isPatternLiteralType(type) {
|
|
63533
|
-
return !!(type.flags & 134217728 /* TypeFlags.TemplateLiteral */) && ts.every(type.types, isPatternLiteralPlaceholderType)
|
|
63554
|
+
return !!(type.flags & 134217728 /* TypeFlags.TemplateLiteral */) && ts.every(type.types, isPatternLiteralPlaceholderType) ||
|
|
63555
|
+
!!(type.flags & 268435456 /* TypeFlags.StringMapping */) && isPatternLiteralPlaceholderType(type.type);
|
|
63534
63556
|
}
|
|
63535
63557
|
function isGenericType(type) {
|
|
63536
63558
|
return !!getGenericObjectFlags(type);
|
|
@@ -69717,7 +69739,7 @@ var ts;
|
|
|
69717
69739
|
&& (!roundTripOnly || s === ts.pseudoBigIntToString({ negative: negative, base10Value: ts.parsePseudoBigInt(scanner.getTokenValue()) }));
|
|
69718
69740
|
}
|
|
69719
69741
|
function isMemberOfStringMapping(source, target) {
|
|
69720
|
-
if (target.flags & (4 /* TypeFlags.String */ |
|
|
69742
|
+
if (target.flags & (4 /* TypeFlags.String */ | 1 /* TypeFlags.Any */)) {
|
|
69721
69743
|
return true;
|
|
69722
69744
|
}
|
|
69723
69745
|
if (target.flags & 134217728 /* TypeFlags.TemplateLiteral */) {
|
|
@@ -146623,8 +146645,8 @@ var ts;
|
|
|
146623
146645
|
}
|
|
146624
146646
|
if (ts.scanner.getToken() === 15 /* SyntaxKind.TemplateHead */) {
|
|
146625
146647
|
var stack = [ts.scanner.getToken()];
|
|
146626
|
-
var token = ts.scanner.scan();
|
|
146627
146648
|
loop: while (ts.length(stack)) {
|
|
146649
|
+
var token = ts.scanner.scan();
|
|
146628
146650
|
switch (token) {
|
|
146629
146651
|
case 1 /* SyntaxKind.EndOfFileToken */:
|
|
146630
146652
|
break loop;
|
|
@@ -146652,7 +146674,6 @@ var ts;
|
|
|
146652
146674
|
}
|
|
146653
146675
|
break;
|
|
146654
146676
|
}
|
|
146655
|
-
token = ts.scanner.scan();
|
|
146656
146677
|
}
|
|
146657
146678
|
nextToken();
|
|
146658
146679
|
}
|
|
@@ -164141,7 +164162,6 @@ var ts;
|
|
|
164141
164162
|
var start = cursorRequest ? getExtractableParent(startToken) : ts.getParentNodeInSpan(startToken, sourceFile, adjustedSpan);
|
|
164142
164163
|
// Do the same for the ending position
|
|
164143
164164
|
var end = cursorRequest ? start : ts.getParentNodeInSpan(endToken, sourceFile, adjustedSpan);
|
|
164144
|
-
var declarations = [];
|
|
164145
164165
|
// We'll modify these flags as we walk the tree to collect data
|
|
164146
164166
|
// about what things need to be done as part of the extraction.
|
|
164147
164167
|
var rangeFacts = RangeFacts.None;
|
|
@@ -164184,7 +164204,7 @@ var ts;
|
|
|
164184
164204
|
// the expression.
|
|
164185
164205
|
return { errors: [ts.createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractRange)] };
|
|
164186
164206
|
}
|
|
164187
|
-
return { targetRange: { range: statements, facts: rangeFacts,
|
|
164207
|
+
return { targetRange: { range: statements, facts: rangeFacts, thisNode: thisNode } };
|
|
164188
164208
|
}
|
|
164189
164209
|
if (ts.isReturnStatement(start) && !start.expression) {
|
|
164190
164210
|
// Makes no sense to extract an expression-less return statement.
|
|
@@ -164196,7 +164216,7 @@ var ts;
|
|
|
164196
164216
|
if (errors) {
|
|
164197
164217
|
return { errors: errors };
|
|
164198
164218
|
}
|
|
164199
|
-
return { targetRange: { range: getStatementOrExpressionRange(node), facts: rangeFacts,
|
|
164219
|
+
return { targetRange: { range: getStatementOrExpressionRange(node), facts: rangeFacts, thisNode: thisNode } }; // TODO: GH#18217
|
|
164200
164220
|
/**
|
|
164201
164221
|
* Attempt to refine the extraction node (generally, by shrinking it) to produce better results.
|
|
164202
164222
|
* @param node The unrefined extraction node.
|
|
@@ -164208,10 +164228,10 @@ var ts;
|
|
|
164208
164228
|
}
|
|
164209
164229
|
}
|
|
164210
164230
|
else if (ts.isVariableStatement(node) || ts.isVariableDeclarationList(node)) {
|
|
164211
|
-
var
|
|
164231
|
+
var declarations = ts.isVariableStatement(node) ? node.declarationList.declarations : node.declarations;
|
|
164212
164232
|
var numInitializers = 0;
|
|
164213
164233
|
var lastInitializer = void 0;
|
|
164214
|
-
for (var _i = 0, declarations_5 =
|
|
164234
|
+
for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) {
|
|
164215
164235
|
var declaration = declarations_5[_i];
|
|
164216
164236
|
if (declaration.initializer) {
|
|
164217
164237
|
numInitializers++;
|
|
@@ -164311,7 +164331,6 @@ var ts;
|
|
|
164311
164331
|
(errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractExportedEntity));
|
|
164312
164332
|
return true;
|
|
164313
164333
|
}
|
|
164314
|
-
declarations.push(node.symbol);
|
|
164315
164334
|
}
|
|
164316
164335
|
// Some things can't be extracted in certain situations
|
|
164317
164336
|
switch (node.kind) {
|
|
@@ -168357,8 +168376,8 @@ var ts;
|
|
|
168357
168376
|
tags = __spreadArray(__spreadArray([], inheritedTags, true), tags, true);
|
|
168358
168377
|
}
|
|
168359
168378
|
};
|
|
168360
|
-
for (var _i = 0,
|
|
168361
|
-
var declaration =
|
|
168379
|
+
for (var _i = 0, declarations_6 = declarations; _i < declarations_6.length; _i++) {
|
|
168380
|
+
var declaration = declarations_6[_i];
|
|
168362
168381
|
_loop_20(declaration);
|
|
168363
168382
|
}
|
|
168364
168383
|
}
|
|
@@ -168384,8 +168403,8 @@ var ts;
|
|
|
168384
168403
|
if (inheritedDocs)
|
|
168385
168404
|
doc = doc.length === 0 ? inheritedDocs.slice() : inheritedDocs.concat(ts.lineBreakPart(), doc);
|
|
168386
168405
|
};
|
|
168387
|
-
for (var _i = 0,
|
|
168388
|
-
var declaration =
|
|
168406
|
+
for (var _i = 0, declarations_7 = declarations; _i < declarations_7.length; _i++) {
|
|
168407
|
+
var declaration = declarations_7[_i];
|
|
168389
168408
|
_loop_21(declaration);
|
|
168390
168409
|
}
|
|
168391
168410
|
}
|