typescript 5.0.0-dev.20221130 → 5.0.0-dev.20221202
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.es2022.sharedmemory.d.ts +15 -1
- package/lib/tsc.js +143 -141
- package/lib/tsserver.js +469 -179
- package/lib/tsserverlibrary.js +469 -179
- package/lib/typescript.js +462 -179
- package/lib/typingsInstaller.js +1 -1
- package/package.json +1 -1
package/lib/tsserverlibrary.js
CHANGED
|
@@ -42,7 +42,7 @@ var ts = (() => {
|
|
|
42
42
|
"src/compiler/corePublic.ts"() {
|
|
43
43
|
"use strict";
|
|
44
44
|
versionMajorMinor = "5.0";
|
|
45
|
-
version = `${versionMajorMinor}.0-dev.
|
|
45
|
+
version = `${versionMajorMinor}.0-dev.20221202`;
|
|
46
46
|
Comparison = /* @__PURE__ */ ((Comparison3) => {
|
|
47
47
|
Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
|
|
48
48
|
Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
|
|
@@ -17095,6 +17095,32 @@ ${lanes.join("\n")}
|
|
|
17095
17095
|
function pseudoBigIntToString({ negative, base10Value }) {
|
|
17096
17096
|
return (negative && base10Value !== "0" ? "-" : "") + base10Value;
|
|
17097
17097
|
}
|
|
17098
|
+
function parseBigInt(text) {
|
|
17099
|
+
if (!isValidBigIntString(text, false)) {
|
|
17100
|
+
return void 0;
|
|
17101
|
+
}
|
|
17102
|
+
return parseValidBigInt(text);
|
|
17103
|
+
}
|
|
17104
|
+
function parseValidBigInt(text) {
|
|
17105
|
+
const negative = text.startsWith("-");
|
|
17106
|
+
const base10Value = parsePseudoBigInt(`${negative ? text.slice(1) : text}n`);
|
|
17107
|
+
return { negative, base10Value };
|
|
17108
|
+
}
|
|
17109
|
+
function isValidBigIntString(s, roundTripOnly) {
|
|
17110
|
+
if (s === "")
|
|
17111
|
+
return false;
|
|
17112
|
+
const scanner2 = createScanner(99 /* ESNext */, false);
|
|
17113
|
+
let success = true;
|
|
17114
|
+
scanner2.setOnError(() => success = false);
|
|
17115
|
+
scanner2.setText(s + "n");
|
|
17116
|
+
let result = scanner2.scan();
|
|
17117
|
+
const negative = result === 40 /* MinusToken */;
|
|
17118
|
+
if (negative) {
|
|
17119
|
+
result = scanner2.scan();
|
|
17120
|
+
}
|
|
17121
|
+
const flags = scanner2.getTokenFlags();
|
|
17122
|
+
return success && result === 9 /* BigIntLiteral */ && scanner2.getTextPos() === s.length + 1 && !(flags & 512 /* ContainsSeparator */) && (!roundTripOnly || s === pseudoBigIntToString({ negative, base10Value: parsePseudoBigInt(scanner2.getTokenValue()) }));
|
|
17123
|
+
}
|
|
17098
17124
|
function isValidTypeOnlyAliasUseSite(useSite) {
|
|
17099
17125
|
return !!(useSite.flags & 16777216 /* Ambient */) || isPartOfTypeQuery(useSite) || isIdentifierInNonEmittingHeritageClause(useSite) || isPartOfPossiblyValidTypeOrAbstractComputedPropertyName(useSite) || !(isExpressionNode(useSite) || isShorthandPropertyNameUseSite(useSite));
|
|
17100
17126
|
}
|
|
@@ -17421,6 +17447,17 @@ ${lanes.join("\n")}
|
|
|
17421
17447
|
const { isBracketed, typeExpression } = node;
|
|
17422
17448
|
return isBracketed || !!typeExpression && typeExpression.type.kind === 319 /* JSDocOptionalType */;
|
|
17423
17449
|
}
|
|
17450
|
+
function canUsePropertyAccess(name, languageVersion) {
|
|
17451
|
+
if (name.length === 0) {
|
|
17452
|
+
return false;
|
|
17453
|
+
}
|
|
17454
|
+
const firstChar = name.charCodeAt(0);
|
|
17455
|
+
return firstChar === 35 /* hash */ ? name.length > 1 && isIdentifierStart(name.charCodeAt(1), languageVersion) : isIdentifierStart(firstChar, languageVersion);
|
|
17456
|
+
}
|
|
17457
|
+
function hasTabstop(node) {
|
|
17458
|
+
var _a2;
|
|
17459
|
+
return ((_a2 = getSnippetElement(node)) == null ? void 0 : _a2.kind) === 0 /* TabStop */;
|
|
17460
|
+
}
|
|
17424
17461
|
var resolvingEmptyArray, externalHelpersModuleNameText, defaultMaximumTruncationLength, noTruncationMaximumTruncationLength, stringWriter, GetLiteralTextFlags, fullTripleSlashReferencePathRegEx, fullTripleSlashReferenceTypeReferenceDirectiveRegEx, fullTripleSlashAMDReferencePathRegEx, defaultLibReferenceRegEx, AssignmentKind, FunctionFlags, Associativity, OperatorPrecedence, templateSubstitutionRegExp, doubleQuoteEscapedCharsRegExp, singleQuoteEscapedCharsRegExp, backtickQuoteEscapedCharsRegExp, escapedCharsMap, nonAsciiCharacters, jsxDoubleQuoteEscapedCharsRegExp, jsxSingleQuoteEscapedCharsRegExp, jsxEscapedCharsMap, indentStrings, base64Digits, carriageReturnLineFeed, lineFeed, AccessKind, objectAllocator, localizedDiagnosticMessages, reservedCharacterPattern, wildcardCharCodes, commonPackageFolders, implicitExcludePathRegexPattern, filesMatcher, directoriesMatcher, excludeMatcher, wildcardMatchers, supportedTSExtensions, supportedTSExtensionsFlat, supportedTSExtensionsWithJson, supportedTSExtensionsForExtractExtension, supportedJSExtensions, supportedJSExtensionsFlat, allSupportedExtensions, allSupportedExtensionsWithJson, supportedDeclarationExtensions, supportedTSImplementationExtensions, extensionsToRemove, emptyFileSystemEntries;
|
|
17425
17462
|
var init_utilities = __esm({
|
|
17426
17463
|
"src/compiler/utilities.ts"() {
|
|
@@ -35262,41 +35299,86 @@ ${lanes.join("\n")}
|
|
|
35262
35299
|
}
|
|
35263
35300
|
return result;
|
|
35264
35301
|
}
|
|
35265
|
-
function
|
|
35266
|
-
|
|
35302
|
+
function compilerOptionValueToString(value) {
|
|
35303
|
+
var _a2;
|
|
35304
|
+
if (value === null || typeof value !== "object") {
|
|
35305
|
+
return "" + value;
|
|
35306
|
+
}
|
|
35307
|
+
if (isArray(value)) {
|
|
35308
|
+
return `[${(_a2 = value.map((e) => compilerOptionValueToString(e))) == null ? void 0 : _a2.join(",")}]`;
|
|
35309
|
+
}
|
|
35310
|
+
let str = "{";
|
|
35311
|
+
for (const key in value) {
|
|
35312
|
+
if (hasProperty(value, key)) {
|
|
35313
|
+
str += `${key}: ${compilerOptionValueToString(value[key])}`;
|
|
35314
|
+
}
|
|
35315
|
+
}
|
|
35316
|
+
return str + "}";
|
|
35317
|
+
}
|
|
35318
|
+
function getKeyForCompilerOptions(options, affectingOptionDeclarations) {
|
|
35319
|
+
return affectingOptionDeclarations.map((option) => compilerOptionValueToString(getCompilerOptionValue(options, option))).join("|") + (options.pathsBasePath ? `|${options.pathsBasePath}` : void 0);
|
|
35320
|
+
}
|
|
35321
|
+
function createCacheWithRedirects(ownOptions) {
|
|
35267
35322
|
const redirectsMap = /* @__PURE__ */ new Map();
|
|
35323
|
+
const optionsToRedirectsKey = /* @__PURE__ */ new Map();
|
|
35324
|
+
const redirectsKeyToMap = /* @__PURE__ */ new Map();
|
|
35325
|
+
let ownMap = /* @__PURE__ */ new Map();
|
|
35326
|
+
if (ownOptions)
|
|
35327
|
+
redirectsMap.set(ownOptions, ownMap);
|
|
35268
35328
|
return {
|
|
35269
|
-
getOwnMap,
|
|
35270
|
-
redirectsMap,
|
|
35271
35329
|
getOrCreateMapOfCacheRedirects,
|
|
35272
|
-
|
|
35273
|
-
|
|
35274
|
-
setOwnMap
|
|
35330
|
+
update,
|
|
35331
|
+
clear: clear2
|
|
35275
35332
|
};
|
|
35276
|
-
function getOwnMap() {
|
|
35277
|
-
return ownMap;
|
|
35278
|
-
}
|
|
35279
|
-
function setOwnOptions(newOptions) {
|
|
35280
|
-
options = newOptions;
|
|
35281
|
-
}
|
|
35282
|
-
function setOwnMap(newOwnMap) {
|
|
35283
|
-
ownMap = newOwnMap;
|
|
35284
|
-
}
|
|
35285
35333
|
function getOrCreateMapOfCacheRedirects(redirectedReference) {
|
|
35286
|
-
|
|
35287
|
-
|
|
35334
|
+
return redirectedReference ? getOrCreateMap(redirectedReference.commandLine.options) : ownMap;
|
|
35335
|
+
}
|
|
35336
|
+
function update(newOptions) {
|
|
35337
|
+
if (ownOptions !== newOptions) {
|
|
35338
|
+
if (ownOptions)
|
|
35339
|
+
ownMap = getOrCreateMap(newOptions);
|
|
35340
|
+
else
|
|
35341
|
+
redirectsMap.set(newOptions, ownMap);
|
|
35342
|
+
ownOptions = newOptions;
|
|
35288
35343
|
}
|
|
35289
|
-
|
|
35290
|
-
|
|
35291
|
-
|
|
35292
|
-
|
|
35293
|
-
|
|
35344
|
+
}
|
|
35345
|
+
function getOrCreateMap(redirectOptions) {
|
|
35346
|
+
let result = redirectsMap.get(redirectOptions);
|
|
35347
|
+
if (result)
|
|
35348
|
+
return result;
|
|
35349
|
+
const key = getRedirectsCacheKey(redirectOptions);
|
|
35350
|
+
result = redirectsKeyToMap.get(key);
|
|
35351
|
+
if (!result) {
|
|
35352
|
+
if (ownOptions) {
|
|
35353
|
+
const ownKey = getRedirectsCacheKey(ownOptions);
|
|
35354
|
+
if (ownKey === key)
|
|
35355
|
+
result = ownMap;
|
|
35356
|
+
else if (!redirectsKeyToMap.has(ownKey))
|
|
35357
|
+
redirectsKeyToMap.set(ownKey, ownMap);
|
|
35358
|
+
}
|
|
35359
|
+
redirectsKeyToMap.set(key, result != null ? result : result = /* @__PURE__ */ new Map());
|
|
35294
35360
|
}
|
|
35295
|
-
|
|
35361
|
+
redirectsMap.set(redirectOptions, result);
|
|
35362
|
+
return result;
|
|
35296
35363
|
}
|
|
35297
35364
|
function clear2() {
|
|
35365
|
+
const ownKey = ownOptions && optionsToRedirectsKey.get(ownOptions);
|
|
35298
35366
|
ownMap.clear();
|
|
35299
35367
|
redirectsMap.clear();
|
|
35368
|
+
optionsToRedirectsKey.clear();
|
|
35369
|
+
redirectsKeyToMap.clear();
|
|
35370
|
+
if (ownOptions) {
|
|
35371
|
+
if (ownKey)
|
|
35372
|
+
optionsToRedirectsKey.set(ownOptions, ownKey);
|
|
35373
|
+
redirectsMap.set(ownOptions, ownMap);
|
|
35374
|
+
}
|
|
35375
|
+
}
|
|
35376
|
+
function getRedirectsCacheKey(options) {
|
|
35377
|
+
let result = optionsToRedirectsKey.get(options);
|
|
35378
|
+
if (!result) {
|
|
35379
|
+
optionsToRedirectsKey.set(options, result = getKeyForCompilerOptions(options, moduleResolutionOptionDeclarations));
|
|
35380
|
+
}
|
|
35381
|
+
return result;
|
|
35300
35382
|
}
|
|
35301
35383
|
}
|
|
35302
35384
|
function createPackageJsonInfoCache(currentDirectory, getCanonicalFileName) {
|
|
@@ -35328,27 +35410,6 @@ ${lanes.join("\n")}
|
|
|
35328
35410
|
}
|
|
35329
35411
|
return result;
|
|
35330
35412
|
}
|
|
35331
|
-
function updateRedirectsMap(options, directoryToModuleNameMap, moduleNameToDirectoryMap) {
|
|
35332
|
-
if (!options.configFile)
|
|
35333
|
-
return;
|
|
35334
|
-
if (directoryToModuleNameMap.redirectsMap.size === 0) {
|
|
35335
|
-
Debug.assert(!moduleNameToDirectoryMap || moduleNameToDirectoryMap.redirectsMap.size === 0);
|
|
35336
|
-
Debug.assert(directoryToModuleNameMap.getOwnMap().size === 0);
|
|
35337
|
-
Debug.assert(!moduleNameToDirectoryMap || moduleNameToDirectoryMap.getOwnMap().size === 0);
|
|
35338
|
-
directoryToModuleNameMap.redirectsMap.set(options.configFile.path, directoryToModuleNameMap.getOwnMap());
|
|
35339
|
-
moduleNameToDirectoryMap == null ? void 0 : moduleNameToDirectoryMap.redirectsMap.set(options.configFile.path, moduleNameToDirectoryMap.getOwnMap());
|
|
35340
|
-
} else {
|
|
35341
|
-
Debug.assert(!moduleNameToDirectoryMap || moduleNameToDirectoryMap.redirectsMap.size > 0);
|
|
35342
|
-
const ref = {
|
|
35343
|
-
sourceFile: options.configFile,
|
|
35344
|
-
commandLine: { options }
|
|
35345
|
-
};
|
|
35346
|
-
directoryToModuleNameMap.setOwnMap(directoryToModuleNameMap.getOrCreateMapOfCacheRedirects(ref));
|
|
35347
|
-
moduleNameToDirectoryMap == null ? void 0 : moduleNameToDirectoryMap.setOwnMap(moduleNameToDirectoryMap.getOrCreateMapOfCacheRedirects(ref));
|
|
35348
|
-
}
|
|
35349
|
-
directoryToModuleNameMap.setOwnOptions(options);
|
|
35350
|
-
moduleNameToDirectoryMap == null ? void 0 : moduleNameToDirectoryMap.setOwnOptions(options);
|
|
35351
|
-
}
|
|
35352
35413
|
function createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, directoryToModuleNameMap) {
|
|
35353
35414
|
return {
|
|
35354
35415
|
getOrCreateCacheForDirectory,
|
|
@@ -35359,13 +35420,16 @@ ${lanes.join("\n")}
|
|
|
35359
35420
|
directoryToModuleNameMap.clear();
|
|
35360
35421
|
}
|
|
35361
35422
|
function update(options) {
|
|
35362
|
-
|
|
35423
|
+
directoryToModuleNameMap.update(options);
|
|
35363
35424
|
}
|
|
35364
35425
|
function getOrCreateCacheForDirectory(directoryName, redirectedReference) {
|
|
35365
35426
|
const path = toPath(directoryName, currentDirectory, getCanonicalFileName);
|
|
35366
35427
|
return getOrCreateCache(directoryToModuleNameMap, redirectedReference, path, () => createModeAwareCache());
|
|
35367
35428
|
}
|
|
35368
35429
|
}
|
|
35430
|
+
function createModeAwareCacheKey(specifier, mode) {
|
|
35431
|
+
return mode === void 0 ? specifier : `${mode}|${specifier}`;
|
|
35432
|
+
}
|
|
35369
35433
|
function createModeAwareCache() {
|
|
35370
35434
|
const underlying = /* @__PURE__ */ new Map();
|
|
35371
35435
|
const memoizedReverseKeys = /* @__PURE__ */ new Map();
|
|
@@ -35396,7 +35460,7 @@ ${lanes.join("\n")}
|
|
|
35396
35460
|
};
|
|
35397
35461
|
return cache;
|
|
35398
35462
|
function getUnderlyingCacheKey(specifier, mode) {
|
|
35399
|
-
const result =
|
|
35463
|
+
const result = createModeAwareCacheKey(specifier, mode);
|
|
35400
35464
|
memoizedReverseKeys.set(result, [specifier, mode]);
|
|
35401
35465
|
return result;
|
|
35402
35466
|
}
|
|
@@ -35416,9 +35480,10 @@ ${lanes.join("\n")}
|
|
|
35416
35480
|
}
|
|
35417
35481
|
return map2;
|
|
35418
35482
|
}
|
|
35419
|
-
function createModuleResolutionCache(currentDirectory, getCanonicalFileName, options
|
|
35420
|
-
const
|
|
35421
|
-
|
|
35483
|
+
function createModuleResolutionCache(currentDirectory, getCanonicalFileName, options) {
|
|
35484
|
+
const directoryToModuleNameMap = createCacheWithRedirects(options);
|
|
35485
|
+
const perDirectoryResolutionCache = createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, directoryToModuleNameMap);
|
|
35486
|
+
const moduleNameToDirectoryMap = createCacheWithRedirects(options);
|
|
35422
35487
|
const packageJsonInfoCache = createPackageJsonInfoCache(currentDirectory, getCanonicalFileName);
|
|
35423
35488
|
return {
|
|
35424
35489
|
...packageJsonInfoCache,
|
|
@@ -35438,11 +35503,12 @@ ${lanes.join("\n")}
|
|
|
35438
35503
|
moduleNameToDirectoryMap.clear();
|
|
35439
35504
|
}
|
|
35440
35505
|
function update(options2) {
|
|
35441
|
-
|
|
35506
|
+
directoryToModuleNameMap.update(options2);
|
|
35507
|
+
moduleNameToDirectoryMap.update(options2);
|
|
35442
35508
|
}
|
|
35443
35509
|
function getOrCreateCacheForModuleName(nonRelativeModuleName, mode, redirectedReference) {
|
|
35444
35510
|
Debug.assert(!isExternalModuleNameRelative(nonRelativeModuleName));
|
|
35445
|
-
return getOrCreateCache(moduleNameToDirectoryMap, redirectedReference,
|
|
35511
|
+
return getOrCreateCache(moduleNameToDirectoryMap, redirectedReference, createModeAwareCacheKey(nonRelativeModuleName, mode), createPerModuleNameCache);
|
|
35446
35512
|
}
|
|
35447
35513
|
function createPerModuleNameCache() {
|
|
35448
35514
|
const directoryPathMap = /* @__PURE__ */ new Map();
|
|
@@ -35490,8 +35556,9 @@ ${lanes.join("\n")}
|
|
|
35490
35556
|
}
|
|
35491
35557
|
}
|
|
35492
35558
|
}
|
|
35493
|
-
function createTypeReferenceDirectiveResolutionCache(currentDirectory, getCanonicalFileName, options, packageJsonInfoCache
|
|
35494
|
-
const
|
|
35559
|
+
function createTypeReferenceDirectiveResolutionCache(currentDirectory, getCanonicalFileName, options, packageJsonInfoCache) {
|
|
35560
|
+
const directoryToModuleNameMap = createCacheWithRedirects(options);
|
|
35561
|
+
const perDirectoryResolutionCache = createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, directoryToModuleNameMap);
|
|
35495
35562
|
packageJsonInfoCache || (packageJsonInfoCache = createPackageJsonInfoCache(currentDirectory, getCanonicalFileName));
|
|
35496
35563
|
return {
|
|
35497
35564
|
...packageJsonInfoCache,
|
|
@@ -45171,7 +45238,7 @@ ${lanes.join("\n")}
|
|
|
45171
45238
|
}
|
|
45172
45239
|
const contextFile = getSourceFileOfNode(getOriginalNode(context.enclosingDeclaration));
|
|
45173
45240
|
const resolutionMode = overrideImportMode || (contextFile == null ? void 0 : contextFile.impliedNodeFormat);
|
|
45174
|
-
const cacheKey =
|
|
45241
|
+
const cacheKey = createModeAwareCacheKey(contextFile.path, resolutionMode);
|
|
45175
45242
|
const links = getSymbolLinks(symbol);
|
|
45176
45243
|
let specifier = links.specifierCache && links.specifierCache.get(cacheKey);
|
|
45177
45244
|
if (!specifier) {
|
|
@@ -45194,9 +45261,6 @@ ${lanes.join("\n")}
|
|
|
45194
45261
|
links.specifierCache.set(cacheKey, specifier);
|
|
45195
45262
|
}
|
|
45196
45263
|
return specifier;
|
|
45197
|
-
function getSpecifierCacheKey(path, mode) {
|
|
45198
|
-
return mode === void 0 ? path : `${mode}|${path}`;
|
|
45199
|
-
}
|
|
45200
45264
|
}
|
|
45201
45265
|
function symbolToEntityNameNode(symbol) {
|
|
45202
45266
|
const identifier = factory.createIdentifier(unescapeLeadingUnderscores(symbol.escapedName));
|
|
@@ -45410,8 +45474,7 @@ ${lanes.join("\n")}
|
|
|
45410
45474
|
if (isSingleOrDoubleQuote(firstChar) && some(symbol2.declarations, hasNonGlobalAugmentationExternalModuleSymbol)) {
|
|
45411
45475
|
return factory.createStringLiteral(getSpecifierForModuleSymbol(symbol2, context));
|
|
45412
45476
|
}
|
|
45413
|
-
|
|
45414
|
-
if (index === 0 || canUsePropertyAccess) {
|
|
45477
|
+
if (index === 0 || canUsePropertyAccess(symbolName2, languageVersion)) {
|
|
45415
45478
|
const identifier = setEmitFlags(factory.createIdentifier(symbolName2, typeParameterNodes), 33554432 /* NoAsciiEscaping */);
|
|
45416
45479
|
identifier.symbol = symbol2;
|
|
45417
45480
|
return index > 0 ? factory.createPropertyAccessExpression(createExpressionFromSymbolChain(chain2, index - 1), identifier) : identifier;
|
|
@@ -56841,7 +56904,8 @@ ${lanes.join("\n")}
|
|
|
56841
56904
|
return !!(type.flags & 109440 /* Unit */);
|
|
56842
56905
|
}
|
|
56843
56906
|
function isUnitLikeType(type) {
|
|
56844
|
-
|
|
56907
|
+
const t = getBaseConstraintOrType(type);
|
|
56908
|
+
return t.flags & 2097152 /* Intersection */ ? some(t.types, isUnitType) : isUnitType(t);
|
|
56845
56909
|
}
|
|
56846
56910
|
function extractUnitType(type) {
|
|
56847
56911
|
return type.flags & 2097152 /* Intersection */ ? find(type.types, isUnitType) || type : type;
|
|
@@ -57482,24 +57546,7 @@ ${lanes.join("\n")}
|
|
|
57482
57546
|
return isFinite(n) && (!roundTripOnly || "" + n === s);
|
|
57483
57547
|
}
|
|
57484
57548
|
function parseBigIntLiteralType(text) {
|
|
57485
|
-
|
|
57486
|
-
const base10Value = parsePseudoBigInt(`${negative ? text.slice(1) : text}n`);
|
|
57487
|
-
return getBigIntLiteralType({ negative, base10Value });
|
|
57488
|
-
}
|
|
57489
|
-
function isValidBigIntString(s, roundTripOnly) {
|
|
57490
|
-
if (s === "")
|
|
57491
|
-
return false;
|
|
57492
|
-
const scanner2 = createScanner(99 /* ESNext */, false);
|
|
57493
|
-
let success = true;
|
|
57494
|
-
scanner2.setOnError(() => success = false);
|
|
57495
|
-
scanner2.setText(s + "n");
|
|
57496
|
-
let result = scanner2.scan();
|
|
57497
|
-
const negative = result === 40 /* MinusToken */;
|
|
57498
|
-
if (negative) {
|
|
57499
|
-
result = scanner2.scan();
|
|
57500
|
-
}
|
|
57501
|
-
const flags = scanner2.getTokenFlags();
|
|
57502
|
-
return success && result === 9 /* BigIntLiteral */ && scanner2.getTextPos() === s.length + 1 && !(flags & 512 /* ContainsSeparator */) && (!roundTripOnly || s === pseudoBigIntToString({ negative, base10Value: parsePseudoBigInt(scanner2.getTokenValue()) }));
|
|
57549
|
+
return getBigIntLiteralType(parseValidBigInt(text));
|
|
57503
57550
|
}
|
|
57504
57551
|
function isMemberOfStringMapping(source, target) {
|
|
57505
57552
|
if (target.flags & (4 /* String */ | 1 /* Any */)) {
|
|
@@ -64971,11 +65018,11 @@ ${lanes.join("\n")}
|
|
|
64971
65018
|
}
|
|
64972
65019
|
function checkSatisfiesExpression(node) {
|
|
64973
65020
|
checkSourceElement(node.type);
|
|
65021
|
+
const exprType = checkExpression(node.expression);
|
|
64974
65022
|
const targetType = getTypeFromTypeNode(node.type);
|
|
64975
65023
|
if (isErrorType(targetType)) {
|
|
64976
65024
|
return targetType;
|
|
64977
65025
|
}
|
|
64978
|
-
const exprType = checkExpression(node.expression);
|
|
64979
65026
|
checkTypeAssignableToAndOptionallyElaborate(exprType, targetType, node.type, node.expression, Diagnostics.Type_0_does_not_satisfy_the_expected_type_1);
|
|
64980
65027
|
return exprType;
|
|
64981
65028
|
}
|
|
@@ -100157,16 +100204,15 @@ ${lanes.join("\n")}
|
|
|
100157
100204
|
return [];
|
|
100158
100205
|
}
|
|
100159
100206
|
const resolutions = [];
|
|
100160
|
-
const cache =
|
|
100207
|
+
const cache = createModeAwareCache();
|
|
100161
100208
|
for (const name of names) {
|
|
100162
100209
|
let result;
|
|
100163
100210
|
const mode = getModeForFileReference(name, containingFileMode);
|
|
100164
100211
|
const strName = getResolutionName(name);
|
|
100165
|
-
|
|
100166
|
-
|
|
100167
|
-
result = cache.get(cacheKey);
|
|
100212
|
+
if (cache.has(strName, mode)) {
|
|
100213
|
+
result = cache.get(strName, mode);
|
|
100168
100214
|
} else {
|
|
100169
|
-
cache.set(
|
|
100215
|
+
cache.set(strName, mode, result = loader(strName, containingFile, redirectedReference, mode));
|
|
100170
100216
|
}
|
|
100171
100217
|
resolutions.push(result);
|
|
100172
100218
|
}
|
|
@@ -100242,18 +100288,17 @@ ${lanes.join("\n")}
|
|
|
100242
100288
|
return [];
|
|
100243
100289
|
}
|
|
100244
100290
|
const resolutions = [];
|
|
100245
|
-
const cache =
|
|
100291
|
+
const cache = createModeAwareCache();
|
|
100246
100292
|
let i = 0;
|
|
100247
100293
|
for (const entry of resolutionInfo ? resolutionInfo.names : names) {
|
|
100248
100294
|
let result;
|
|
100249
100295
|
const mode = !isString(entry) ? getModeForUsageLocation(containingFile, entry) : getModeForResolutionAtIndex(containingFile, i);
|
|
100250
100296
|
i++;
|
|
100251
100297
|
const name = isString(entry) ? entry : entry.text;
|
|
100252
|
-
|
|
100253
|
-
|
|
100254
|
-
result = cache.get(cacheKey);
|
|
100298
|
+
if (cache.has(name, mode)) {
|
|
100299
|
+
result = cache.get(name, mode);
|
|
100255
100300
|
} else {
|
|
100256
|
-
cache.set(
|
|
100301
|
+
cache.set(name, mode, result = loader(name, mode, containingFileName, redirectedReference));
|
|
100257
100302
|
}
|
|
100258
100303
|
resolutions.push(result);
|
|
100259
100304
|
}
|
|
@@ -104829,23 +104874,17 @@ ${lanes.join("\n")}
|
|
|
104829
104874
|
const getCurrentDirectory = memoize(() => resolutionHost.getCurrentDirectory());
|
|
104830
104875
|
const cachedDirectoryStructureHost = resolutionHost.getCachedDirectoryStructureHost();
|
|
104831
104876
|
const resolvedModuleNames = /* @__PURE__ */ new Map();
|
|
104832
|
-
const perDirectoryResolvedModuleNames = createCacheWithRedirects();
|
|
104833
|
-
const nonRelativeModuleNameCache = createCacheWithRedirects();
|
|
104834
104877
|
const moduleResolutionCache = createModuleResolutionCache(
|
|
104835
104878
|
getCurrentDirectory(),
|
|
104836
104879
|
resolutionHost.getCanonicalFileName,
|
|
104837
|
-
|
|
104838
|
-
perDirectoryResolvedModuleNames,
|
|
104839
|
-
nonRelativeModuleNameCache
|
|
104880
|
+
resolutionHost.getCompilationSettings()
|
|
104840
104881
|
);
|
|
104841
104882
|
const resolvedTypeReferenceDirectives = /* @__PURE__ */ new Map();
|
|
104842
|
-
const perDirectoryResolvedTypeReferenceDirectives = createCacheWithRedirects();
|
|
104843
104883
|
const typeReferenceDirectiveResolutionCache = createTypeReferenceDirectiveResolutionCache(
|
|
104844
104884
|
getCurrentDirectory(),
|
|
104845
104885
|
resolutionHost.getCanonicalFileName,
|
|
104846
|
-
|
|
104847
|
-
moduleResolutionCache.getPackageJsonInfoCache()
|
|
104848
|
-
perDirectoryResolvedTypeReferenceDirectives
|
|
104886
|
+
resolutionHost.getCompilationSettings(),
|
|
104887
|
+
moduleResolutionCache.getPackageJsonInfoCache()
|
|
104849
104888
|
);
|
|
104850
104889
|
const failedLookupDefaultExtensions = [".ts" /* Ts */, ".tsx" /* Tsx */, ".js" /* Js */, ".jsx" /* Jsx */, ".json" /* Json */];
|
|
104851
104890
|
const customFailedLookupPaths = /* @__PURE__ */ new Map();
|
|
@@ -104906,6 +104945,8 @@ ${lanes.join("\n")}
|
|
|
104906
104945
|
affectingPathChecksForFile = void 0;
|
|
104907
104946
|
moduleResolutionCache.clear();
|
|
104908
104947
|
typeReferenceDirectiveResolutionCache.clear();
|
|
104948
|
+
moduleResolutionCache.update(resolutionHost.getCompilationSettings());
|
|
104949
|
+
typeReferenceDirectiveResolutionCache.update(resolutionHost.getCompilationSettings());
|
|
104909
104950
|
impliedFormatPackageJsons.clear();
|
|
104910
104951
|
hasChangedAutomaticTypeDirectiveNames = false;
|
|
104911
104952
|
}
|
|
@@ -105010,8 +105051,7 @@ ${lanes.join("\n")}
|
|
|
105010
105051
|
names,
|
|
105011
105052
|
containingFile,
|
|
105012
105053
|
redirectedReference,
|
|
105013
|
-
|
|
105014
|
-
perDirectoryCacheWithRedirects,
|
|
105054
|
+
perFileCache,
|
|
105015
105055
|
loader,
|
|
105016
105056
|
getResolutionWithResolvedFileName,
|
|
105017
105057
|
shouldRetryResolution,
|
|
@@ -105021,16 +105061,9 @@ ${lanes.join("\n")}
|
|
|
105021
105061
|
containingSourceFile,
|
|
105022
105062
|
containingSourceFileMode
|
|
105023
105063
|
}) {
|
|
105024
|
-
var _a2, _b, _c
|
|
105064
|
+
var _a2, _b, _c;
|
|
105025
105065
|
const path = resolutionHost.toPath(containingFile);
|
|
105026
|
-
const resolutionsInFile =
|
|
105027
|
-
const dirPath = getDirectoryPath(path);
|
|
105028
|
-
const perDirectoryCache = perDirectoryCacheWithRedirects.getOrCreateMapOfCacheRedirects(redirectedReference);
|
|
105029
|
-
let perDirectoryResolution = perDirectoryCache.get(dirPath);
|
|
105030
|
-
if (!perDirectoryResolution) {
|
|
105031
|
-
perDirectoryResolution = createModeAwareCache();
|
|
105032
|
-
perDirectoryCache.set(dirPath, perDirectoryResolution);
|
|
105033
|
-
}
|
|
105066
|
+
const resolutionsInFile = perFileCache.get(path) || perFileCache.set(path, createModeAwareCache()).get(path);
|
|
105034
105067
|
const resolvedModules = [];
|
|
105035
105068
|
const compilerOptions = resolutionHost.getCompilationSettings();
|
|
105036
105069
|
const hasInvalidatedNonRelativeUnresolvedImport = logChanges && isFileWithInvalidatedNonRelativeUnresolvedImports(path);
|
|
@@ -105046,28 +105079,9 @@ ${lanes.join("\n")}
|
|
|
105046
105079
|
let resolution = resolutionsInFile.get(name, mode);
|
|
105047
105080
|
if (!seenNamesInFile.has(name, mode) && unmatchedRedirects || !resolution || resolution.isInvalidated || hasInvalidatedNonRelativeUnresolvedImport && !isExternalModuleNameRelative(name) && shouldRetryResolution(resolution)) {
|
|
105048
105081
|
const existingResolution = resolution;
|
|
105049
|
-
|
|
105050
|
-
if (
|
|
105051
|
-
|
|
105052
|
-
const host = ((_a2 = resolutionHost.getCompilerHost) == null ? void 0 : _a2.call(resolutionHost)) || resolutionHost;
|
|
105053
|
-
if (isTraceEnabled(compilerOptions, host)) {
|
|
105054
|
-
const resolved = getResolutionWithResolvedFileName(resolution);
|
|
105055
|
-
trace(
|
|
105056
|
-
host,
|
|
105057
|
-
loader === resolveModuleName2 ? (resolved == null ? void 0 : resolved.resolvedFileName) ? resolved.packageId ? Diagnostics.Reusing_resolution_of_module_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_3_with_Package_ID_4 : Diagnostics.Reusing_resolution_of_module_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_3 : Diagnostics.Reusing_resolution_of_module_0_from_1_found_in_cache_from_location_2_it_was_not_resolved : (resolved == null ? void 0 : resolved.resolvedFileName) ? resolved.packageId ? Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_3_with_Package_ID_4 : Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_found_in_cache_from_location_2_it_was_successfully_resolved_to_3 : Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_found_in_cache_from_location_2_it_was_not_resolved,
|
|
105058
|
-
name,
|
|
105059
|
-
containingFile,
|
|
105060
|
-
getDirectoryPath(containingFile),
|
|
105061
|
-
resolved == null ? void 0 : resolved.resolvedFileName,
|
|
105062
|
-
(resolved == null ? void 0 : resolved.packageId) && packageIdToString(resolved.packageId)
|
|
105063
|
-
);
|
|
105064
|
-
}
|
|
105065
|
-
} else {
|
|
105066
|
-
resolution = loader(name, containingFile, compilerOptions, ((_b = resolutionHost.getCompilerHost) == null ? void 0 : _b.call(resolutionHost)) || resolutionHost, redirectedReference, containingSourceFile, mode);
|
|
105067
|
-
perDirectoryResolution.set(name, mode, resolution);
|
|
105068
|
-
if (resolutionHost.onDiscoveredSymlink && resolutionIsSymlink(resolution)) {
|
|
105069
|
-
resolutionHost.onDiscoveredSymlink();
|
|
105070
|
-
}
|
|
105082
|
+
resolution = loader(name, containingFile, compilerOptions, ((_a2 = resolutionHost.getCompilerHost) == null ? void 0 : _a2.call(resolutionHost)) || resolutionHost, redirectedReference, containingSourceFile, mode);
|
|
105083
|
+
if (resolutionHost.onDiscoveredSymlink && resolutionIsSymlink(resolution)) {
|
|
105084
|
+
resolutionHost.onDiscoveredSymlink();
|
|
105071
105085
|
}
|
|
105072
105086
|
resolutionsInFile.set(name, mode, resolution);
|
|
105073
105087
|
watchFailedLookupLocationsOfExternalModuleResolutions(name, resolution, path, getResolutionWithResolvedFileName);
|
|
@@ -105079,7 +105093,7 @@ ${lanes.join("\n")}
|
|
|
105079
105093
|
logChanges = false;
|
|
105080
105094
|
}
|
|
105081
105095
|
} else {
|
|
105082
|
-
const host = ((
|
|
105096
|
+
const host = ((_b = resolutionHost.getCompilerHost) == null ? void 0 : _b.call(resolutionHost)) || resolutionHost;
|
|
105083
105097
|
if (isTraceEnabled(compilerOptions, host) && !seenNamesInFile.has(name, mode)) {
|
|
105084
105098
|
const resolved = getResolutionWithResolvedFileName(resolution);
|
|
105085
105099
|
trace(
|
|
@@ -105097,7 +105111,7 @@ ${lanes.join("\n")}
|
|
|
105097
105111
|
resolvedModules.push(getResolutionWithResolvedFileName(resolution));
|
|
105098
105112
|
}
|
|
105099
105113
|
if (resolutionInfo && (loader === resolveTypeReferenceDirective2 || containingSourceFile)) {
|
|
105100
|
-
(
|
|
105114
|
+
(_c = resolutionInfo.reusedNames) == null ? void 0 : _c.forEach((entry) => seenNamesInFile.set(
|
|
105101
105115
|
getResolutionName(entry),
|
|
105102
105116
|
!isString(entry) && isStringLiteralLike(entry) ? getModeForUsageLocation(containingSourceFile, entry) : getModeForFileReference(entry, containingSourceFileMode),
|
|
105103
105117
|
true
|
|
@@ -105136,8 +105150,7 @@ ${lanes.join("\n")}
|
|
|
105136
105150
|
names: typeDirectiveNames,
|
|
105137
105151
|
containingFile,
|
|
105138
105152
|
redirectedReference,
|
|
105139
|
-
|
|
105140
|
-
perDirectoryCacheWithRedirects: perDirectoryResolvedTypeReferenceDirectives,
|
|
105153
|
+
perFileCache: resolvedTypeReferenceDirectives,
|
|
105141
105154
|
loader: resolveTypeReferenceDirective2,
|
|
105142
105155
|
getResolutionWithResolvedFileName: getResolvedTypeReferenceDirective2,
|
|
105143
105156
|
shouldRetryResolution: (resolution) => resolution.resolvedTypeReferenceDirective === void 0,
|
|
@@ -105150,8 +105163,7 @@ ${lanes.join("\n")}
|
|
|
105150
105163
|
names: moduleNames,
|
|
105151
105164
|
containingFile,
|
|
105152
105165
|
redirectedReference,
|
|
105153
|
-
|
|
105154
|
-
perDirectoryCacheWithRedirects: perDirectoryResolvedModuleNames,
|
|
105166
|
+
perFileCache: resolvedModuleNames,
|
|
105155
105167
|
loader: resolveModuleName2,
|
|
105156
105168
|
getResolutionWithResolvedFileName: getResolvedModule2,
|
|
105157
105169
|
shouldRetryResolution: (resolution) => !resolution.resolvedModule || !resolutionExtensionIsTSOrJson(resolution.resolvedModule.extension),
|
|
@@ -106535,7 +106547,7 @@ ${lanes.join("\n")}
|
|
|
106535
106547
|
if (hostSourceFile.version)
|
|
106536
106548
|
return hostSourceFile.version;
|
|
106537
106549
|
const text = readFileWithCache(path);
|
|
106538
|
-
return text ? getSourceFileVersionAsHashFromText(compilerHost, text) : void 0;
|
|
106550
|
+
return text !== void 0 ? getSourceFileVersionAsHashFromText(compilerHost, text) : void 0;
|
|
106539
106551
|
}
|
|
106540
106552
|
function onReleaseOldSourceFile(oldSourceFile, _oldOptions, hasSourceFileByPath) {
|
|
106541
106553
|
const hostSourceFileInfo = sourceFilesCache.get(oldSourceFile.resolvedPath);
|
|
@@ -108077,7 +108089,7 @@ ${lanes.join("\n")}
|
|
|
108077
108089
|
buildInfoVersionMap = getBuildInfoFileVersionMap(buildInfoProgram, buildInfoPath, host);
|
|
108078
108090
|
version2 = buildInfoVersionMap.get(toPath2(state, inputFile));
|
|
108079
108091
|
const text = version2 ? state.readFileWithCache(inputFile) : void 0;
|
|
108080
|
-
currentVersion = text
|
|
108092
|
+
currentVersion = text !== void 0 ? getSourceFileVersionAsHashFromText(host, text) : void 0;
|
|
108081
108093
|
if (version2 && version2 === currentVersion)
|
|
108082
108094
|
pseudoInputUpToDate = true;
|
|
108083
108095
|
}
|
|
@@ -113905,24 +113917,8 @@ ${lanes.join("\n")}
|
|
|
113905
113917
|
getKeyForCompilationSettings
|
|
113906
113918
|
};
|
|
113907
113919
|
}
|
|
113908
|
-
function compilerOptionValueToString(value) {
|
|
113909
|
-
var _a2;
|
|
113910
|
-
if (value === null || typeof value !== "object") {
|
|
113911
|
-
return "" + value;
|
|
113912
|
-
}
|
|
113913
|
-
if (isArray(value)) {
|
|
113914
|
-
return `[${(_a2 = map(value, (e) => compilerOptionValueToString(e))) == null ? void 0 : _a2.join(",")}]`;
|
|
113915
|
-
}
|
|
113916
|
-
let str = "{";
|
|
113917
|
-
for (const key in value) {
|
|
113918
|
-
if (hasProperty(value, key)) {
|
|
113919
|
-
str += `${key}: ${compilerOptionValueToString(value[key])}`;
|
|
113920
|
-
}
|
|
113921
|
-
}
|
|
113922
|
-
return str + "}";
|
|
113923
|
-
}
|
|
113924
113920
|
function getKeyForCompilationSettings(settings) {
|
|
113925
|
-
return
|
|
113921
|
+
return getKeyForCompilerOptions(settings, sourceFileAffectingCompilerOptions);
|
|
113926
113922
|
}
|
|
113927
113923
|
function getDocumentRegistryBucketKeyWithMode(key, mode) {
|
|
113928
113924
|
return mode ? `${key}|${mode}` : key;
|
|
@@ -116120,6 +116116,9 @@ ${lanes.join("\n")}
|
|
|
116120
116116
|
const textPos = scanner.getTextPos();
|
|
116121
116117
|
if (textPos <= end) {
|
|
116122
116118
|
if (token === 79 /* Identifier */) {
|
|
116119
|
+
if (hasTabstop(parent2)) {
|
|
116120
|
+
continue;
|
|
116121
|
+
}
|
|
116123
116122
|
Debug.fail(`Did not expect ${Debug.formatSyntaxKind(parent2.kind)} to have an Identifier in its trivia`);
|
|
116124
116123
|
}
|
|
116125
116124
|
nodes.push(createNode(token, pos, textPos, parent2));
|
|
@@ -129561,6 +129560,13 @@ ${lanes.join("\n")}
|
|
|
129561
129560
|
if (!isChecked) {
|
|
129562
129561
|
getJSCompletionEntries(sourceFile, location.pos, uniqueNames, getEmitScriptTarget(compilerOptions), entries);
|
|
129563
129562
|
}
|
|
129563
|
+
let caseBlock;
|
|
129564
|
+
if (preferences.includeCompletionsWithInsertText && contextToken && (caseBlock = findAncestor(contextToken, isCaseBlock))) {
|
|
129565
|
+
const cases = getExhaustiveCaseSnippets(caseBlock, sourceFile, preferences, compilerOptions, host, program, formatContext);
|
|
129566
|
+
if (cases) {
|
|
129567
|
+
entries.push(cases.entry);
|
|
129568
|
+
}
|
|
129569
|
+
}
|
|
129564
129570
|
return {
|
|
129565
129571
|
flags: completionData.flags,
|
|
129566
129572
|
isGlobalCompletion: isInSnippetScope,
|
|
@@ -129574,6 +129580,187 @@ ${lanes.join("\n")}
|
|
|
129574
129580
|
function isCheckedFile(sourceFile, compilerOptions) {
|
|
129575
129581
|
return !isSourceFileJS(sourceFile) || !!isCheckJsEnabledForFile(sourceFile, compilerOptions);
|
|
129576
129582
|
}
|
|
129583
|
+
function getExhaustiveCaseSnippets(caseBlock, sourceFile, preferences, options, host, program, formatContext) {
|
|
129584
|
+
const clauses = caseBlock.clauses;
|
|
129585
|
+
const checker = program.getTypeChecker();
|
|
129586
|
+
const switchType = checker.getTypeAtLocation(caseBlock.parent.expression);
|
|
129587
|
+
if (switchType && switchType.isUnion() && every(switchType.types, (type) => type.isLiteral())) {
|
|
129588
|
+
const tracker = newCaseClauseTracker(checker, clauses);
|
|
129589
|
+
const target = getEmitScriptTarget(options);
|
|
129590
|
+
const quotePreference = getQuotePreference(sourceFile, preferences);
|
|
129591
|
+
const importAdder = ts_codefix_exports.createImportAdder(sourceFile, program, preferences, host);
|
|
129592
|
+
const elements = [];
|
|
129593
|
+
for (const type of switchType.types) {
|
|
129594
|
+
if (type.flags & 1024 /* EnumLiteral */) {
|
|
129595
|
+
Debug.assert(type.symbol, "An enum member type should have a symbol");
|
|
129596
|
+
Debug.assert(type.symbol.parent, "An enum member type should have a parent symbol (the enum symbol)");
|
|
129597
|
+
const enumValue = type.symbol.valueDeclaration && checker.getConstantValue(type.symbol.valueDeclaration);
|
|
129598
|
+
if (enumValue !== void 0) {
|
|
129599
|
+
if (tracker.hasValue(enumValue)) {
|
|
129600
|
+
continue;
|
|
129601
|
+
}
|
|
129602
|
+
tracker.addValue(enumValue);
|
|
129603
|
+
}
|
|
129604
|
+
const typeNode = ts_codefix_exports.typeToAutoImportableTypeNode(checker, importAdder, type, caseBlock, target);
|
|
129605
|
+
if (!typeNode) {
|
|
129606
|
+
return void 0;
|
|
129607
|
+
}
|
|
129608
|
+
const expr = typeNodeToExpression(typeNode, target, quotePreference);
|
|
129609
|
+
if (!expr) {
|
|
129610
|
+
return void 0;
|
|
129611
|
+
}
|
|
129612
|
+
elements.push(expr);
|
|
129613
|
+
} else if (!tracker.hasValue(type.value)) {
|
|
129614
|
+
switch (typeof type.value) {
|
|
129615
|
+
case "object":
|
|
129616
|
+
elements.push(factory.createBigIntLiteral(type.value));
|
|
129617
|
+
break;
|
|
129618
|
+
case "number":
|
|
129619
|
+
elements.push(factory.createNumericLiteral(type.value));
|
|
129620
|
+
break;
|
|
129621
|
+
case "string":
|
|
129622
|
+
elements.push(factory.createStringLiteral(type.value));
|
|
129623
|
+
break;
|
|
129624
|
+
}
|
|
129625
|
+
}
|
|
129626
|
+
}
|
|
129627
|
+
if (elements.length === 0) {
|
|
129628
|
+
return void 0;
|
|
129629
|
+
}
|
|
129630
|
+
const newClauses = map(elements, (element) => factory.createCaseClause(element, []));
|
|
129631
|
+
const newLineChar = getNewLineCharacter(options, maybeBind(host, host.getNewLine));
|
|
129632
|
+
const printer = createSnippetPrinter({
|
|
129633
|
+
removeComments: true,
|
|
129634
|
+
module: options.module,
|
|
129635
|
+
target: options.target,
|
|
129636
|
+
newLine: getNewLineKind(newLineChar)
|
|
129637
|
+
});
|
|
129638
|
+
const printNode = formatContext ? (node) => printer.printAndFormatNode(4 /* Unspecified */, node, sourceFile, formatContext) : (node) => printer.printNode(4 /* Unspecified */, node, sourceFile);
|
|
129639
|
+
const insertText = map(newClauses, (clause, i) => {
|
|
129640
|
+
if (preferences.includeCompletionsWithSnippetText) {
|
|
129641
|
+
return `${printNode(clause)}$${i + 1}`;
|
|
129642
|
+
}
|
|
129643
|
+
return `${printNode(clause)}`;
|
|
129644
|
+
}).join(newLineChar);
|
|
129645
|
+
const firstClause = printer.printNode(4 /* Unspecified */, newClauses[0], sourceFile);
|
|
129646
|
+
return {
|
|
129647
|
+
entry: {
|
|
129648
|
+
name: `${firstClause} ...`,
|
|
129649
|
+
kind: "" /* unknown */,
|
|
129650
|
+
sortText: SortText.GlobalsOrKeywords,
|
|
129651
|
+
insertText,
|
|
129652
|
+
hasAction: importAdder.hasFixes() || void 0,
|
|
129653
|
+
source: "SwitchCases/" /* SwitchCases */,
|
|
129654
|
+
isSnippet: preferences.includeCompletionsWithSnippetText ? true : void 0
|
|
129655
|
+
},
|
|
129656
|
+
importAdder
|
|
129657
|
+
};
|
|
129658
|
+
}
|
|
129659
|
+
return void 0;
|
|
129660
|
+
}
|
|
129661
|
+
function newCaseClauseTracker(checker, clauses) {
|
|
129662
|
+
const existingStrings = /* @__PURE__ */ new Set();
|
|
129663
|
+
const existingNumbers = /* @__PURE__ */ new Set();
|
|
129664
|
+
const existingBigInts = /* @__PURE__ */ new Set();
|
|
129665
|
+
for (const clause of clauses) {
|
|
129666
|
+
if (!isDefaultClause(clause)) {
|
|
129667
|
+
if (isLiteralExpression(clause.expression)) {
|
|
129668
|
+
const expression = clause.expression;
|
|
129669
|
+
switch (expression.kind) {
|
|
129670
|
+
case 14 /* NoSubstitutionTemplateLiteral */:
|
|
129671
|
+
case 10 /* StringLiteral */:
|
|
129672
|
+
existingStrings.add(expression.text);
|
|
129673
|
+
break;
|
|
129674
|
+
case 8 /* NumericLiteral */:
|
|
129675
|
+
existingNumbers.add(parseInt(expression.text));
|
|
129676
|
+
break;
|
|
129677
|
+
case 9 /* BigIntLiteral */:
|
|
129678
|
+
const parsedBigInt = parseBigInt(endsWith(expression.text, "n") ? expression.text.slice(0, -1) : expression.text);
|
|
129679
|
+
if (parsedBigInt) {
|
|
129680
|
+
existingBigInts.add(pseudoBigIntToString(parsedBigInt));
|
|
129681
|
+
}
|
|
129682
|
+
break;
|
|
129683
|
+
}
|
|
129684
|
+
} else {
|
|
129685
|
+
const symbol = checker.getSymbolAtLocation(clause.expression);
|
|
129686
|
+
if (symbol && symbol.valueDeclaration && isEnumMember(symbol.valueDeclaration)) {
|
|
129687
|
+
const enumValue = checker.getConstantValue(symbol.valueDeclaration);
|
|
129688
|
+
if (enumValue !== void 0) {
|
|
129689
|
+
addValue(enumValue);
|
|
129690
|
+
}
|
|
129691
|
+
}
|
|
129692
|
+
}
|
|
129693
|
+
}
|
|
129694
|
+
}
|
|
129695
|
+
return {
|
|
129696
|
+
addValue,
|
|
129697
|
+
hasValue
|
|
129698
|
+
};
|
|
129699
|
+
function addValue(value) {
|
|
129700
|
+
switch (typeof value) {
|
|
129701
|
+
case "string":
|
|
129702
|
+
existingStrings.add(value);
|
|
129703
|
+
break;
|
|
129704
|
+
case "number":
|
|
129705
|
+
existingNumbers.add(value);
|
|
129706
|
+
}
|
|
129707
|
+
}
|
|
129708
|
+
function hasValue(value) {
|
|
129709
|
+
switch (typeof value) {
|
|
129710
|
+
case "string":
|
|
129711
|
+
return existingStrings.has(value);
|
|
129712
|
+
case "number":
|
|
129713
|
+
return existingNumbers.has(value);
|
|
129714
|
+
case "object":
|
|
129715
|
+
return existingBigInts.has(pseudoBigIntToString(value));
|
|
129716
|
+
}
|
|
129717
|
+
}
|
|
129718
|
+
}
|
|
129719
|
+
function typeNodeToExpression(typeNode, languageVersion, quotePreference) {
|
|
129720
|
+
switch (typeNode.kind) {
|
|
129721
|
+
case 180 /* TypeReference */:
|
|
129722
|
+
const typeName = typeNode.typeName;
|
|
129723
|
+
return entityNameToExpression(typeName, languageVersion, quotePreference);
|
|
129724
|
+
case 196 /* IndexedAccessType */:
|
|
129725
|
+
const objectExpression = typeNodeToExpression(typeNode.objectType, languageVersion, quotePreference);
|
|
129726
|
+
const indexExpression = typeNodeToExpression(typeNode.indexType, languageVersion, quotePreference);
|
|
129727
|
+
return objectExpression && indexExpression && factory.createElementAccessExpression(objectExpression, indexExpression);
|
|
129728
|
+
case 198 /* LiteralType */:
|
|
129729
|
+
const literal = typeNode.literal;
|
|
129730
|
+
switch (literal.kind) {
|
|
129731
|
+
case 10 /* StringLiteral */:
|
|
129732
|
+
return factory.createStringLiteral(literal.text, quotePreference === 0 /* Single */);
|
|
129733
|
+
case 8 /* NumericLiteral */:
|
|
129734
|
+
return factory.createNumericLiteral(literal.text, literal.numericLiteralFlags);
|
|
129735
|
+
}
|
|
129736
|
+
return void 0;
|
|
129737
|
+
case 193 /* ParenthesizedType */:
|
|
129738
|
+
const exp = typeNodeToExpression(typeNode.type, languageVersion, quotePreference);
|
|
129739
|
+
return exp && (isIdentifier(exp) ? exp : factory.createParenthesizedExpression(exp));
|
|
129740
|
+
case 183 /* TypeQuery */:
|
|
129741
|
+
return entityNameToExpression(typeNode.exprName, languageVersion, quotePreference);
|
|
129742
|
+
case 202 /* ImportType */:
|
|
129743
|
+
Debug.fail(`We should not get an import type after calling 'codefix.typeToAutoImportableTypeNode'.`);
|
|
129744
|
+
}
|
|
129745
|
+
return void 0;
|
|
129746
|
+
}
|
|
129747
|
+
function entityNameToExpression(entityName, languageVersion, quotePreference) {
|
|
129748
|
+
if (isIdentifier(entityName)) {
|
|
129749
|
+
return entityName;
|
|
129750
|
+
}
|
|
129751
|
+
const unescapedName = unescapeLeadingUnderscores(entityName.right.escapedText);
|
|
129752
|
+
if (canUsePropertyAccess(unescapedName, languageVersion)) {
|
|
129753
|
+
return factory.createPropertyAccessExpression(
|
|
129754
|
+
entityNameToExpression(entityName.left, languageVersion, quotePreference),
|
|
129755
|
+
unescapedName
|
|
129756
|
+
);
|
|
129757
|
+
} else {
|
|
129758
|
+
return factory.createElementAccessExpression(
|
|
129759
|
+
entityNameToExpression(entityName.left, languageVersion, quotePreference),
|
|
129760
|
+
factory.createStringLiteral(unescapedName, quotePreference === 0 /* Single */)
|
|
129761
|
+
);
|
|
129762
|
+
}
|
|
129763
|
+
}
|
|
129577
129764
|
function isMemberCompletionKind(kind) {
|
|
129578
129765
|
switch (kind) {
|
|
129579
129766
|
case CompletionKind.ObjectPropertyDeclaration:
|
|
@@ -129980,7 +130167,9 @@ ${lanes.join("\n")}
|
|
|
129980
130167
|
};
|
|
129981
130168
|
return {
|
|
129982
130169
|
printSnippetList,
|
|
129983
|
-
printAndFormatSnippetList
|
|
130170
|
+
printAndFormatSnippetList,
|
|
130171
|
+
printNode,
|
|
130172
|
+
printAndFormatNode
|
|
129984
130173
|
};
|
|
129985
130174
|
function escapingWrite(s, write) {
|
|
129986
130175
|
const escaped = escapeSnippetText(s);
|
|
@@ -130029,6 +130218,40 @@ ${lanes.join("\n")}
|
|
|
130029
130218
|
const allChanges = escapes ? stableSort(concatenate(changes, escapes), (a, b) => compareTextSpans(a.span, b.span)) : changes;
|
|
130030
130219
|
return ts_textChanges_exports.applyChanges(syntheticFile.text, allChanges);
|
|
130031
130220
|
}
|
|
130221
|
+
function printNode(hint, node, sourceFile) {
|
|
130222
|
+
const unescaped = printUnescapedNode(hint, node, sourceFile);
|
|
130223
|
+
return escapes ? ts_textChanges_exports.applyChanges(unescaped, escapes) : unescaped;
|
|
130224
|
+
}
|
|
130225
|
+
function printUnescapedNode(hint, node, sourceFile) {
|
|
130226
|
+
escapes = void 0;
|
|
130227
|
+
writer.clear();
|
|
130228
|
+
printer.writeNode(hint, node, sourceFile, writer);
|
|
130229
|
+
return writer.getText();
|
|
130230
|
+
}
|
|
130231
|
+
function printAndFormatNode(hint, node, sourceFile, formatContext) {
|
|
130232
|
+
const syntheticFile = {
|
|
130233
|
+
text: printUnescapedNode(
|
|
130234
|
+
hint,
|
|
130235
|
+
node,
|
|
130236
|
+
sourceFile
|
|
130237
|
+
),
|
|
130238
|
+
getLineAndCharacterOfPosition(pos) {
|
|
130239
|
+
return getLineAndCharacterOfPosition(this, pos);
|
|
130240
|
+
}
|
|
130241
|
+
};
|
|
130242
|
+
const formatOptions = getFormatCodeSettingsForWriting(formatContext, sourceFile);
|
|
130243
|
+
const nodeWithPos = ts_textChanges_exports.assignPositionsToNode(node);
|
|
130244
|
+
const changes = ts_formatting_exports.formatNodeGivenIndentation(
|
|
130245
|
+
nodeWithPos,
|
|
130246
|
+
syntheticFile,
|
|
130247
|
+
sourceFile.languageVariant,
|
|
130248
|
+
0,
|
|
130249
|
+
0,
|
|
130250
|
+
{ ...formatContext, options: formatOptions }
|
|
130251
|
+
);
|
|
130252
|
+
const allChanges = escapes ? stableSort(concatenate(changes, escapes), (a, b) => compareTextSpans(a.span, b.span)) : changes;
|
|
130253
|
+
return ts_textChanges_exports.applyChanges(syntheticFile.text, allChanges);
|
|
130254
|
+
}
|
|
130032
130255
|
}
|
|
130033
130256
|
function originToCompletionEntryData(origin) {
|
|
130034
130257
|
const ambientModuleName = origin.fileName ? void 0 : stripQuotes(origin.moduleSymbol.name);
|
|
@@ -130232,6 +130455,9 @@ ${lanes.join("\n")}
|
|
|
130232
130455
|
return entries;
|
|
130233
130456
|
}
|
|
130234
130457
|
function getSymbolCompletionFromEntryId(program, log, sourceFile, position, entryId, host, preferences) {
|
|
130458
|
+
if (entryId.source === "SwitchCases/" /* SwitchCases */) {
|
|
130459
|
+
return { type: "cases" };
|
|
130460
|
+
}
|
|
130235
130461
|
if (entryId.data) {
|
|
130236
130462
|
const autoImport = getAutoImportSymbolFromCompletionEntryData(entryId.name, entryId.data, program, host);
|
|
130237
130463
|
if (autoImport) {
|
|
@@ -130270,9 +130496,9 @@ ${lanes.join("\n")}
|
|
|
130270
130496
|
const typeChecker = program.getTypeChecker();
|
|
130271
130497
|
const compilerOptions = program.getCompilerOptions();
|
|
130272
130498
|
const { name, source, data } = entryId;
|
|
130273
|
-
const contextToken =
|
|
130274
|
-
if (isInString(sourceFile, position,
|
|
130275
|
-
return ts_Completions_StringCompletions_exports.getStringLiteralCompletionDetails(name, sourceFile, position,
|
|
130499
|
+
const { previousToken, contextToken } = getRelevantTokens(position, sourceFile);
|
|
130500
|
+
if (isInString(sourceFile, position, previousToken)) {
|
|
130501
|
+
return ts_Completions_StringCompletions_exports.getStringLiteralCompletionDetails(name, sourceFile, position, previousToken, typeChecker, compilerOptions, host, cancellationToken, preferences);
|
|
130276
130502
|
}
|
|
130277
130503
|
const symbolCompletion = getSymbolCompletionFromEntryId(program, log, sourceFile, position, entryId, host, preferences);
|
|
130278
130504
|
switch (symbolCompletion.type) {
|
|
@@ -130292,14 +130518,49 @@ ${lanes.join("\n")}
|
|
|
130292
130518
|
}
|
|
130293
130519
|
}
|
|
130294
130520
|
case "symbol": {
|
|
130295
|
-
const { symbol, location, contextToken: contextToken2, origin, previousToken } = symbolCompletion;
|
|
130296
|
-
const { codeActions, sourceDisplay } = getCompletionEntryCodeActionsAndSourceDisplay(name, location, contextToken2, origin, symbol, program, host, compilerOptions, sourceFile, position,
|
|
130521
|
+
const { symbol, location, contextToken: contextToken2, origin, previousToken: previousToken2 } = symbolCompletion;
|
|
130522
|
+
const { codeActions, sourceDisplay } = getCompletionEntryCodeActionsAndSourceDisplay(name, location, contextToken2, origin, symbol, program, host, compilerOptions, sourceFile, position, previousToken2, formatContext, preferences, data, source, cancellationToken);
|
|
130297
130523
|
return createCompletionDetailsForSymbol(symbol, typeChecker, sourceFile, location, cancellationToken, codeActions, sourceDisplay);
|
|
130298
130524
|
}
|
|
130299
130525
|
case "literal": {
|
|
130300
130526
|
const { literal } = symbolCompletion;
|
|
130301
130527
|
return createSimpleDetails(completionNameForLiteral(sourceFile, preferences, literal), "string" /* string */, typeof literal === "string" ? 8 /* stringLiteral */ : 7 /* numericLiteral */);
|
|
130302
130528
|
}
|
|
130529
|
+
case "cases": {
|
|
130530
|
+
const { entry, importAdder } = getExhaustiveCaseSnippets(
|
|
130531
|
+
contextToken.parent,
|
|
130532
|
+
sourceFile,
|
|
130533
|
+
preferences,
|
|
130534
|
+
program.getCompilerOptions(),
|
|
130535
|
+
host,
|
|
130536
|
+
program,
|
|
130537
|
+
void 0
|
|
130538
|
+
);
|
|
130539
|
+
if (importAdder.hasFixes()) {
|
|
130540
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(
|
|
130541
|
+
{ host, formatContext, preferences },
|
|
130542
|
+
importAdder.writeFixes
|
|
130543
|
+
);
|
|
130544
|
+
return {
|
|
130545
|
+
name: entry.name,
|
|
130546
|
+
kind: "" /* unknown */,
|
|
130547
|
+
kindModifiers: "",
|
|
130548
|
+
displayParts: [],
|
|
130549
|
+
sourceDisplay: void 0,
|
|
130550
|
+
codeActions: [{
|
|
130551
|
+
changes,
|
|
130552
|
+
description: diagnosticToString([Diagnostics.Includes_imports_of_types_referenced_by_0, name])
|
|
130553
|
+
}]
|
|
130554
|
+
};
|
|
130555
|
+
}
|
|
130556
|
+
return {
|
|
130557
|
+
name: entry.name,
|
|
130558
|
+
kind: "" /* unknown */,
|
|
130559
|
+
kindModifiers: "",
|
|
130560
|
+
displayParts: [],
|
|
130561
|
+
sourceDisplay: void 0
|
|
130562
|
+
};
|
|
130563
|
+
}
|
|
130303
130564
|
case "none":
|
|
130304
130565
|
return allKeywordsCompletions().some((c) => c.name === name) ? createSimpleDetails(name, "keyword" /* keyword */, 5 /* keyword */) : void 0;
|
|
130305
130566
|
default:
|
|
@@ -132186,6 +132447,7 @@ ${lanes.join("\n")}
|
|
|
132186
132447
|
CompletionSource2["ClassMemberSnippet"] = "ClassMemberSnippet/";
|
|
132187
132448
|
CompletionSource2["TypeOnlyAlias"] = "TypeOnlyAlias/";
|
|
132188
132449
|
CompletionSource2["ObjectLiteralMethodSnippet"] = "ObjectLiteralMethodSnippet/";
|
|
132450
|
+
CompletionSource2["SwitchCases"] = "SwitchCases/";
|
|
132189
132451
|
return CompletionSource2;
|
|
132190
132452
|
})(CompletionSource || {});
|
|
132191
132453
|
SymbolOriginInfoKind = /* @__PURE__ */ ((SymbolOriginInfoKind2) => {
|
|
@@ -137500,12 +137762,14 @@ ${lanes.join("\n")}
|
|
|
137500
137762
|
if (!selection || !isTypeNode(selection))
|
|
137501
137763
|
return { error: getLocaleSpecificMessage(Diagnostics.Selection_is_not_a_valid_type_node) };
|
|
137502
137764
|
const checker = context.program.getTypeChecker();
|
|
137503
|
-
const
|
|
137504
|
-
|
|
137765
|
+
const enclosingNode = getEnclosingNode(selection, isJS);
|
|
137766
|
+
if (enclosingNode === void 0)
|
|
137767
|
+
return { error: getLocaleSpecificMessage(Diagnostics.No_type_could_be_extracted_from_this_type_node) };
|
|
137768
|
+
const typeParameters = collectTypeParameters(checker, selection, enclosingNode, file);
|
|
137505
137769
|
if (!typeParameters)
|
|
137506
137770
|
return { error: getLocaleSpecificMessage(Diagnostics.No_type_could_be_extracted_from_this_type_node) };
|
|
137507
137771
|
const typeElements = flattenTypeLiteralNodeReference(checker, selection);
|
|
137508
|
-
return { isJS, selection,
|
|
137772
|
+
return { isJS, selection, enclosingNode, typeParameters, typeElements };
|
|
137509
137773
|
}
|
|
137510
137774
|
function flattenTypeLiteralNodeReference(checker, node) {
|
|
137511
137775
|
if (!node)
|
|
@@ -137531,7 +137795,7 @@ ${lanes.join("\n")}
|
|
|
137531
137795
|
function rangeContainsSkipTrivia(r1, node, file) {
|
|
137532
137796
|
return rangeContainsStartEnd(r1, skipTrivia(file.text, node.pos), node.end);
|
|
137533
137797
|
}
|
|
137534
|
-
function collectTypeParameters(checker, selection,
|
|
137798
|
+
function collectTypeParameters(checker, selection, enclosingNode, file) {
|
|
137535
137799
|
const result = [];
|
|
137536
137800
|
return visitor(selection) ? void 0 : result;
|
|
137537
137801
|
function visitor(node) {
|
|
@@ -137544,7 +137808,7 @@ ${lanes.join("\n")}
|
|
|
137544
137808
|
if (decl.name.escapedText === typeName.escapedText && rangeContainsSkipTrivia(decl, selection, file)) {
|
|
137545
137809
|
return true;
|
|
137546
137810
|
}
|
|
137547
|
-
if (rangeContainsSkipTrivia(
|
|
137811
|
+
if (rangeContainsSkipTrivia(enclosingNode, decl, file) && !rangeContainsSkipTrivia(selection, decl, file)) {
|
|
137548
137812
|
pushIfUnique(result, decl);
|
|
137549
137813
|
break;
|
|
137550
137814
|
}
|
|
@@ -137564,7 +137828,7 @@ ${lanes.join("\n")}
|
|
|
137564
137828
|
} else if (isTypeQueryNode(node)) {
|
|
137565
137829
|
if (isIdentifier(node.exprName)) {
|
|
137566
137830
|
const symbol = checker.resolveName(node.exprName.text, node.exprName, 111551 /* Value */, false);
|
|
137567
|
-
if ((symbol == null ? void 0 : symbol.valueDeclaration) && rangeContainsSkipTrivia(
|
|
137831
|
+
if ((symbol == null ? void 0 : symbol.valueDeclaration) && rangeContainsSkipTrivia(enclosingNode, symbol.valueDeclaration, file) && !rangeContainsSkipTrivia(selection, symbol.valueDeclaration, file)) {
|
|
137568
137832
|
return true;
|
|
137569
137833
|
}
|
|
137570
137834
|
} else {
|
|
@@ -137580,19 +137844,19 @@ ${lanes.join("\n")}
|
|
|
137580
137844
|
}
|
|
137581
137845
|
}
|
|
137582
137846
|
function doTypeAliasChange(changes, file, name, info) {
|
|
137583
|
-
const {
|
|
137847
|
+
const { enclosingNode, selection, typeParameters } = info;
|
|
137584
137848
|
const newTypeNode = factory.createTypeAliasDeclaration(
|
|
137585
137849
|
void 0,
|
|
137586
137850
|
name,
|
|
137587
137851
|
typeParameters.map((id) => factory.updateTypeParameterDeclaration(id, id.modifiers, id.name, id.constraint, void 0)),
|
|
137588
137852
|
selection
|
|
137589
137853
|
);
|
|
137590
|
-
changes.insertNodeBefore(file,
|
|
137854
|
+
changes.insertNodeBefore(file, enclosingNode, ignoreSourceNewlines(newTypeNode), true);
|
|
137591
137855
|
changes.replaceNode(file, selection, factory.createTypeReferenceNode(name, typeParameters.map((id) => factory.createTypeReferenceNode(id.name, void 0))), { leadingTriviaOption: ts_textChanges_exports.LeadingTriviaOption.Exclude, trailingTriviaOption: ts_textChanges_exports.TrailingTriviaOption.ExcludeWhitespace });
|
|
137592
137856
|
}
|
|
137593
137857
|
function doInterfaceChange(changes, file, name, info) {
|
|
137594
137858
|
var _a2;
|
|
137595
|
-
const {
|
|
137859
|
+
const { enclosingNode, selection, typeParameters, typeElements } = info;
|
|
137596
137860
|
const newTypeNode = factory.createInterfaceDeclaration(
|
|
137597
137861
|
void 0,
|
|
137598
137862
|
name,
|
|
@@ -137601,11 +137865,11 @@ ${lanes.join("\n")}
|
|
|
137601
137865
|
typeElements
|
|
137602
137866
|
);
|
|
137603
137867
|
setTextRange(newTypeNode, (_a2 = typeElements[0]) == null ? void 0 : _a2.parent);
|
|
137604
|
-
changes.insertNodeBefore(file,
|
|
137868
|
+
changes.insertNodeBefore(file, enclosingNode, ignoreSourceNewlines(newTypeNode), true);
|
|
137605
137869
|
changes.replaceNode(file, selection, factory.createTypeReferenceNode(name, typeParameters.map((id) => factory.createTypeReferenceNode(id.name, void 0))), { leadingTriviaOption: ts_textChanges_exports.LeadingTriviaOption.Exclude, trailingTriviaOption: ts_textChanges_exports.TrailingTriviaOption.ExcludeWhitespace });
|
|
137606
137870
|
}
|
|
137607
|
-
function doTypedefChange(changes, file, name, info) {
|
|
137608
|
-
const {
|
|
137871
|
+
function doTypedefChange(changes, program, file, name, info) {
|
|
137872
|
+
const { enclosingNode, selection, typeParameters } = info;
|
|
137609
137873
|
setEmitFlags(selection, 3072 /* NoComments */ | 4096 /* NoNestedComments */);
|
|
137610
137874
|
const node = factory.createJSDocTypedefTag(
|
|
137611
137875
|
factory.createIdentifier("typedef"),
|
|
@@ -137623,9 +137887,21 @@ ${lanes.join("\n")}
|
|
|
137623
137887
|
);
|
|
137624
137888
|
templates.push(template);
|
|
137625
137889
|
});
|
|
137626
|
-
|
|
137890
|
+
const jsDoc = factory.createJSDocComment(void 0, factory.createNodeArray(concatenate(templates, [node])));
|
|
137891
|
+
if (isJSDoc(enclosingNode)) {
|
|
137892
|
+
const pos = enclosingNode.getStart(file);
|
|
137893
|
+
const newLineCharacter = getNewLineCharacter(program.getCompilerOptions());
|
|
137894
|
+
changes.insertNodeAt(file, enclosingNode.getStart(file), jsDoc, {
|
|
137895
|
+
suffix: newLineCharacter + newLineCharacter + file.text.slice(getPrecedingNonSpaceCharacterPosition(file.text, pos - 1), pos)
|
|
137896
|
+
});
|
|
137897
|
+
} else {
|
|
137898
|
+
changes.insertNodeBefore(file, enclosingNode, jsDoc, true);
|
|
137899
|
+
}
|
|
137627
137900
|
changes.replaceNode(file, selection, factory.createTypeReferenceNode(name, typeParameters.map((id) => factory.createTypeReferenceNode(id.name, void 0))));
|
|
137628
137901
|
}
|
|
137902
|
+
function getEnclosingNode(node, isJS) {
|
|
137903
|
+
return findAncestor(node, isStatement) || (isJS ? findAncestor(node, isJSDoc) : void 0);
|
|
137904
|
+
}
|
|
137629
137905
|
var refactorName3, extractToTypeAliasAction, extractToInterfaceAction, extractToTypeDefAction;
|
|
137630
137906
|
var init_extractType = __esm({
|
|
137631
137907
|
"src/services/refactors/extractType.ts"() {
|
|
@@ -137679,7 +137955,7 @@ ${lanes.join("\n")}
|
|
|
137679
137955
|
return emptyArray;
|
|
137680
137956
|
},
|
|
137681
137957
|
getEditsForAction: function getRefactorEditsToExtractType(context, actionName2) {
|
|
137682
|
-
const { file } = context;
|
|
137958
|
+
const { file, program } = context;
|
|
137683
137959
|
const info = getRangeToExtract(context);
|
|
137684
137960
|
Debug.assert(info && !isRefactorErrorInfo(info), "Expected to find a range to extract");
|
|
137685
137961
|
const name = getUniqueName("NewType", file);
|
|
@@ -137690,7 +137966,7 @@ ${lanes.join("\n")}
|
|
|
137690
137966
|
return doTypeAliasChange(changes, file, name, info);
|
|
137691
137967
|
case extractToTypeDefAction.name:
|
|
137692
137968
|
Debug.assert(info.isJS, "Invalid actionName/JS combo");
|
|
137693
|
-
return doTypedefChange(changes, file, name, info);
|
|
137969
|
+
return doTypedefChange(changes, program, file, name, info);
|
|
137694
137970
|
case extractToInterfaceAction.name:
|
|
137695
137971
|
Debug.assert(!info.isJS && !!info.typeElements, "Invalid actionName/JS combo");
|
|
137696
137972
|
return doInterfaceChange(changes, file, name, info);
|
|
@@ -158086,6 +158362,7 @@ ${e.message}`;
|
|
|
158086
158362
|
canHaveModifiers: () => canHaveModifiers,
|
|
158087
158363
|
canJsonReportNoInputFiles: () => canJsonReportNoInputFiles,
|
|
158088
158364
|
canProduceDiagnostics: () => canProduceDiagnostics,
|
|
158365
|
+
canUsePropertyAccess: () => canUsePropertyAccess,
|
|
158089
158366
|
canWatchDirectoryOrFile: () => canWatchDirectoryOrFile,
|
|
158090
158367
|
cartesianProduct: () => cartesianProduct,
|
|
158091
158368
|
cast: () => cast,
|
|
@@ -158362,6 +158639,7 @@ ${e.message}`;
|
|
|
158362
158639
|
createMethod: () => createMethod,
|
|
158363
158640
|
createMethodSignature: () => createMethodSignature,
|
|
158364
158641
|
createModeAwareCache: () => createModeAwareCache,
|
|
158642
|
+
createModeAwareCacheKey: () => createModeAwareCacheKey,
|
|
158365
158643
|
createModifier: () => createModifier,
|
|
158366
158644
|
createModifiersFromModifierFlags: () => createModifiersFromModifierFlags,
|
|
158367
158645
|
createModuleBlock: () => createModuleBlock,
|
|
@@ -158841,6 +159119,7 @@ ${e.message}`;
|
|
|
158841
159119
|
getJSXImplicitImportBase: () => getJSXImplicitImportBase,
|
|
158842
159120
|
getJSXRuntimeImport: () => getJSXRuntimeImport,
|
|
158843
159121
|
getJSXTransformEnabled: () => getJSXTransformEnabled,
|
|
159122
|
+
getKeyForCompilerOptions: () => getKeyForCompilerOptions,
|
|
158844
159123
|
getLanguageVariant: () => getLanguageVariant,
|
|
158845
159124
|
getLastChild: () => getLastChild,
|
|
158846
159125
|
getLeadingCommentRanges: () => getLeadingCommentRanges,
|
|
@@ -159112,6 +159391,7 @@ ${e.message}`;
|
|
|
159112
159391
|
hasSyntacticModifier: () => hasSyntacticModifier,
|
|
159113
159392
|
hasSyntacticModifiers: () => hasSyntacticModifiers,
|
|
159114
159393
|
hasTSFileExtension: () => hasTSFileExtension,
|
|
159394
|
+
hasTabstop: () => hasTabstop,
|
|
159115
159395
|
hasTrailingDirectorySeparator: () => hasTrailingDirectorySeparator,
|
|
159116
159396
|
hasType: () => hasType,
|
|
159117
159397
|
hasTypeArguments: () => hasTypeArguments,
|
|
@@ -159761,6 +160041,7 @@ ${e.message}`;
|
|
|
159761
160041
|
isUnparsedSource: () => isUnparsedSource,
|
|
159762
160042
|
isUnparsedTextLike: () => isUnparsedTextLike,
|
|
159763
160043
|
isUrl: () => isUrl,
|
|
160044
|
+
isValidBigIntString: () => isValidBigIntString,
|
|
159764
160045
|
isValidESSymbolDeclaration: () => isValidESSymbolDeclaration,
|
|
159765
160046
|
isValidTypeOnlyAliasUseSite: () => isValidTypeOnlyAliasUseSite,
|
|
159766
160047
|
isValueSignatureDeclaration: () => isValueSignatureDeclaration,
|
|
@@ -159892,6 +160173,7 @@ ${e.message}`;
|
|
|
159892
160173
|
parameterIsThisKeyword: () => parameterIsThisKeyword,
|
|
159893
160174
|
parameterNamePart: () => parameterNamePart,
|
|
159894
160175
|
parseBaseNodeFactory: () => parseBaseNodeFactory,
|
|
160176
|
+
parseBigInt: () => parseBigInt,
|
|
159895
160177
|
parseBuildCommand: () => parseBuildCommand,
|
|
159896
160178
|
parseCommandLine: () => parseCommandLine,
|
|
159897
160179
|
parseCommandLineWorker: () => parseCommandLineWorker,
|
|
@@ -159910,6 +160192,7 @@ ${e.message}`;
|
|
|
159910
160192
|
parseNodeModuleFromPath: () => parseNodeModuleFromPath,
|
|
159911
160193
|
parsePackageName: () => parsePackageName,
|
|
159912
160194
|
parsePseudoBigInt: () => parsePseudoBigInt,
|
|
160195
|
+
parseValidBigInt: () => parseValidBigInt,
|
|
159913
160196
|
patchWriteFileEnsuringDirectory: () => patchWriteFileEnsuringDirectory,
|
|
159914
160197
|
pathContainsNodeModules: () => pathContainsNodeModules,
|
|
159915
160198
|
pathIsAbsolute: () => pathIsAbsolute,
|
|
@@ -160701,6 +160984,7 @@ ${e.message}`;
|
|
|
160701
160984
|
canHaveModifiers: () => canHaveModifiers,
|
|
160702
160985
|
canJsonReportNoInputFiles: () => canJsonReportNoInputFiles,
|
|
160703
160986
|
canProduceDiagnostics: () => canProduceDiagnostics,
|
|
160987
|
+
canUsePropertyAccess: () => canUsePropertyAccess,
|
|
160704
160988
|
canWatchDirectoryOrFile: () => canWatchDirectoryOrFile,
|
|
160705
160989
|
cartesianProduct: () => cartesianProduct,
|
|
160706
160990
|
cast: () => cast,
|
|
@@ -160977,6 +161261,7 @@ ${e.message}`;
|
|
|
160977
161261
|
createMethod: () => createMethod,
|
|
160978
161262
|
createMethodSignature: () => createMethodSignature,
|
|
160979
161263
|
createModeAwareCache: () => createModeAwareCache,
|
|
161264
|
+
createModeAwareCacheKey: () => createModeAwareCacheKey,
|
|
160980
161265
|
createModifier: () => createModifier,
|
|
160981
161266
|
createModifiersFromModifierFlags: () => createModifiersFromModifierFlags,
|
|
160982
161267
|
createModuleBlock: () => createModuleBlock,
|
|
@@ -161456,6 +161741,7 @@ ${e.message}`;
|
|
|
161456
161741
|
getJSXImplicitImportBase: () => getJSXImplicitImportBase,
|
|
161457
161742
|
getJSXRuntimeImport: () => getJSXRuntimeImport,
|
|
161458
161743
|
getJSXTransformEnabled: () => getJSXTransformEnabled,
|
|
161744
|
+
getKeyForCompilerOptions: () => getKeyForCompilerOptions,
|
|
161459
161745
|
getLanguageVariant: () => getLanguageVariant,
|
|
161460
161746
|
getLastChild: () => getLastChild,
|
|
161461
161747
|
getLeadingCommentRanges: () => getLeadingCommentRanges,
|
|
@@ -161727,6 +162013,7 @@ ${e.message}`;
|
|
|
161727
162013
|
hasSyntacticModifier: () => hasSyntacticModifier,
|
|
161728
162014
|
hasSyntacticModifiers: () => hasSyntacticModifiers,
|
|
161729
162015
|
hasTSFileExtension: () => hasTSFileExtension,
|
|
162016
|
+
hasTabstop: () => hasTabstop,
|
|
161730
162017
|
hasTrailingDirectorySeparator: () => hasTrailingDirectorySeparator,
|
|
161731
162018
|
hasType: () => hasType,
|
|
161732
162019
|
hasTypeArguments: () => hasTypeArguments,
|
|
@@ -162376,6 +162663,7 @@ ${e.message}`;
|
|
|
162376
162663
|
isUnparsedSource: () => isUnparsedSource,
|
|
162377
162664
|
isUnparsedTextLike: () => isUnparsedTextLike,
|
|
162378
162665
|
isUrl: () => isUrl,
|
|
162666
|
+
isValidBigIntString: () => isValidBigIntString,
|
|
162379
162667
|
isValidESSymbolDeclaration: () => isValidESSymbolDeclaration,
|
|
162380
162668
|
isValidTypeOnlyAliasUseSite: () => isValidTypeOnlyAliasUseSite,
|
|
162381
162669
|
isValueSignatureDeclaration: () => isValueSignatureDeclaration,
|
|
@@ -162507,6 +162795,7 @@ ${e.message}`;
|
|
|
162507
162795
|
parameterIsThisKeyword: () => parameterIsThisKeyword,
|
|
162508
162796
|
parameterNamePart: () => parameterNamePart,
|
|
162509
162797
|
parseBaseNodeFactory: () => parseBaseNodeFactory,
|
|
162798
|
+
parseBigInt: () => parseBigInt,
|
|
162510
162799
|
parseBuildCommand: () => parseBuildCommand,
|
|
162511
162800
|
parseCommandLine: () => parseCommandLine,
|
|
162512
162801
|
parseCommandLineWorker: () => parseCommandLineWorker,
|
|
@@ -162525,6 +162814,7 @@ ${e.message}`;
|
|
|
162525
162814
|
parseNodeModuleFromPath: () => parseNodeModuleFromPath,
|
|
162526
162815
|
parsePackageName: () => parsePackageName,
|
|
162527
162816
|
parsePseudoBigInt: () => parsePseudoBigInt,
|
|
162817
|
+
parseValidBigInt: () => parseValidBigInt,
|
|
162528
162818
|
patchWriteFileEnsuringDirectory: () => patchWriteFileEnsuringDirectory,
|
|
162529
162819
|
pathContainsNodeModules: () => pathContainsNodeModules,
|
|
162530
162820
|
pathIsAbsolute: () => pathIsAbsolute,
|