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/typescript.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
|
}
|
|
@@ -113919,24 +113931,8 @@ ${lanes.join("\n")}
|
|
|
113919
113931
|
getKeyForCompilationSettings
|
|
113920
113932
|
};
|
|
113921
113933
|
}
|
|
113922
|
-
function compilerOptionValueToString(value) {
|
|
113923
|
-
var _a2;
|
|
113924
|
-
if (value === null || typeof value !== "object") {
|
|
113925
|
-
return "" + value;
|
|
113926
|
-
}
|
|
113927
|
-
if (isArray(value)) {
|
|
113928
|
-
return `[${(_a2 = map(value, (e) => compilerOptionValueToString(e))) == null ? void 0 : _a2.join(",")}]`;
|
|
113929
|
-
}
|
|
113930
|
-
let str = "{";
|
|
113931
|
-
for (const key in value) {
|
|
113932
|
-
if (hasProperty(value, key)) {
|
|
113933
|
-
str += `${key}: ${compilerOptionValueToString(value[key])}`;
|
|
113934
|
-
}
|
|
113935
|
-
}
|
|
113936
|
-
return str + "}";
|
|
113937
|
-
}
|
|
113938
113934
|
function getKeyForCompilationSettings(settings) {
|
|
113939
|
-
return
|
|
113935
|
+
return getKeyForCompilerOptions(settings, sourceFileAffectingCompilerOptions);
|
|
113940
113936
|
}
|
|
113941
113937
|
function getDocumentRegistryBucketKeyWithMode(key, mode) {
|
|
113942
113938
|
return mode ? `${key}|${mode}` : key;
|
|
@@ -116134,6 +116130,9 @@ ${lanes.join("\n")}
|
|
|
116134
116130
|
const textPos = scanner.getTextPos();
|
|
116135
116131
|
if (textPos <= end) {
|
|
116136
116132
|
if (token === 79 /* Identifier */) {
|
|
116133
|
+
if (hasTabstop(parent2)) {
|
|
116134
|
+
continue;
|
|
116135
|
+
}
|
|
116137
116136
|
Debug.fail(`Did not expect ${Debug.formatSyntaxKind(parent2.kind)} to have an Identifier in its trivia`);
|
|
116138
116137
|
}
|
|
116139
116138
|
nodes.push(createNode(token, pos, textPos, parent2));
|
|
@@ -129575,6 +129574,13 @@ ${lanes.join("\n")}
|
|
|
129575
129574
|
if (!isChecked) {
|
|
129576
129575
|
getJSCompletionEntries(sourceFile, location.pos, uniqueNames, getEmitScriptTarget(compilerOptions), entries);
|
|
129577
129576
|
}
|
|
129577
|
+
let caseBlock;
|
|
129578
|
+
if (preferences.includeCompletionsWithInsertText && contextToken && (caseBlock = findAncestor(contextToken, isCaseBlock))) {
|
|
129579
|
+
const cases = getExhaustiveCaseSnippets(caseBlock, sourceFile, preferences, compilerOptions, host, program, formatContext);
|
|
129580
|
+
if (cases) {
|
|
129581
|
+
entries.push(cases.entry);
|
|
129582
|
+
}
|
|
129583
|
+
}
|
|
129578
129584
|
return {
|
|
129579
129585
|
flags: completionData.flags,
|
|
129580
129586
|
isGlobalCompletion: isInSnippetScope,
|
|
@@ -129588,6 +129594,187 @@ ${lanes.join("\n")}
|
|
|
129588
129594
|
function isCheckedFile(sourceFile, compilerOptions) {
|
|
129589
129595
|
return !isSourceFileJS(sourceFile) || !!isCheckJsEnabledForFile(sourceFile, compilerOptions);
|
|
129590
129596
|
}
|
|
129597
|
+
function getExhaustiveCaseSnippets(caseBlock, sourceFile, preferences, options, host, program, formatContext) {
|
|
129598
|
+
const clauses = caseBlock.clauses;
|
|
129599
|
+
const checker = program.getTypeChecker();
|
|
129600
|
+
const switchType = checker.getTypeAtLocation(caseBlock.parent.expression);
|
|
129601
|
+
if (switchType && switchType.isUnion() && every(switchType.types, (type) => type.isLiteral())) {
|
|
129602
|
+
const tracker = newCaseClauseTracker(checker, clauses);
|
|
129603
|
+
const target = getEmitScriptTarget(options);
|
|
129604
|
+
const quotePreference = getQuotePreference(sourceFile, preferences);
|
|
129605
|
+
const importAdder = ts_codefix_exports.createImportAdder(sourceFile, program, preferences, host);
|
|
129606
|
+
const elements = [];
|
|
129607
|
+
for (const type of switchType.types) {
|
|
129608
|
+
if (type.flags & 1024 /* EnumLiteral */) {
|
|
129609
|
+
Debug.assert(type.symbol, "An enum member type should have a symbol");
|
|
129610
|
+
Debug.assert(type.symbol.parent, "An enum member type should have a parent symbol (the enum symbol)");
|
|
129611
|
+
const enumValue = type.symbol.valueDeclaration && checker.getConstantValue(type.symbol.valueDeclaration);
|
|
129612
|
+
if (enumValue !== void 0) {
|
|
129613
|
+
if (tracker.hasValue(enumValue)) {
|
|
129614
|
+
continue;
|
|
129615
|
+
}
|
|
129616
|
+
tracker.addValue(enumValue);
|
|
129617
|
+
}
|
|
129618
|
+
const typeNode = ts_codefix_exports.typeToAutoImportableTypeNode(checker, importAdder, type, caseBlock, target);
|
|
129619
|
+
if (!typeNode) {
|
|
129620
|
+
return void 0;
|
|
129621
|
+
}
|
|
129622
|
+
const expr = typeNodeToExpression(typeNode, target, quotePreference);
|
|
129623
|
+
if (!expr) {
|
|
129624
|
+
return void 0;
|
|
129625
|
+
}
|
|
129626
|
+
elements.push(expr);
|
|
129627
|
+
} else if (!tracker.hasValue(type.value)) {
|
|
129628
|
+
switch (typeof type.value) {
|
|
129629
|
+
case "object":
|
|
129630
|
+
elements.push(factory.createBigIntLiteral(type.value));
|
|
129631
|
+
break;
|
|
129632
|
+
case "number":
|
|
129633
|
+
elements.push(factory.createNumericLiteral(type.value));
|
|
129634
|
+
break;
|
|
129635
|
+
case "string":
|
|
129636
|
+
elements.push(factory.createStringLiteral(type.value));
|
|
129637
|
+
break;
|
|
129638
|
+
}
|
|
129639
|
+
}
|
|
129640
|
+
}
|
|
129641
|
+
if (elements.length === 0) {
|
|
129642
|
+
return void 0;
|
|
129643
|
+
}
|
|
129644
|
+
const newClauses = map(elements, (element) => factory.createCaseClause(element, []));
|
|
129645
|
+
const newLineChar = getNewLineCharacter(options, maybeBind(host, host.getNewLine));
|
|
129646
|
+
const printer = createSnippetPrinter({
|
|
129647
|
+
removeComments: true,
|
|
129648
|
+
module: options.module,
|
|
129649
|
+
target: options.target,
|
|
129650
|
+
newLine: getNewLineKind(newLineChar)
|
|
129651
|
+
});
|
|
129652
|
+
const printNode = formatContext ? (node) => printer.printAndFormatNode(4 /* Unspecified */, node, sourceFile, formatContext) : (node) => printer.printNode(4 /* Unspecified */, node, sourceFile);
|
|
129653
|
+
const insertText = map(newClauses, (clause, i) => {
|
|
129654
|
+
if (preferences.includeCompletionsWithSnippetText) {
|
|
129655
|
+
return `${printNode(clause)}$${i + 1}`;
|
|
129656
|
+
}
|
|
129657
|
+
return `${printNode(clause)}`;
|
|
129658
|
+
}).join(newLineChar);
|
|
129659
|
+
const firstClause = printer.printNode(4 /* Unspecified */, newClauses[0], sourceFile);
|
|
129660
|
+
return {
|
|
129661
|
+
entry: {
|
|
129662
|
+
name: `${firstClause} ...`,
|
|
129663
|
+
kind: "" /* unknown */,
|
|
129664
|
+
sortText: SortText.GlobalsOrKeywords,
|
|
129665
|
+
insertText,
|
|
129666
|
+
hasAction: importAdder.hasFixes() || void 0,
|
|
129667
|
+
source: "SwitchCases/" /* SwitchCases */,
|
|
129668
|
+
isSnippet: preferences.includeCompletionsWithSnippetText ? true : void 0
|
|
129669
|
+
},
|
|
129670
|
+
importAdder
|
|
129671
|
+
};
|
|
129672
|
+
}
|
|
129673
|
+
return void 0;
|
|
129674
|
+
}
|
|
129675
|
+
function newCaseClauseTracker(checker, clauses) {
|
|
129676
|
+
const existingStrings = /* @__PURE__ */ new Set();
|
|
129677
|
+
const existingNumbers = /* @__PURE__ */ new Set();
|
|
129678
|
+
const existingBigInts = /* @__PURE__ */ new Set();
|
|
129679
|
+
for (const clause of clauses) {
|
|
129680
|
+
if (!isDefaultClause(clause)) {
|
|
129681
|
+
if (isLiteralExpression(clause.expression)) {
|
|
129682
|
+
const expression = clause.expression;
|
|
129683
|
+
switch (expression.kind) {
|
|
129684
|
+
case 14 /* NoSubstitutionTemplateLiteral */:
|
|
129685
|
+
case 10 /* StringLiteral */:
|
|
129686
|
+
existingStrings.add(expression.text);
|
|
129687
|
+
break;
|
|
129688
|
+
case 8 /* NumericLiteral */:
|
|
129689
|
+
existingNumbers.add(parseInt(expression.text));
|
|
129690
|
+
break;
|
|
129691
|
+
case 9 /* BigIntLiteral */:
|
|
129692
|
+
const parsedBigInt = parseBigInt(endsWith(expression.text, "n") ? expression.text.slice(0, -1) : expression.text);
|
|
129693
|
+
if (parsedBigInt) {
|
|
129694
|
+
existingBigInts.add(pseudoBigIntToString(parsedBigInt));
|
|
129695
|
+
}
|
|
129696
|
+
break;
|
|
129697
|
+
}
|
|
129698
|
+
} else {
|
|
129699
|
+
const symbol = checker.getSymbolAtLocation(clause.expression);
|
|
129700
|
+
if (symbol && symbol.valueDeclaration && isEnumMember(symbol.valueDeclaration)) {
|
|
129701
|
+
const enumValue = checker.getConstantValue(symbol.valueDeclaration);
|
|
129702
|
+
if (enumValue !== void 0) {
|
|
129703
|
+
addValue(enumValue);
|
|
129704
|
+
}
|
|
129705
|
+
}
|
|
129706
|
+
}
|
|
129707
|
+
}
|
|
129708
|
+
}
|
|
129709
|
+
return {
|
|
129710
|
+
addValue,
|
|
129711
|
+
hasValue
|
|
129712
|
+
};
|
|
129713
|
+
function addValue(value) {
|
|
129714
|
+
switch (typeof value) {
|
|
129715
|
+
case "string":
|
|
129716
|
+
existingStrings.add(value);
|
|
129717
|
+
break;
|
|
129718
|
+
case "number":
|
|
129719
|
+
existingNumbers.add(value);
|
|
129720
|
+
}
|
|
129721
|
+
}
|
|
129722
|
+
function hasValue(value) {
|
|
129723
|
+
switch (typeof value) {
|
|
129724
|
+
case "string":
|
|
129725
|
+
return existingStrings.has(value);
|
|
129726
|
+
case "number":
|
|
129727
|
+
return existingNumbers.has(value);
|
|
129728
|
+
case "object":
|
|
129729
|
+
return existingBigInts.has(pseudoBigIntToString(value));
|
|
129730
|
+
}
|
|
129731
|
+
}
|
|
129732
|
+
}
|
|
129733
|
+
function typeNodeToExpression(typeNode, languageVersion, quotePreference) {
|
|
129734
|
+
switch (typeNode.kind) {
|
|
129735
|
+
case 180 /* TypeReference */:
|
|
129736
|
+
const typeName = typeNode.typeName;
|
|
129737
|
+
return entityNameToExpression(typeName, languageVersion, quotePreference);
|
|
129738
|
+
case 196 /* IndexedAccessType */:
|
|
129739
|
+
const objectExpression = typeNodeToExpression(typeNode.objectType, languageVersion, quotePreference);
|
|
129740
|
+
const indexExpression = typeNodeToExpression(typeNode.indexType, languageVersion, quotePreference);
|
|
129741
|
+
return objectExpression && indexExpression && factory.createElementAccessExpression(objectExpression, indexExpression);
|
|
129742
|
+
case 198 /* LiteralType */:
|
|
129743
|
+
const literal = typeNode.literal;
|
|
129744
|
+
switch (literal.kind) {
|
|
129745
|
+
case 10 /* StringLiteral */:
|
|
129746
|
+
return factory.createStringLiteral(literal.text, quotePreference === 0 /* Single */);
|
|
129747
|
+
case 8 /* NumericLiteral */:
|
|
129748
|
+
return factory.createNumericLiteral(literal.text, literal.numericLiteralFlags);
|
|
129749
|
+
}
|
|
129750
|
+
return void 0;
|
|
129751
|
+
case 193 /* ParenthesizedType */:
|
|
129752
|
+
const exp = typeNodeToExpression(typeNode.type, languageVersion, quotePreference);
|
|
129753
|
+
return exp && (isIdentifier(exp) ? exp : factory.createParenthesizedExpression(exp));
|
|
129754
|
+
case 183 /* TypeQuery */:
|
|
129755
|
+
return entityNameToExpression(typeNode.exprName, languageVersion, quotePreference);
|
|
129756
|
+
case 202 /* ImportType */:
|
|
129757
|
+
Debug.fail(`We should not get an import type after calling 'codefix.typeToAutoImportableTypeNode'.`);
|
|
129758
|
+
}
|
|
129759
|
+
return void 0;
|
|
129760
|
+
}
|
|
129761
|
+
function entityNameToExpression(entityName, languageVersion, quotePreference) {
|
|
129762
|
+
if (isIdentifier(entityName)) {
|
|
129763
|
+
return entityName;
|
|
129764
|
+
}
|
|
129765
|
+
const unescapedName = unescapeLeadingUnderscores(entityName.right.escapedText);
|
|
129766
|
+
if (canUsePropertyAccess(unescapedName, languageVersion)) {
|
|
129767
|
+
return factory.createPropertyAccessExpression(
|
|
129768
|
+
entityNameToExpression(entityName.left, languageVersion, quotePreference),
|
|
129769
|
+
unescapedName
|
|
129770
|
+
);
|
|
129771
|
+
} else {
|
|
129772
|
+
return factory.createElementAccessExpression(
|
|
129773
|
+
entityNameToExpression(entityName.left, languageVersion, quotePreference),
|
|
129774
|
+
factory.createStringLiteral(unescapedName, quotePreference === 0 /* Single */)
|
|
129775
|
+
);
|
|
129776
|
+
}
|
|
129777
|
+
}
|
|
129591
129778
|
function isMemberCompletionKind(kind) {
|
|
129592
129779
|
switch (kind) {
|
|
129593
129780
|
case CompletionKind.ObjectPropertyDeclaration:
|
|
@@ -129994,7 +130181,9 @@ ${lanes.join("\n")}
|
|
|
129994
130181
|
};
|
|
129995
130182
|
return {
|
|
129996
130183
|
printSnippetList,
|
|
129997
|
-
printAndFormatSnippetList
|
|
130184
|
+
printAndFormatSnippetList,
|
|
130185
|
+
printNode,
|
|
130186
|
+
printAndFormatNode
|
|
129998
130187
|
};
|
|
129999
130188
|
function escapingWrite(s, write) {
|
|
130000
130189
|
const escaped = escapeSnippetText(s);
|
|
@@ -130043,6 +130232,40 @@ ${lanes.join("\n")}
|
|
|
130043
130232
|
const allChanges = escapes ? stableSort(concatenate(changes, escapes), (a, b) => compareTextSpans(a.span, b.span)) : changes;
|
|
130044
130233
|
return ts_textChanges_exports.applyChanges(syntheticFile.text, allChanges);
|
|
130045
130234
|
}
|
|
130235
|
+
function printNode(hint, node, sourceFile) {
|
|
130236
|
+
const unescaped = printUnescapedNode(hint, node, sourceFile);
|
|
130237
|
+
return escapes ? ts_textChanges_exports.applyChanges(unescaped, escapes) : unescaped;
|
|
130238
|
+
}
|
|
130239
|
+
function printUnescapedNode(hint, node, sourceFile) {
|
|
130240
|
+
escapes = void 0;
|
|
130241
|
+
writer.clear();
|
|
130242
|
+
printer.writeNode(hint, node, sourceFile, writer);
|
|
130243
|
+
return writer.getText();
|
|
130244
|
+
}
|
|
130245
|
+
function printAndFormatNode(hint, node, sourceFile, formatContext) {
|
|
130246
|
+
const syntheticFile = {
|
|
130247
|
+
text: printUnescapedNode(
|
|
130248
|
+
hint,
|
|
130249
|
+
node,
|
|
130250
|
+
sourceFile
|
|
130251
|
+
),
|
|
130252
|
+
getLineAndCharacterOfPosition(pos) {
|
|
130253
|
+
return getLineAndCharacterOfPosition(this, pos);
|
|
130254
|
+
}
|
|
130255
|
+
};
|
|
130256
|
+
const formatOptions = getFormatCodeSettingsForWriting(formatContext, sourceFile);
|
|
130257
|
+
const nodeWithPos = ts_textChanges_exports.assignPositionsToNode(node);
|
|
130258
|
+
const changes = ts_formatting_exports.formatNodeGivenIndentation(
|
|
130259
|
+
nodeWithPos,
|
|
130260
|
+
syntheticFile,
|
|
130261
|
+
sourceFile.languageVariant,
|
|
130262
|
+
0,
|
|
130263
|
+
0,
|
|
130264
|
+
{ ...formatContext, options: formatOptions }
|
|
130265
|
+
);
|
|
130266
|
+
const allChanges = escapes ? stableSort(concatenate(changes, escapes), (a, b) => compareTextSpans(a.span, b.span)) : changes;
|
|
130267
|
+
return ts_textChanges_exports.applyChanges(syntheticFile.text, allChanges);
|
|
130268
|
+
}
|
|
130046
130269
|
}
|
|
130047
130270
|
function originToCompletionEntryData(origin) {
|
|
130048
130271
|
const ambientModuleName = origin.fileName ? void 0 : stripQuotes(origin.moduleSymbol.name);
|
|
@@ -130246,6 +130469,9 @@ ${lanes.join("\n")}
|
|
|
130246
130469
|
return entries;
|
|
130247
130470
|
}
|
|
130248
130471
|
function getSymbolCompletionFromEntryId(program, log, sourceFile, position, entryId, host, preferences) {
|
|
130472
|
+
if (entryId.source === "SwitchCases/" /* SwitchCases */) {
|
|
130473
|
+
return { type: "cases" };
|
|
130474
|
+
}
|
|
130249
130475
|
if (entryId.data) {
|
|
130250
130476
|
const autoImport = getAutoImportSymbolFromCompletionEntryData(entryId.name, entryId.data, program, host);
|
|
130251
130477
|
if (autoImport) {
|
|
@@ -130284,9 +130510,9 @@ ${lanes.join("\n")}
|
|
|
130284
130510
|
const typeChecker = program.getTypeChecker();
|
|
130285
130511
|
const compilerOptions = program.getCompilerOptions();
|
|
130286
130512
|
const { name, source, data } = entryId;
|
|
130287
|
-
const contextToken =
|
|
130288
|
-
if (isInString(sourceFile, position,
|
|
130289
|
-
return ts_Completions_StringCompletions_exports.getStringLiteralCompletionDetails(name, sourceFile, position,
|
|
130513
|
+
const { previousToken, contextToken } = getRelevantTokens(position, sourceFile);
|
|
130514
|
+
if (isInString(sourceFile, position, previousToken)) {
|
|
130515
|
+
return ts_Completions_StringCompletions_exports.getStringLiteralCompletionDetails(name, sourceFile, position, previousToken, typeChecker, compilerOptions, host, cancellationToken, preferences);
|
|
130290
130516
|
}
|
|
130291
130517
|
const symbolCompletion = getSymbolCompletionFromEntryId(program, log, sourceFile, position, entryId, host, preferences);
|
|
130292
130518
|
switch (symbolCompletion.type) {
|
|
@@ -130306,14 +130532,49 @@ ${lanes.join("\n")}
|
|
|
130306
130532
|
}
|
|
130307
130533
|
}
|
|
130308
130534
|
case "symbol": {
|
|
130309
|
-
const { symbol, location, contextToken: contextToken2, origin, previousToken } = symbolCompletion;
|
|
130310
|
-
const { codeActions, sourceDisplay } = getCompletionEntryCodeActionsAndSourceDisplay(name, location, contextToken2, origin, symbol, program, host, compilerOptions, sourceFile, position,
|
|
130535
|
+
const { symbol, location, contextToken: contextToken2, origin, previousToken: previousToken2 } = symbolCompletion;
|
|
130536
|
+
const { codeActions, sourceDisplay } = getCompletionEntryCodeActionsAndSourceDisplay(name, location, contextToken2, origin, symbol, program, host, compilerOptions, sourceFile, position, previousToken2, formatContext, preferences, data, source, cancellationToken);
|
|
130311
130537
|
return createCompletionDetailsForSymbol(symbol, typeChecker, sourceFile, location, cancellationToken, codeActions, sourceDisplay);
|
|
130312
130538
|
}
|
|
130313
130539
|
case "literal": {
|
|
130314
130540
|
const { literal } = symbolCompletion;
|
|
130315
130541
|
return createSimpleDetails(completionNameForLiteral(sourceFile, preferences, literal), "string" /* string */, typeof literal === "string" ? 8 /* stringLiteral */ : 7 /* numericLiteral */);
|
|
130316
130542
|
}
|
|
130543
|
+
case "cases": {
|
|
130544
|
+
const { entry, importAdder } = getExhaustiveCaseSnippets(
|
|
130545
|
+
contextToken.parent,
|
|
130546
|
+
sourceFile,
|
|
130547
|
+
preferences,
|
|
130548
|
+
program.getCompilerOptions(),
|
|
130549
|
+
host,
|
|
130550
|
+
program,
|
|
130551
|
+
void 0
|
|
130552
|
+
);
|
|
130553
|
+
if (importAdder.hasFixes()) {
|
|
130554
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(
|
|
130555
|
+
{ host, formatContext, preferences },
|
|
130556
|
+
importAdder.writeFixes
|
|
130557
|
+
);
|
|
130558
|
+
return {
|
|
130559
|
+
name: entry.name,
|
|
130560
|
+
kind: "" /* unknown */,
|
|
130561
|
+
kindModifiers: "",
|
|
130562
|
+
displayParts: [],
|
|
130563
|
+
sourceDisplay: void 0,
|
|
130564
|
+
codeActions: [{
|
|
130565
|
+
changes,
|
|
130566
|
+
description: diagnosticToString([Diagnostics.Includes_imports_of_types_referenced_by_0, name])
|
|
130567
|
+
}]
|
|
130568
|
+
};
|
|
130569
|
+
}
|
|
130570
|
+
return {
|
|
130571
|
+
name: entry.name,
|
|
130572
|
+
kind: "" /* unknown */,
|
|
130573
|
+
kindModifiers: "",
|
|
130574
|
+
displayParts: [],
|
|
130575
|
+
sourceDisplay: void 0
|
|
130576
|
+
};
|
|
130577
|
+
}
|
|
130317
130578
|
case "none":
|
|
130318
130579
|
return allKeywordsCompletions().some((c) => c.name === name) ? createSimpleDetails(name, "keyword" /* keyword */, 5 /* keyword */) : void 0;
|
|
130319
130580
|
default:
|
|
@@ -132200,6 +132461,7 @@ ${lanes.join("\n")}
|
|
|
132200
132461
|
CompletionSource2["ClassMemberSnippet"] = "ClassMemberSnippet/";
|
|
132201
132462
|
CompletionSource2["TypeOnlyAlias"] = "TypeOnlyAlias/";
|
|
132202
132463
|
CompletionSource2["ObjectLiteralMethodSnippet"] = "ObjectLiteralMethodSnippet/";
|
|
132464
|
+
CompletionSource2["SwitchCases"] = "SwitchCases/";
|
|
132203
132465
|
return CompletionSource2;
|
|
132204
132466
|
})(CompletionSource || {});
|
|
132205
132467
|
SymbolOriginInfoKind = /* @__PURE__ */ ((SymbolOriginInfoKind2) => {
|
|
@@ -137514,12 +137776,14 @@ ${lanes.join("\n")}
|
|
|
137514
137776
|
if (!selection || !isTypeNode(selection))
|
|
137515
137777
|
return { error: getLocaleSpecificMessage(Diagnostics.Selection_is_not_a_valid_type_node) };
|
|
137516
137778
|
const checker = context.program.getTypeChecker();
|
|
137517
|
-
const
|
|
137518
|
-
|
|
137779
|
+
const enclosingNode = getEnclosingNode(selection, isJS);
|
|
137780
|
+
if (enclosingNode === void 0)
|
|
137781
|
+
return { error: getLocaleSpecificMessage(Diagnostics.No_type_could_be_extracted_from_this_type_node) };
|
|
137782
|
+
const typeParameters = collectTypeParameters(checker, selection, enclosingNode, file);
|
|
137519
137783
|
if (!typeParameters)
|
|
137520
137784
|
return { error: getLocaleSpecificMessage(Diagnostics.No_type_could_be_extracted_from_this_type_node) };
|
|
137521
137785
|
const typeElements = flattenTypeLiteralNodeReference(checker, selection);
|
|
137522
|
-
return { isJS, selection,
|
|
137786
|
+
return { isJS, selection, enclosingNode, typeParameters, typeElements };
|
|
137523
137787
|
}
|
|
137524
137788
|
function flattenTypeLiteralNodeReference(checker, node) {
|
|
137525
137789
|
if (!node)
|
|
@@ -137545,7 +137809,7 @@ ${lanes.join("\n")}
|
|
|
137545
137809
|
function rangeContainsSkipTrivia(r1, node, file) {
|
|
137546
137810
|
return rangeContainsStartEnd(r1, skipTrivia(file.text, node.pos), node.end);
|
|
137547
137811
|
}
|
|
137548
|
-
function collectTypeParameters(checker, selection,
|
|
137812
|
+
function collectTypeParameters(checker, selection, enclosingNode, file) {
|
|
137549
137813
|
const result = [];
|
|
137550
137814
|
return visitor(selection) ? void 0 : result;
|
|
137551
137815
|
function visitor(node) {
|
|
@@ -137558,7 +137822,7 @@ ${lanes.join("\n")}
|
|
|
137558
137822
|
if (decl.name.escapedText === typeName.escapedText && rangeContainsSkipTrivia(decl, selection, file)) {
|
|
137559
137823
|
return true;
|
|
137560
137824
|
}
|
|
137561
|
-
if (rangeContainsSkipTrivia(
|
|
137825
|
+
if (rangeContainsSkipTrivia(enclosingNode, decl, file) && !rangeContainsSkipTrivia(selection, decl, file)) {
|
|
137562
137826
|
pushIfUnique(result, decl);
|
|
137563
137827
|
break;
|
|
137564
137828
|
}
|
|
@@ -137578,7 +137842,7 @@ ${lanes.join("\n")}
|
|
|
137578
137842
|
} else if (isTypeQueryNode(node)) {
|
|
137579
137843
|
if (isIdentifier(node.exprName)) {
|
|
137580
137844
|
const symbol = checker.resolveName(node.exprName.text, node.exprName, 111551 /* Value */, false);
|
|
137581
|
-
if ((symbol == null ? void 0 : symbol.valueDeclaration) && rangeContainsSkipTrivia(
|
|
137845
|
+
if ((symbol == null ? void 0 : symbol.valueDeclaration) && rangeContainsSkipTrivia(enclosingNode, symbol.valueDeclaration, file) && !rangeContainsSkipTrivia(selection, symbol.valueDeclaration, file)) {
|
|
137582
137846
|
return true;
|
|
137583
137847
|
}
|
|
137584
137848
|
} else {
|
|
@@ -137594,19 +137858,19 @@ ${lanes.join("\n")}
|
|
|
137594
137858
|
}
|
|
137595
137859
|
}
|
|
137596
137860
|
function doTypeAliasChange(changes, file, name, info) {
|
|
137597
|
-
const {
|
|
137861
|
+
const { enclosingNode, selection, typeParameters } = info;
|
|
137598
137862
|
const newTypeNode = factory.createTypeAliasDeclaration(
|
|
137599
137863
|
void 0,
|
|
137600
137864
|
name,
|
|
137601
137865
|
typeParameters.map((id) => factory.updateTypeParameterDeclaration(id, id.modifiers, id.name, id.constraint, void 0)),
|
|
137602
137866
|
selection
|
|
137603
137867
|
);
|
|
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
137871
|
function doInterfaceChange(changes, file, name, info) {
|
|
137608
137872
|
var _a2;
|
|
137609
|
-
const {
|
|
137873
|
+
const { enclosingNode, selection, typeParameters, typeElements } = info;
|
|
137610
137874
|
const newTypeNode = factory.createInterfaceDeclaration(
|
|
137611
137875
|
void 0,
|
|
137612
137876
|
name,
|
|
@@ -137615,11 +137879,11 @@ ${lanes.join("\n")}
|
|
|
137615
137879
|
typeElements
|
|
137616
137880
|
);
|
|
137617
137881
|
setTextRange(newTypeNode, (_a2 = typeElements[0]) == null ? void 0 : _a2.parent);
|
|
137618
|
-
changes.insertNodeBefore(file,
|
|
137882
|
+
changes.insertNodeBefore(file, enclosingNode, ignoreSourceNewlines(newTypeNode), true);
|
|
137619
137883
|
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 });
|
|
137620
137884
|
}
|
|
137621
|
-
function doTypedefChange(changes, file, name, info) {
|
|
137622
|
-
const {
|
|
137885
|
+
function doTypedefChange(changes, program, file, name, info) {
|
|
137886
|
+
const { enclosingNode, selection, typeParameters } = info;
|
|
137623
137887
|
setEmitFlags(selection, 3072 /* NoComments */ | 4096 /* NoNestedComments */);
|
|
137624
137888
|
const node = factory.createJSDocTypedefTag(
|
|
137625
137889
|
factory.createIdentifier("typedef"),
|
|
@@ -137637,9 +137901,21 @@ ${lanes.join("\n")}
|
|
|
137637
137901
|
);
|
|
137638
137902
|
templates.push(template);
|
|
137639
137903
|
});
|
|
137640
|
-
|
|
137904
|
+
const jsDoc = factory.createJSDocComment(void 0, factory.createNodeArray(concatenate(templates, [node])));
|
|
137905
|
+
if (isJSDoc(enclosingNode)) {
|
|
137906
|
+
const pos = enclosingNode.getStart(file);
|
|
137907
|
+
const newLineCharacter = getNewLineCharacter(program.getCompilerOptions());
|
|
137908
|
+
changes.insertNodeAt(file, enclosingNode.getStart(file), jsDoc, {
|
|
137909
|
+
suffix: newLineCharacter + newLineCharacter + file.text.slice(getPrecedingNonSpaceCharacterPosition(file.text, pos - 1), pos)
|
|
137910
|
+
});
|
|
137911
|
+
} else {
|
|
137912
|
+
changes.insertNodeBefore(file, enclosingNode, jsDoc, true);
|
|
137913
|
+
}
|
|
137641
137914
|
changes.replaceNode(file, selection, factory.createTypeReferenceNode(name, typeParameters.map((id) => factory.createTypeReferenceNode(id.name, void 0))));
|
|
137642
137915
|
}
|
|
137916
|
+
function getEnclosingNode(node, isJS) {
|
|
137917
|
+
return findAncestor(node, isStatement) || (isJS ? findAncestor(node, isJSDoc) : void 0);
|
|
137918
|
+
}
|
|
137643
137919
|
var refactorName3, extractToTypeAliasAction, extractToInterfaceAction, extractToTypeDefAction;
|
|
137644
137920
|
var init_extractType = __esm({
|
|
137645
137921
|
"src/services/refactors/extractType.ts"() {
|
|
@@ -137693,7 +137969,7 @@ ${lanes.join("\n")}
|
|
|
137693
137969
|
return emptyArray;
|
|
137694
137970
|
},
|
|
137695
137971
|
getEditsForAction: function getRefactorEditsToExtractType(context, actionName2) {
|
|
137696
|
-
const { file } = context;
|
|
137972
|
+
const { file, program } = context;
|
|
137697
137973
|
const info = getRangeToExtract(context);
|
|
137698
137974
|
Debug.assert(info && !isRefactorErrorInfo(info), "Expected to find a range to extract");
|
|
137699
137975
|
const name = getUniqueName("NewType", file);
|
|
@@ -137704,7 +137980,7 @@ ${lanes.join("\n")}
|
|
|
137704
137980
|
return doTypeAliasChange(changes, file, name, info);
|
|
137705
137981
|
case extractToTypeDefAction.name:
|
|
137706
137982
|
Debug.assert(info.isJS, "Invalid actionName/JS combo");
|
|
137707
|
-
return doTypedefChange(changes, file, name, info);
|
|
137983
|
+
return doTypedefChange(changes, program, file, name, info);
|
|
137708
137984
|
case extractToInterfaceAction.name:
|
|
137709
137985
|
Debug.assert(!info.isJS && !!info.typeElements, "Invalid actionName/JS combo");
|
|
137710
137986
|
return doInterfaceChange(changes, file, name, info);
|
|
@@ -148473,6 +148749,7 @@ ${options.prefix}` : "\n" : options.prefix
|
|
|
148473
148749
|
canHaveModifiers: () => canHaveModifiers,
|
|
148474
148750
|
canJsonReportNoInputFiles: () => canJsonReportNoInputFiles,
|
|
148475
148751
|
canProduceDiagnostics: () => canProduceDiagnostics,
|
|
148752
|
+
canUsePropertyAccess: () => canUsePropertyAccess,
|
|
148476
148753
|
canWatchDirectoryOrFile: () => canWatchDirectoryOrFile,
|
|
148477
148754
|
cartesianProduct: () => cartesianProduct,
|
|
148478
148755
|
cast: () => cast,
|
|
@@ -148749,6 +149026,7 @@ ${options.prefix}` : "\n" : options.prefix
|
|
|
148749
149026
|
createMethod: () => createMethod,
|
|
148750
149027
|
createMethodSignature: () => createMethodSignature,
|
|
148751
149028
|
createModeAwareCache: () => createModeAwareCache,
|
|
149029
|
+
createModeAwareCacheKey: () => createModeAwareCacheKey,
|
|
148752
149030
|
createModifier: () => createModifier,
|
|
148753
149031
|
createModifiersFromModifierFlags: () => createModifiersFromModifierFlags,
|
|
148754
149032
|
createModuleBlock: () => createModuleBlock,
|
|
@@ -149228,6 +149506,7 @@ ${options.prefix}` : "\n" : options.prefix
|
|
|
149228
149506
|
getJSXImplicitImportBase: () => getJSXImplicitImportBase,
|
|
149229
149507
|
getJSXRuntimeImport: () => getJSXRuntimeImport,
|
|
149230
149508
|
getJSXTransformEnabled: () => getJSXTransformEnabled,
|
|
149509
|
+
getKeyForCompilerOptions: () => getKeyForCompilerOptions,
|
|
149231
149510
|
getLanguageVariant: () => getLanguageVariant,
|
|
149232
149511
|
getLastChild: () => getLastChild,
|
|
149233
149512
|
getLeadingCommentRanges: () => getLeadingCommentRanges,
|
|
@@ -149499,6 +149778,7 @@ ${options.prefix}` : "\n" : options.prefix
|
|
|
149499
149778
|
hasSyntacticModifier: () => hasSyntacticModifier,
|
|
149500
149779
|
hasSyntacticModifiers: () => hasSyntacticModifiers,
|
|
149501
149780
|
hasTSFileExtension: () => hasTSFileExtension,
|
|
149781
|
+
hasTabstop: () => hasTabstop,
|
|
149502
149782
|
hasTrailingDirectorySeparator: () => hasTrailingDirectorySeparator,
|
|
149503
149783
|
hasType: () => hasType,
|
|
149504
149784
|
hasTypeArguments: () => hasTypeArguments,
|
|
@@ -150148,6 +150428,7 @@ ${options.prefix}` : "\n" : options.prefix
|
|
|
150148
150428
|
isUnparsedSource: () => isUnparsedSource,
|
|
150149
150429
|
isUnparsedTextLike: () => isUnparsedTextLike,
|
|
150150
150430
|
isUrl: () => isUrl,
|
|
150431
|
+
isValidBigIntString: () => isValidBigIntString,
|
|
150151
150432
|
isValidESSymbolDeclaration: () => isValidESSymbolDeclaration,
|
|
150152
150433
|
isValidTypeOnlyAliasUseSite: () => isValidTypeOnlyAliasUseSite,
|
|
150153
150434
|
isValueSignatureDeclaration: () => isValueSignatureDeclaration,
|
|
@@ -150279,6 +150560,7 @@ ${options.prefix}` : "\n" : options.prefix
|
|
|
150279
150560
|
parameterIsThisKeyword: () => parameterIsThisKeyword,
|
|
150280
150561
|
parameterNamePart: () => parameterNamePart,
|
|
150281
150562
|
parseBaseNodeFactory: () => parseBaseNodeFactory,
|
|
150563
|
+
parseBigInt: () => parseBigInt,
|
|
150282
150564
|
parseBuildCommand: () => parseBuildCommand,
|
|
150283
150565
|
parseCommandLine: () => parseCommandLine,
|
|
150284
150566
|
parseCommandLineWorker: () => parseCommandLineWorker,
|
|
@@ -150297,6 +150579,7 @@ ${options.prefix}` : "\n" : options.prefix
|
|
|
150297
150579
|
parseNodeModuleFromPath: () => parseNodeModuleFromPath,
|
|
150298
150580
|
parsePackageName: () => parsePackageName,
|
|
150299
150581
|
parsePseudoBigInt: () => parsePseudoBigInt,
|
|
150582
|
+
parseValidBigInt: () => parseValidBigInt,
|
|
150300
150583
|
patchWriteFileEnsuringDirectory: () => patchWriteFileEnsuringDirectory,
|
|
150301
150584
|
pathContainsNodeModules: () => pathContainsNodeModules,
|
|
150302
150585
|
pathIsAbsolute: () => pathIsAbsolute,
|