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/tsserver.js
CHANGED
|
@@ -253,6 +253,7 @@ var ts = (() => {
|
|
|
253
253
|
canHaveModifiers: () => canHaveModifiers,
|
|
254
254
|
canJsonReportNoInputFiles: () => canJsonReportNoInputFiles,
|
|
255
255
|
canProduceDiagnostics: () => canProduceDiagnostics,
|
|
256
|
+
canUsePropertyAccess: () => canUsePropertyAccess,
|
|
256
257
|
canWatchDirectoryOrFile: () => canWatchDirectoryOrFile,
|
|
257
258
|
cartesianProduct: () => cartesianProduct,
|
|
258
259
|
cast: () => cast,
|
|
@@ -529,6 +530,7 @@ var ts = (() => {
|
|
|
529
530
|
createMethod: () => createMethod,
|
|
530
531
|
createMethodSignature: () => createMethodSignature,
|
|
531
532
|
createModeAwareCache: () => createModeAwareCache,
|
|
533
|
+
createModeAwareCacheKey: () => createModeAwareCacheKey,
|
|
532
534
|
createModifier: () => createModifier,
|
|
533
535
|
createModifiersFromModifierFlags: () => createModifiersFromModifierFlags,
|
|
534
536
|
createModuleBlock: () => createModuleBlock,
|
|
@@ -1008,6 +1010,7 @@ var ts = (() => {
|
|
|
1008
1010
|
getJSXImplicitImportBase: () => getJSXImplicitImportBase,
|
|
1009
1011
|
getJSXRuntimeImport: () => getJSXRuntimeImport,
|
|
1010
1012
|
getJSXTransformEnabled: () => getJSXTransformEnabled,
|
|
1013
|
+
getKeyForCompilerOptions: () => getKeyForCompilerOptions,
|
|
1011
1014
|
getLanguageVariant: () => getLanguageVariant,
|
|
1012
1015
|
getLastChild: () => getLastChild,
|
|
1013
1016
|
getLeadingCommentRanges: () => getLeadingCommentRanges,
|
|
@@ -1279,6 +1282,7 @@ var ts = (() => {
|
|
|
1279
1282
|
hasSyntacticModifier: () => hasSyntacticModifier,
|
|
1280
1283
|
hasSyntacticModifiers: () => hasSyntacticModifiers,
|
|
1281
1284
|
hasTSFileExtension: () => hasTSFileExtension,
|
|
1285
|
+
hasTabstop: () => hasTabstop,
|
|
1282
1286
|
hasTrailingDirectorySeparator: () => hasTrailingDirectorySeparator,
|
|
1283
1287
|
hasType: () => hasType,
|
|
1284
1288
|
hasTypeArguments: () => hasTypeArguments,
|
|
@@ -1928,6 +1932,7 @@ var ts = (() => {
|
|
|
1928
1932
|
isUnparsedSource: () => isUnparsedSource,
|
|
1929
1933
|
isUnparsedTextLike: () => isUnparsedTextLike,
|
|
1930
1934
|
isUrl: () => isUrl,
|
|
1935
|
+
isValidBigIntString: () => isValidBigIntString,
|
|
1931
1936
|
isValidESSymbolDeclaration: () => isValidESSymbolDeclaration,
|
|
1932
1937
|
isValidTypeOnlyAliasUseSite: () => isValidTypeOnlyAliasUseSite,
|
|
1933
1938
|
isValueSignatureDeclaration: () => isValueSignatureDeclaration,
|
|
@@ -2059,6 +2064,7 @@ var ts = (() => {
|
|
|
2059
2064
|
parameterIsThisKeyword: () => parameterIsThisKeyword,
|
|
2060
2065
|
parameterNamePart: () => parameterNamePart,
|
|
2061
2066
|
parseBaseNodeFactory: () => parseBaseNodeFactory,
|
|
2067
|
+
parseBigInt: () => parseBigInt,
|
|
2062
2068
|
parseBuildCommand: () => parseBuildCommand,
|
|
2063
2069
|
parseCommandLine: () => parseCommandLine,
|
|
2064
2070
|
parseCommandLineWorker: () => parseCommandLineWorker,
|
|
@@ -2077,6 +2083,7 @@ var ts = (() => {
|
|
|
2077
2083
|
parseNodeModuleFromPath: () => parseNodeModuleFromPath,
|
|
2078
2084
|
parsePackageName: () => parsePackageName,
|
|
2079
2085
|
parsePseudoBigInt: () => parsePseudoBigInt,
|
|
2086
|
+
parseValidBigInt: () => parseValidBigInt,
|
|
2080
2087
|
patchWriteFileEnsuringDirectory: () => patchWriteFileEnsuringDirectory,
|
|
2081
2088
|
pathContainsNodeModules: () => pathContainsNodeModules,
|
|
2082
2089
|
pathIsAbsolute: () => pathIsAbsolute,
|
|
@@ -2648,7 +2655,7 @@ var ts = (() => {
|
|
|
2648
2655
|
|
|
2649
2656
|
// src/compiler/corePublic.ts
|
|
2650
2657
|
var versionMajorMinor = "5.0";
|
|
2651
|
-
var version = `${versionMajorMinor}.0-dev.
|
|
2658
|
+
var version = `${versionMajorMinor}.0-dev.20221202`;
|
|
2652
2659
|
var Comparison = /* @__PURE__ */ ((Comparison3) => {
|
|
2653
2660
|
Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
|
|
2654
2661
|
Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
|
|
@@ -19762,6 +19769,32 @@ ${lanes.join("\n")}
|
|
|
19762
19769
|
function pseudoBigIntToString({ negative, base10Value }) {
|
|
19763
19770
|
return (negative && base10Value !== "0" ? "-" : "") + base10Value;
|
|
19764
19771
|
}
|
|
19772
|
+
function parseBigInt(text) {
|
|
19773
|
+
if (!isValidBigIntString(text, false)) {
|
|
19774
|
+
return void 0;
|
|
19775
|
+
}
|
|
19776
|
+
return parseValidBigInt(text);
|
|
19777
|
+
}
|
|
19778
|
+
function parseValidBigInt(text) {
|
|
19779
|
+
const negative = text.startsWith("-");
|
|
19780
|
+
const base10Value = parsePseudoBigInt(`${negative ? text.slice(1) : text}n`);
|
|
19781
|
+
return { negative, base10Value };
|
|
19782
|
+
}
|
|
19783
|
+
function isValidBigIntString(s, roundTripOnly) {
|
|
19784
|
+
if (s === "")
|
|
19785
|
+
return false;
|
|
19786
|
+
const scanner2 = createScanner(99 /* ESNext */, false);
|
|
19787
|
+
let success = true;
|
|
19788
|
+
scanner2.setOnError(() => success = false);
|
|
19789
|
+
scanner2.setText(s + "n");
|
|
19790
|
+
let result = scanner2.scan();
|
|
19791
|
+
const negative = result === 40 /* MinusToken */;
|
|
19792
|
+
if (negative) {
|
|
19793
|
+
result = scanner2.scan();
|
|
19794
|
+
}
|
|
19795
|
+
const flags = scanner2.getTokenFlags();
|
|
19796
|
+
return success && result === 9 /* BigIntLiteral */ && scanner2.getTextPos() === s.length + 1 && !(flags & 512 /* ContainsSeparator */) && (!roundTripOnly || s === pseudoBigIntToString({ negative, base10Value: parsePseudoBigInt(scanner2.getTokenValue()) }));
|
|
19797
|
+
}
|
|
19765
19798
|
function isValidTypeOnlyAliasUseSite(useSite) {
|
|
19766
19799
|
return !!(useSite.flags & 16777216 /* Ambient */) || isPartOfTypeQuery(useSite) || isIdentifierInNonEmittingHeritageClause(useSite) || isPartOfPossiblyValidTypeOrAbstractComputedPropertyName(useSite) || !(isExpressionNode(useSite) || isShorthandPropertyNameUseSite(useSite));
|
|
19767
19800
|
}
|
|
@@ -20088,6 +20121,17 @@ ${lanes.join("\n")}
|
|
|
20088
20121
|
const { isBracketed, typeExpression } = node;
|
|
20089
20122
|
return isBracketed || !!typeExpression && typeExpression.type.kind === 319 /* JSDocOptionalType */;
|
|
20090
20123
|
}
|
|
20124
|
+
function canUsePropertyAccess(name, languageVersion) {
|
|
20125
|
+
if (name.length === 0) {
|
|
20126
|
+
return false;
|
|
20127
|
+
}
|
|
20128
|
+
const firstChar = name.charCodeAt(0);
|
|
20129
|
+
return firstChar === 35 /* hash */ ? name.length > 1 && isIdentifierStart(name.charCodeAt(1), languageVersion) : isIdentifierStart(firstChar, languageVersion);
|
|
20130
|
+
}
|
|
20131
|
+
function hasTabstop(node) {
|
|
20132
|
+
var _a2;
|
|
20133
|
+
return ((_a2 = getSnippetElement(node)) == null ? void 0 : _a2.kind) === 0 /* TabStop */;
|
|
20134
|
+
}
|
|
20091
20135
|
|
|
20092
20136
|
// src/compiler/factory/baseNodeFactory.ts
|
|
20093
20137
|
function createBaseNodeFactory() {
|
|
@@ -37716,41 +37760,86 @@ ${lanes.join("\n")}
|
|
|
37716
37760
|
}
|
|
37717
37761
|
return result;
|
|
37718
37762
|
}
|
|
37719
|
-
function
|
|
37720
|
-
|
|
37763
|
+
function compilerOptionValueToString(value) {
|
|
37764
|
+
var _a2;
|
|
37765
|
+
if (value === null || typeof value !== "object") {
|
|
37766
|
+
return "" + value;
|
|
37767
|
+
}
|
|
37768
|
+
if (isArray(value)) {
|
|
37769
|
+
return `[${(_a2 = value.map((e) => compilerOptionValueToString(e))) == null ? void 0 : _a2.join(",")}]`;
|
|
37770
|
+
}
|
|
37771
|
+
let str = "{";
|
|
37772
|
+
for (const key in value) {
|
|
37773
|
+
if (hasProperty(value, key)) {
|
|
37774
|
+
str += `${key}: ${compilerOptionValueToString(value[key])}`;
|
|
37775
|
+
}
|
|
37776
|
+
}
|
|
37777
|
+
return str + "}";
|
|
37778
|
+
}
|
|
37779
|
+
function getKeyForCompilerOptions(options, affectingOptionDeclarations) {
|
|
37780
|
+
return affectingOptionDeclarations.map((option) => compilerOptionValueToString(getCompilerOptionValue(options, option))).join("|") + (options.pathsBasePath ? `|${options.pathsBasePath}` : void 0);
|
|
37781
|
+
}
|
|
37782
|
+
function createCacheWithRedirects(ownOptions) {
|
|
37721
37783
|
const redirectsMap = /* @__PURE__ */ new Map();
|
|
37784
|
+
const optionsToRedirectsKey = /* @__PURE__ */ new Map();
|
|
37785
|
+
const redirectsKeyToMap = /* @__PURE__ */ new Map();
|
|
37786
|
+
let ownMap = /* @__PURE__ */ new Map();
|
|
37787
|
+
if (ownOptions)
|
|
37788
|
+
redirectsMap.set(ownOptions, ownMap);
|
|
37722
37789
|
return {
|
|
37723
|
-
getOwnMap,
|
|
37724
|
-
redirectsMap,
|
|
37725
37790
|
getOrCreateMapOfCacheRedirects,
|
|
37726
|
-
|
|
37727
|
-
|
|
37728
|
-
setOwnMap
|
|
37791
|
+
update,
|
|
37792
|
+
clear: clear2
|
|
37729
37793
|
};
|
|
37730
|
-
function getOwnMap() {
|
|
37731
|
-
return ownMap;
|
|
37732
|
-
}
|
|
37733
|
-
function setOwnOptions(newOptions) {
|
|
37734
|
-
options = newOptions;
|
|
37735
|
-
}
|
|
37736
|
-
function setOwnMap(newOwnMap) {
|
|
37737
|
-
ownMap = newOwnMap;
|
|
37738
|
-
}
|
|
37739
37794
|
function getOrCreateMapOfCacheRedirects(redirectedReference) {
|
|
37740
|
-
|
|
37741
|
-
|
|
37795
|
+
return redirectedReference ? getOrCreateMap(redirectedReference.commandLine.options) : ownMap;
|
|
37796
|
+
}
|
|
37797
|
+
function update(newOptions) {
|
|
37798
|
+
if (ownOptions !== newOptions) {
|
|
37799
|
+
if (ownOptions)
|
|
37800
|
+
ownMap = getOrCreateMap(newOptions);
|
|
37801
|
+
else
|
|
37802
|
+
redirectsMap.set(newOptions, ownMap);
|
|
37803
|
+
ownOptions = newOptions;
|
|
37742
37804
|
}
|
|
37743
|
-
|
|
37744
|
-
|
|
37745
|
-
|
|
37746
|
-
|
|
37747
|
-
|
|
37805
|
+
}
|
|
37806
|
+
function getOrCreateMap(redirectOptions) {
|
|
37807
|
+
let result = redirectsMap.get(redirectOptions);
|
|
37808
|
+
if (result)
|
|
37809
|
+
return result;
|
|
37810
|
+
const key = getRedirectsCacheKey(redirectOptions);
|
|
37811
|
+
result = redirectsKeyToMap.get(key);
|
|
37812
|
+
if (!result) {
|
|
37813
|
+
if (ownOptions) {
|
|
37814
|
+
const ownKey = getRedirectsCacheKey(ownOptions);
|
|
37815
|
+
if (ownKey === key)
|
|
37816
|
+
result = ownMap;
|
|
37817
|
+
else if (!redirectsKeyToMap.has(ownKey))
|
|
37818
|
+
redirectsKeyToMap.set(ownKey, ownMap);
|
|
37819
|
+
}
|
|
37820
|
+
redirectsKeyToMap.set(key, result != null ? result : result = /* @__PURE__ */ new Map());
|
|
37748
37821
|
}
|
|
37749
|
-
|
|
37822
|
+
redirectsMap.set(redirectOptions, result);
|
|
37823
|
+
return result;
|
|
37750
37824
|
}
|
|
37751
37825
|
function clear2() {
|
|
37826
|
+
const ownKey = ownOptions && optionsToRedirectsKey.get(ownOptions);
|
|
37752
37827
|
ownMap.clear();
|
|
37753
37828
|
redirectsMap.clear();
|
|
37829
|
+
optionsToRedirectsKey.clear();
|
|
37830
|
+
redirectsKeyToMap.clear();
|
|
37831
|
+
if (ownOptions) {
|
|
37832
|
+
if (ownKey)
|
|
37833
|
+
optionsToRedirectsKey.set(ownOptions, ownKey);
|
|
37834
|
+
redirectsMap.set(ownOptions, ownMap);
|
|
37835
|
+
}
|
|
37836
|
+
}
|
|
37837
|
+
function getRedirectsCacheKey(options) {
|
|
37838
|
+
let result = optionsToRedirectsKey.get(options);
|
|
37839
|
+
if (!result) {
|
|
37840
|
+
optionsToRedirectsKey.set(options, result = getKeyForCompilerOptions(options, moduleResolutionOptionDeclarations));
|
|
37841
|
+
}
|
|
37842
|
+
return result;
|
|
37754
37843
|
}
|
|
37755
37844
|
}
|
|
37756
37845
|
function createPackageJsonInfoCache(currentDirectory, getCanonicalFileName) {
|
|
@@ -37782,27 +37871,6 @@ ${lanes.join("\n")}
|
|
|
37782
37871
|
}
|
|
37783
37872
|
return result;
|
|
37784
37873
|
}
|
|
37785
|
-
function updateRedirectsMap(options, directoryToModuleNameMap, moduleNameToDirectoryMap) {
|
|
37786
|
-
if (!options.configFile)
|
|
37787
|
-
return;
|
|
37788
|
-
if (directoryToModuleNameMap.redirectsMap.size === 0) {
|
|
37789
|
-
Debug.assert(!moduleNameToDirectoryMap || moduleNameToDirectoryMap.redirectsMap.size === 0);
|
|
37790
|
-
Debug.assert(directoryToModuleNameMap.getOwnMap().size === 0);
|
|
37791
|
-
Debug.assert(!moduleNameToDirectoryMap || moduleNameToDirectoryMap.getOwnMap().size === 0);
|
|
37792
|
-
directoryToModuleNameMap.redirectsMap.set(options.configFile.path, directoryToModuleNameMap.getOwnMap());
|
|
37793
|
-
moduleNameToDirectoryMap == null ? void 0 : moduleNameToDirectoryMap.redirectsMap.set(options.configFile.path, moduleNameToDirectoryMap.getOwnMap());
|
|
37794
|
-
} else {
|
|
37795
|
-
Debug.assert(!moduleNameToDirectoryMap || moduleNameToDirectoryMap.redirectsMap.size > 0);
|
|
37796
|
-
const ref = {
|
|
37797
|
-
sourceFile: options.configFile,
|
|
37798
|
-
commandLine: { options }
|
|
37799
|
-
};
|
|
37800
|
-
directoryToModuleNameMap.setOwnMap(directoryToModuleNameMap.getOrCreateMapOfCacheRedirects(ref));
|
|
37801
|
-
moduleNameToDirectoryMap == null ? void 0 : moduleNameToDirectoryMap.setOwnMap(moduleNameToDirectoryMap.getOrCreateMapOfCacheRedirects(ref));
|
|
37802
|
-
}
|
|
37803
|
-
directoryToModuleNameMap.setOwnOptions(options);
|
|
37804
|
-
moduleNameToDirectoryMap == null ? void 0 : moduleNameToDirectoryMap.setOwnOptions(options);
|
|
37805
|
-
}
|
|
37806
37874
|
function createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, directoryToModuleNameMap) {
|
|
37807
37875
|
return {
|
|
37808
37876
|
getOrCreateCacheForDirectory,
|
|
@@ -37813,13 +37881,16 @@ ${lanes.join("\n")}
|
|
|
37813
37881
|
directoryToModuleNameMap.clear();
|
|
37814
37882
|
}
|
|
37815
37883
|
function update(options) {
|
|
37816
|
-
|
|
37884
|
+
directoryToModuleNameMap.update(options);
|
|
37817
37885
|
}
|
|
37818
37886
|
function getOrCreateCacheForDirectory(directoryName, redirectedReference) {
|
|
37819
37887
|
const path = toPath(directoryName, currentDirectory, getCanonicalFileName);
|
|
37820
37888
|
return getOrCreateCache(directoryToModuleNameMap, redirectedReference, path, () => createModeAwareCache());
|
|
37821
37889
|
}
|
|
37822
37890
|
}
|
|
37891
|
+
function createModeAwareCacheKey(specifier, mode) {
|
|
37892
|
+
return mode === void 0 ? specifier : `${mode}|${specifier}`;
|
|
37893
|
+
}
|
|
37823
37894
|
function createModeAwareCache() {
|
|
37824
37895
|
const underlying = /* @__PURE__ */ new Map();
|
|
37825
37896
|
const memoizedReverseKeys = /* @__PURE__ */ new Map();
|
|
@@ -37850,7 +37921,7 @@ ${lanes.join("\n")}
|
|
|
37850
37921
|
};
|
|
37851
37922
|
return cache;
|
|
37852
37923
|
function getUnderlyingCacheKey(specifier, mode) {
|
|
37853
|
-
const result =
|
|
37924
|
+
const result = createModeAwareCacheKey(specifier, mode);
|
|
37854
37925
|
memoizedReverseKeys.set(result, [specifier, mode]);
|
|
37855
37926
|
return result;
|
|
37856
37927
|
}
|
|
@@ -37870,9 +37941,10 @@ ${lanes.join("\n")}
|
|
|
37870
37941
|
}
|
|
37871
37942
|
return map2;
|
|
37872
37943
|
}
|
|
37873
|
-
function createModuleResolutionCache(currentDirectory, getCanonicalFileName, options
|
|
37874
|
-
const
|
|
37875
|
-
|
|
37944
|
+
function createModuleResolutionCache(currentDirectory, getCanonicalFileName, options) {
|
|
37945
|
+
const directoryToModuleNameMap = createCacheWithRedirects(options);
|
|
37946
|
+
const perDirectoryResolutionCache = createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, directoryToModuleNameMap);
|
|
37947
|
+
const moduleNameToDirectoryMap = createCacheWithRedirects(options);
|
|
37876
37948
|
const packageJsonInfoCache = createPackageJsonInfoCache(currentDirectory, getCanonicalFileName);
|
|
37877
37949
|
return {
|
|
37878
37950
|
...packageJsonInfoCache,
|
|
@@ -37892,11 +37964,12 @@ ${lanes.join("\n")}
|
|
|
37892
37964
|
moduleNameToDirectoryMap.clear();
|
|
37893
37965
|
}
|
|
37894
37966
|
function update(options2) {
|
|
37895
|
-
|
|
37967
|
+
directoryToModuleNameMap.update(options2);
|
|
37968
|
+
moduleNameToDirectoryMap.update(options2);
|
|
37896
37969
|
}
|
|
37897
37970
|
function getOrCreateCacheForModuleName(nonRelativeModuleName, mode, redirectedReference) {
|
|
37898
37971
|
Debug.assert(!isExternalModuleNameRelative(nonRelativeModuleName));
|
|
37899
|
-
return getOrCreateCache(moduleNameToDirectoryMap, redirectedReference,
|
|
37972
|
+
return getOrCreateCache(moduleNameToDirectoryMap, redirectedReference, createModeAwareCacheKey(nonRelativeModuleName, mode), createPerModuleNameCache);
|
|
37900
37973
|
}
|
|
37901
37974
|
function createPerModuleNameCache() {
|
|
37902
37975
|
const directoryPathMap = /* @__PURE__ */ new Map();
|
|
@@ -37944,8 +38017,9 @@ ${lanes.join("\n")}
|
|
|
37944
38017
|
}
|
|
37945
38018
|
}
|
|
37946
38019
|
}
|
|
37947
|
-
function createTypeReferenceDirectiveResolutionCache(currentDirectory, getCanonicalFileName, options, packageJsonInfoCache
|
|
37948
|
-
const
|
|
38020
|
+
function createTypeReferenceDirectiveResolutionCache(currentDirectory, getCanonicalFileName, options, packageJsonInfoCache) {
|
|
38021
|
+
const directoryToModuleNameMap = createCacheWithRedirects(options);
|
|
38022
|
+
const perDirectoryResolutionCache = createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, directoryToModuleNameMap);
|
|
37949
38023
|
packageJsonInfoCache || (packageJsonInfoCache = createPackageJsonInfoCache(currentDirectory, getCanonicalFileName));
|
|
37950
38024
|
return {
|
|
37951
38025
|
...packageJsonInfoCache,
|
|
@@ -47713,7 +47787,7 @@ ${lanes.join("\n")}
|
|
|
47713
47787
|
}
|
|
47714
47788
|
const contextFile = getSourceFileOfNode(getOriginalNode(context.enclosingDeclaration));
|
|
47715
47789
|
const resolutionMode = overrideImportMode || (contextFile == null ? void 0 : contextFile.impliedNodeFormat);
|
|
47716
|
-
const cacheKey =
|
|
47790
|
+
const cacheKey = createModeAwareCacheKey(contextFile.path, resolutionMode);
|
|
47717
47791
|
const links = getSymbolLinks(symbol);
|
|
47718
47792
|
let specifier = links.specifierCache && links.specifierCache.get(cacheKey);
|
|
47719
47793
|
if (!specifier) {
|
|
@@ -47736,9 +47810,6 @@ ${lanes.join("\n")}
|
|
|
47736
47810
|
links.specifierCache.set(cacheKey, specifier);
|
|
47737
47811
|
}
|
|
47738
47812
|
return specifier;
|
|
47739
|
-
function getSpecifierCacheKey(path, mode) {
|
|
47740
|
-
return mode === void 0 ? path : `${mode}|${path}`;
|
|
47741
|
-
}
|
|
47742
47813
|
}
|
|
47743
47814
|
function symbolToEntityNameNode(symbol) {
|
|
47744
47815
|
const identifier = factory.createIdentifier(unescapeLeadingUnderscores(symbol.escapedName));
|
|
@@ -47952,8 +48023,7 @@ ${lanes.join("\n")}
|
|
|
47952
48023
|
if (isSingleOrDoubleQuote(firstChar) && some(symbol2.declarations, hasNonGlobalAugmentationExternalModuleSymbol)) {
|
|
47953
48024
|
return factory.createStringLiteral(getSpecifierForModuleSymbol(symbol2, context));
|
|
47954
48025
|
}
|
|
47955
|
-
|
|
47956
|
-
if (index === 0 || canUsePropertyAccess) {
|
|
48026
|
+
if (index === 0 || canUsePropertyAccess(symbolName2, languageVersion)) {
|
|
47957
48027
|
const identifier = setEmitFlags(factory.createIdentifier(symbolName2, typeParameterNodes), 33554432 /* NoAsciiEscaping */);
|
|
47958
48028
|
identifier.symbol = symbol2;
|
|
47959
48029
|
return index > 0 ? factory.createPropertyAccessExpression(createExpressionFromSymbolChain(chain2, index - 1), identifier) : identifier;
|
|
@@ -59383,7 +59453,8 @@ ${lanes.join("\n")}
|
|
|
59383
59453
|
return !!(type.flags & 109440 /* Unit */);
|
|
59384
59454
|
}
|
|
59385
59455
|
function isUnitLikeType(type) {
|
|
59386
|
-
|
|
59456
|
+
const t = getBaseConstraintOrType(type);
|
|
59457
|
+
return t.flags & 2097152 /* Intersection */ ? some(t.types, isUnitType) : isUnitType(t);
|
|
59387
59458
|
}
|
|
59388
59459
|
function extractUnitType(type) {
|
|
59389
59460
|
return type.flags & 2097152 /* Intersection */ ? find(type.types, isUnitType) || type : type;
|
|
@@ -60024,24 +60095,7 @@ ${lanes.join("\n")}
|
|
|
60024
60095
|
return isFinite(n) && (!roundTripOnly || "" + n === s);
|
|
60025
60096
|
}
|
|
60026
60097
|
function parseBigIntLiteralType(text) {
|
|
60027
|
-
|
|
60028
|
-
const base10Value = parsePseudoBigInt(`${negative ? text.slice(1) : text}n`);
|
|
60029
|
-
return getBigIntLiteralType({ negative, base10Value });
|
|
60030
|
-
}
|
|
60031
|
-
function isValidBigIntString(s, roundTripOnly) {
|
|
60032
|
-
if (s === "")
|
|
60033
|
-
return false;
|
|
60034
|
-
const scanner2 = createScanner(99 /* ESNext */, false);
|
|
60035
|
-
let success = true;
|
|
60036
|
-
scanner2.setOnError(() => success = false);
|
|
60037
|
-
scanner2.setText(s + "n");
|
|
60038
|
-
let result = scanner2.scan();
|
|
60039
|
-
const negative = result === 40 /* MinusToken */;
|
|
60040
|
-
if (negative) {
|
|
60041
|
-
result = scanner2.scan();
|
|
60042
|
-
}
|
|
60043
|
-
const flags = scanner2.getTokenFlags();
|
|
60044
|
-
return success && result === 9 /* BigIntLiteral */ && scanner2.getTextPos() === s.length + 1 && !(flags & 512 /* ContainsSeparator */) && (!roundTripOnly || s === pseudoBigIntToString({ negative, base10Value: parsePseudoBigInt(scanner2.getTokenValue()) }));
|
|
60098
|
+
return getBigIntLiteralType(parseValidBigInt(text));
|
|
60045
60099
|
}
|
|
60046
60100
|
function isMemberOfStringMapping(source, target) {
|
|
60047
60101
|
if (target.flags & (4 /* String */ | 1 /* Any */)) {
|
|
@@ -67513,11 +67567,11 @@ ${lanes.join("\n")}
|
|
|
67513
67567
|
}
|
|
67514
67568
|
function checkSatisfiesExpression(node) {
|
|
67515
67569
|
checkSourceElement(node.type);
|
|
67570
|
+
const exprType = checkExpression(node.expression);
|
|
67516
67571
|
const targetType = getTypeFromTypeNode(node.type);
|
|
67517
67572
|
if (isErrorType(targetType)) {
|
|
67518
67573
|
return targetType;
|
|
67519
67574
|
}
|
|
67520
|
-
const exprType = checkExpression(node.expression);
|
|
67521
67575
|
checkTypeAssignableToAndOptionallyElaborate(exprType, targetType, node.type, node.expression, Diagnostics.Type_0_does_not_satisfy_the_expected_type_1);
|
|
67522
67576
|
return exprType;
|
|
67523
67577
|
}
|
|
@@ -102390,16 +102444,15 @@ ${lanes.join("\n")}
|
|
|
102390
102444
|
return [];
|
|
102391
102445
|
}
|
|
102392
102446
|
const resolutions = [];
|
|
102393
|
-
const cache =
|
|
102447
|
+
const cache = createModeAwareCache();
|
|
102394
102448
|
for (const name of names) {
|
|
102395
102449
|
let result;
|
|
102396
102450
|
const mode = getModeForFileReference(name, containingFileMode);
|
|
102397
102451
|
const strName = getResolutionName(name);
|
|
102398
|
-
|
|
102399
|
-
|
|
102400
|
-
result = cache.get(cacheKey);
|
|
102452
|
+
if (cache.has(strName, mode)) {
|
|
102453
|
+
result = cache.get(strName, mode);
|
|
102401
102454
|
} else {
|
|
102402
|
-
cache.set(
|
|
102455
|
+
cache.set(strName, mode, result = loader(strName, containingFile, redirectedReference, mode));
|
|
102403
102456
|
}
|
|
102404
102457
|
resolutions.push(result);
|
|
102405
102458
|
}
|
|
@@ -102475,18 +102528,17 @@ ${lanes.join("\n")}
|
|
|
102475
102528
|
return [];
|
|
102476
102529
|
}
|
|
102477
102530
|
const resolutions = [];
|
|
102478
|
-
const cache =
|
|
102531
|
+
const cache = createModeAwareCache();
|
|
102479
102532
|
let i = 0;
|
|
102480
102533
|
for (const entry of resolutionInfo ? resolutionInfo.names : names) {
|
|
102481
102534
|
let result;
|
|
102482
102535
|
const mode = !isString(entry) ? getModeForUsageLocation(containingFile, entry) : getModeForResolutionAtIndex(containingFile, i);
|
|
102483
102536
|
i++;
|
|
102484
102537
|
const name = isString(entry) ? entry : entry.text;
|
|
102485
|
-
|
|
102486
|
-
|
|
102487
|
-
result = cache.get(cacheKey);
|
|
102538
|
+
if (cache.has(name, mode)) {
|
|
102539
|
+
result = cache.get(name, mode);
|
|
102488
102540
|
} else {
|
|
102489
|
-
cache.set(
|
|
102541
|
+
cache.set(name, mode, result = loader(name, mode, containingFileName, redirectedReference));
|
|
102490
102542
|
}
|
|
102491
102543
|
resolutions.push(result);
|
|
102492
102544
|
}
|
|
@@ -107012,23 +107064,17 @@ ${lanes.join("\n")}
|
|
|
107012
107064
|
const getCurrentDirectory = memoize(() => resolutionHost.getCurrentDirectory());
|
|
107013
107065
|
const cachedDirectoryStructureHost = resolutionHost.getCachedDirectoryStructureHost();
|
|
107014
107066
|
const resolvedModuleNames = /* @__PURE__ */ new Map();
|
|
107015
|
-
const perDirectoryResolvedModuleNames = createCacheWithRedirects();
|
|
107016
|
-
const nonRelativeModuleNameCache = createCacheWithRedirects();
|
|
107017
107067
|
const moduleResolutionCache = createModuleResolutionCache(
|
|
107018
107068
|
getCurrentDirectory(),
|
|
107019
107069
|
resolutionHost.getCanonicalFileName,
|
|
107020
|
-
|
|
107021
|
-
perDirectoryResolvedModuleNames,
|
|
107022
|
-
nonRelativeModuleNameCache
|
|
107070
|
+
resolutionHost.getCompilationSettings()
|
|
107023
107071
|
);
|
|
107024
107072
|
const resolvedTypeReferenceDirectives = /* @__PURE__ */ new Map();
|
|
107025
|
-
const perDirectoryResolvedTypeReferenceDirectives = createCacheWithRedirects();
|
|
107026
107073
|
const typeReferenceDirectiveResolutionCache = createTypeReferenceDirectiveResolutionCache(
|
|
107027
107074
|
getCurrentDirectory(),
|
|
107028
107075
|
resolutionHost.getCanonicalFileName,
|
|
107029
|
-
|
|
107030
|
-
moduleResolutionCache.getPackageJsonInfoCache()
|
|
107031
|
-
perDirectoryResolvedTypeReferenceDirectives
|
|
107076
|
+
resolutionHost.getCompilationSettings(),
|
|
107077
|
+
moduleResolutionCache.getPackageJsonInfoCache()
|
|
107032
107078
|
);
|
|
107033
107079
|
const failedLookupDefaultExtensions = [".ts" /* Ts */, ".tsx" /* Tsx */, ".js" /* Js */, ".jsx" /* Jsx */, ".json" /* Json */];
|
|
107034
107080
|
const customFailedLookupPaths = /* @__PURE__ */ new Map();
|
|
@@ -107089,6 +107135,8 @@ ${lanes.join("\n")}
|
|
|
107089
107135
|
affectingPathChecksForFile = void 0;
|
|
107090
107136
|
moduleResolutionCache.clear();
|
|
107091
107137
|
typeReferenceDirectiveResolutionCache.clear();
|
|
107138
|
+
moduleResolutionCache.update(resolutionHost.getCompilationSettings());
|
|
107139
|
+
typeReferenceDirectiveResolutionCache.update(resolutionHost.getCompilationSettings());
|
|
107092
107140
|
impliedFormatPackageJsons.clear();
|
|
107093
107141
|
hasChangedAutomaticTypeDirectiveNames = false;
|
|
107094
107142
|
}
|
|
@@ -107193,8 +107241,7 @@ ${lanes.join("\n")}
|
|
|
107193
107241
|
names,
|
|
107194
107242
|
containingFile,
|
|
107195
107243
|
redirectedReference,
|
|
107196
|
-
|
|
107197
|
-
perDirectoryCacheWithRedirects,
|
|
107244
|
+
perFileCache,
|
|
107198
107245
|
loader,
|
|
107199
107246
|
getResolutionWithResolvedFileName,
|
|
107200
107247
|
shouldRetryResolution,
|
|
@@ -107204,16 +107251,9 @@ ${lanes.join("\n")}
|
|
|
107204
107251
|
containingSourceFile,
|
|
107205
107252
|
containingSourceFileMode
|
|
107206
107253
|
}) {
|
|
107207
|
-
var _a2, _b, _c
|
|
107254
|
+
var _a2, _b, _c;
|
|
107208
107255
|
const path = resolutionHost.toPath(containingFile);
|
|
107209
|
-
const resolutionsInFile =
|
|
107210
|
-
const dirPath = getDirectoryPath(path);
|
|
107211
|
-
const perDirectoryCache = perDirectoryCacheWithRedirects.getOrCreateMapOfCacheRedirects(redirectedReference);
|
|
107212
|
-
let perDirectoryResolution = perDirectoryCache.get(dirPath);
|
|
107213
|
-
if (!perDirectoryResolution) {
|
|
107214
|
-
perDirectoryResolution = createModeAwareCache();
|
|
107215
|
-
perDirectoryCache.set(dirPath, perDirectoryResolution);
|
|
107216
|
-
}
|
|
107256
|
+
const resolutionsInFile = perFileCache.get(path) || perFileCache.set(path, createModeAwareCache()).get(path);
|
|
107217
107257
|
const resolvedModules = [];
|
|
107218
107258
|
const compilerOptions = resolutionHost.getCompilationSettings();
|
|
107219
107259
|
const hasInvalidatedNonRelativeUnresolvedImport = logChanges && isFileWithInvalidatedNonRelativeUnresolvedImports(path);
|
|
@@ -107229,28 +107269,9 @@ ${lanes.join("\n")}
|
|
|
107229
107269
|
let resolution = resolutionsInFile.get(name, mode);
|
|
107230
107270
|
if (!seenNamesInFile.has(name, mode) && unmatchedRedirects || !resolution || resolution.isInvalidated || hasInvalidatedNonRelativeUnresolvedImport && !isExternalModuleNameRelative(name) && shouldRetryResolution(resolution)) {
|
|
107231
107271
|
const existingResolution = resolution;
|
|
107232
|
-
|
|
107233
|
-
if (
|
|
107234
|
-
|
|
107235
|
-
const host = ((_a2 = resolutionHost.getCompilerHost) == null ? void 0 : _a2.call(resolutionHost)) || resolutionHost;
|
|
107236
|
-
if (isTraceEnabled(compilerOptions, host)) {
|
|
107237
|
-
const resolved = getResolutionWithResolvedFileName(resolution);
|
|
107238
|
-
trace(
|
|
107239
|
-
host,
|
|
107240
|
-
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,
|
|
107241
|
-
name,
|
|
107242
|
-
containingFile,
|
|
107243
|
-
getDirectoryPath(containingFile),
|
|
107244
|
-
resolved == null ? void 0 : resolved.resolvedFileName,
|
|
107245
|
-
(resolved == null ? void 0 : resolved.packageId) && packageIdToString(resolved.packageId)
|
|
107246
|
-
);
|
|
107247
|
-
}
|
|
107248
|
-
} else {
|
|
107249
|
-
resolution = loader(name, containingFile, compilerOptions, ((_b = resolutionHost.getCompilerHost) == null ? void 0 : _b.call(resolutionHost)) || resolutionHost, redirectedReference, containingSourceFile, mode);
|
|
107250
|
-
perDirectoryResolution.set(name, mode, resolution);
|
|
107251
|
-
if (resolutionHost.onDiscoveredSymlink && resolutionIsSymlink(resolution)) {
|
|
107252
|
-
resolutionHost.onDiscoveredSymlink();
|
|
107253
|
-
}
|
|
107272
|
+
resolution = loader(name, containingFile, compilerOptions, ((_a2 = resolutionHost.getCompilerHost) == null ? void 0 : _a2.call(resolutionHost)) || resolutionHost, redirectedReference, containingSourceFile, mode);
|
|
107273
|
+
if (resolutionHost.onDiscoveredSymlink && resolutionIsSymlink(resolution)) {
|
|
107274
|
+
resolutionHost.onDiscoveredSymlink();
|
|
107254
107275
|
}
|
|
107255
107276
|
resolutionsInFile.set(name, mode, resolution);
|
|
107256
107277
|
watchFailedLookupLocationsOfExternalModuleResolutions(name, resolution, path, getResolutionWithResolvedFileName);
|
|
@@ -107262,7 +107283,7 @@ ${lanes.join("\n")}
|
|
|
107262
107283
|
logChanges = false;
|
|
107263
107284
|
}
|
|
107264
107285
|
} else {
|
|
107265
|
-
const host = ((
|
|
107286
|
+
const host = ((_b = resolutionHost.getCompilerHost) == null ? void 0 : _b.call(resolutionHost)) || resolutionHost;
|
|
107266
107287
|
if (isTraceEnabled(compilerOptions, host) && !seenNamesInFile.has(name, mode)) {
|
|
107267
107288
|
const resolved = getResolutionWithResolvedFileName(resolution);
|
|
107268
107289
|
trace(
|
|
@@ -107280,7 +107301,7 @@ ${lanes.join("\n")}
|
|
|
107280
107301
|
resolvedModules.push(getResolutionWithResolvedFileName(resolution));
|
|
107281
107302
|
}
|
|
107282
107303
|
if (resolutionInfo && (loader === resolveTypeReferenceDirective2 || containingSourceFile)) {
|
|
107283
|
-
(
|
|
107304
|
+
(_c = resolutionInfo.reusedNames) == null ? void 0 : _c.forEach((entry) => seenNamesInFile.set(
|
|
107284
107305
|
getResolutionName(entry),
|
|
107285
107306
|
!isString(entry) && isStringLiteralLike(entry) ? getModeForUsageLocation(containingSourceFile, entry) : getModeForFileReference(entry, containingSourceFileMode),
|
|
107286
107307
|
true
|
|
@@ -107319,8 +107340,7 @@ ${lanes.join("\n")}
|
|
|
107319
107340
|
names: typeDirectiveNames,
|
|
107320
107341
|
containingFile,
|
|
107321
107342
|
redirectedReference,
|
|
107322
|
-
|
|
107323
|
-
perDirectoryCacheWithRedirects: perDirectoryResolvedTypeReferenceDirectives,
|
|
107343
|
+
perFileCache: resolvedTypeReferenceDirectives,
|
|
107324
107344
|
loader: resolveTypeReferenceDirective2,
|
|
107325
107345
|
getResolutionWithResolvedFileName: getResolvedTypeReferenceDirective2,
|
|
107326
107346
|
shouldRetryResolution: (resolution) => resolution.resolvedTypeReferenceDirective === void 0,
|
|
@@ -107333,8 +107353,7 @@ ${lanes.join("\n")}
|
|
|
107333
107353
|
names: moduleNames,
|
|
107334
107354
|
containingFile,
|
|
107335
107355
|
redirectedReference,
|
|
107336
|
-
|
|
107337
|
-
perDirectoryCacheWithRedirects: perDirectoryResolvedModuleNames,
|
|
107356
|
+
perFileCache: resolvedModuleNames,
|
|
107338
107357
|
loader: resolveModuleName2,
|
|
107339
107358
|
getResolutionWithResolvedFileName: getResolvedModule2,
|
|
107340
107359
|
shouldRetryResolution: (resolution) => !resolution.resolvedModule || !resolutionExtensionIsTSOrJson(resolution.resolvedModule.extension),
|
|
@@ -108704,7 +108723,7 @@ ${lanes.join("\n")}
|
|
|
108704
108723
|
if (hostSourceFile.version)
|
|
108705
108724
|
return hostSourceFile.version;
|
|
108706
108725
|
const text = readFileWithCache(path);
|
|
108707
|
-
return text ? getSourceFileVersionAsHashFromText(compilerHost, text) : void 0;
|
|
108726
|
+
return text !== void 0 ? getSourceFileVersionAsHashFromText(compilerHost, text) : void 0;
|
|
108708
108727
|
}
|
|
108709
108728
|
function onReleaseOldSourceFile(oldSourceFile, _oldOptions, hasSourceFileByPath) {
|
|
108710
108729
|
const hostSourceFileInfo = sourceFilesCache.get(oldSourceFile.resolvedPath);
|
|
@@ -110240,7 +110259,7 @@ ${lanes.join("\n")}
|
|
|
110240
110259
|
buildInfoVersionMap = getBuildInfoFileVersionMap(buildInfoProgram, buildInfoPath, host);
|
|
110241
110260
|
version2 = buildInfoVersionMap.get(toPath2(state, inputFile));
|
|
110242
110261
|
const text = version2 ? state.readFileWithCache(inputFile) : void 0;
|
|
110243
|
-
currentVersion = text
|
|
110262
|
+
currentVersion = text !== void 0 ? getSourceFileVersionAsHashFromText(host, text) : void 0;
|
|
110244
110263
|
if (version2 && version2 === currentVersion)
|
|
110245
110264
|
pseudoInputUpToDate = true;
|
|
110246
110265
|
}
|
|
@@ -111583,6 +111602,7 @@ ${lanes.join("\n")}
|
|
|
111583
111602
|
canHaveModifiers: () => canHaveModifiers,
|
|
111584
111603
|
canJsonReportNoInputFiles: () => canJsonReportNoInputFiles,
|
|
111585
111604
|
canProduceDiagnostics: () => canProduceDiagnostics,
|
|
111605
|
+
canUsePropertyAccess: () => canUsePropertyAccess,
|
|
111586
111606
|
canWatchDirectoryOrFile: () => canWatchDirectoryOrFile,
|
|
111587
111607
|
cartesianProduct: () => cartesianProduct,
|
|
111588
111608
|
cast: () => cast,
|
|
@@ -111859,6 +111879,7 @@ ${lanes.join("\n")}
|
|
|
111859
111879
|
createMethod: () => createMethod,
|
|
111860
111880
|
createMethodSignature: () => createMethodSignature,
|
|
111861
111881
|
createModeAwareCache: () => createModeAwareCache,
|
|
111882
|
+
createModeAwareCacheKey: () => createModeAwareCacheKey,
|
|
111862
111883
|
createModifier: () => createModifier,
|
|
111863
111884
|
createModifiersFromModifierFlags: () => createModifiersFromModifierFlags,
|
|
111864
111885
|
createModuleBlock: () => createModuleBlock,
|
|
@@ -112338,6 +112359,7 @@ ${lanes.join("\n")}
|
|
|
112338
112359
|
getJSXImplicitImportBase: () => getJSXImplicitImportBase,
|
|
112339
112360
|
getJSXRuntimeImport: () => getJSXRuntimeImport,
|
|
112340
112361
|
getJSXTransformEnabled: () => getJSXTransformEnabled,
|
|
112362
|
+
getKeyForCompilerOptions: () => getKeyForCompilerOptions,
|
|
112341
112363
|
getLanguageVariant: () => getLanguageVariant,
|
|
112342
112364
|
getLastChild: () => getLastChild,
|
|
112343
112365
|
getLeadingCommentRanges: () => getLeadingCommentRanges,
|
|
@@ -112609,6 +112631,7 @@ ${lanes.join("\n")}
|
|
|
112609
112631
|
hasSyntacticModifier: () => hasSyntacticModifier,
|
|
112610
112632
|
hasSyntacticModifiers: () => hasSyntacticModifiers,
|
|
112611
112633
|
hasTSFileExtension: () => hasTSFileExtension,
|
|
112634
|
+
hasTabstop: () => hasTabstop,
|
|
112612
112635
|
hasTrailingDirectorySeparator: () => hasTrailingDirectorySeparator,
|
|
112613
112636
|
hasType: () => hasType,
|
|
112614
112637
|
hasTypeArguments: () => hasTypeArguments,
|
|
@@ -113258,6 +113281,7 @@ ${lanes.join("\n")}
|
|
|
113258
113281
|
isUnparsedSource: () => isUnparsedSource,
|
|
113259
113282
|
isUnparsedTextLike: () => isUnparsedTextLike,
|
|
113260
113283
|
isUrl: () => isUrl,
|
|
113284
|
+
isValidBigIntString: () => isValidBigIntString,
|
|
113261
113285
|
isValidESSymbolDeclaration: () => isValidESSymbolDeclaration,
|
|
113262
113286
|
isValidTypeOnlyAliasUseSite: () => isValidTypeOnlyAliasUseSite,
|
|
113263
113287
|
isValueSignatureDeclaration: () => isValueSignatureDeclaration,
|
|
@@ -113389,6 +113413,7 @@ ${lanes.join("\n")}
|
|
|
113389
113413
|
parameterIsThisKeyword: () => parameterIsThisKeyword,
|
|
113390
113414
|
parameterNamePart: () => parameterNamePart,
|
|
113391
113415
|
parseBaseNodeFactory: () => parseBaseNodeFactory,
|
|
113416
|
+
parseBigInt: () => parseBigInt,
|
|
113392
113417
|
parseBuildCommand: () => parseBuildCommand,
|
|
113393
113418
|
parseCommandLine: () => parseCommandLine,
|
|
113394
113419
|
parseCommandLineWorker: () => parseCommandLineWorker,
|
|
@@ -113407,6 +113432,7 @@ ${lanes.join("\n")}
|
|
|
113407
113432
|
parseNodeModuleFromPath: () => parseNodeModuleFromPath,
|
|
113408
113433
|
parsePackageName: () => parsePackageName,
|
|
113409
113434
|
parsePseudoBigInt: () => parsePseudoBigInt,
|
|
113435
|
+
parseValidBigInt: () => parseValidBigInt,
|
|
113410
113436
|
patchWriteFileEnsuringDirectory: () => patchWriteFileEnsuringDirectory,
|
|
113411
113437
|
pathContainsNodeModules: () => pathContainsNodeModules,
|
|
113412
113438
|
pathIsAbsolute: () => pathIsAbsolute,
|
|
@@ -118495,24 +118521,8 @@ ${lanes.join("\n")}
|
|
|
118495
118521
|
getKeyForCompilationSettings
|
|
118496
118522
|
};
|
|
118497
118523
|
}
|
|
118498
|
-
function compilerOptionValueToString(value) {
|
|
118499
|
-
var _a2;
|
|
118500
|
-
if (value === null || typeof value !== "object") {
|
|
118501
|
-
return "" + value;
|
|
118502
|
-
}
|
|
118503
|
-
if (isArray(value)) {
|
|
118504
|
-
return `[${(_a2 = map(value, (e) => compilerOptionValueToString(e))) == null ? void 0 : _a2.join(",")}]`;
|
|
118505
|
-
}
|
|
118506
|
-
let str = "{";
|
|
118507
|
-
for (const key in value) {
|
|
118508
|
-
if (hasProperty(value, key)) {
|
|
118509
|
-
str += `${key}: ${compilerOptionValueToString(value[key])}`;
|
|
118510
|
-
}
|
|
118511
|
-
}
|
|
118512
|
-
return str + "}";
|
|
118513
|
-
}
|
|
118514
118524
|
function getKeyForCompilationSettings(settings) {
|
|
118515
|
-
return
|
|
118525
|
+
return getKeyForCompilerOptions(settings, sourceFileAffectingCompilerOptions);
|
|
118516
118526
|
}
|
|
118517
118527
|
function getDocumentRegistryBucketKeyWithMode(key, mode) {
|
|
118518
118528
|
return mode ? `${key}|${mode}` : key;
|
|
@@ -120727,6 +120737,9 @@ ${lanes.join("\n")}
|
|
|
120727
120737
|
const textPos = scanner.getTextPos();
|
|
120728
120738
|
if (textPos <= end) {
|
|
120729
120739
|
if (token === 79 /* Identifier */) {
|
|
120740
|
+
if (hasTabstop(parent2)) {
|
|
120741
|
+
continue;
|
|
120742
|
+
}
|
|
120730
120743
|
Debug.fail(`Did not expect ${Debug.formatSyntaxKind(parent2.kind)} to have an Identifier in its trivia`);
|
|
120731
120744
|
}
|
|
120732
120745
|
nodes.push(createNode(token, pos, textPos, parent2));
|
|
@@ -133121,6 +133134,7 @@ ${lanes.join("\n")}
|
|
|
133121
133134
|
CompletionSource2["ClassMemberSnippet"] = "ClassMemberSnippet/";
|
|
133122
133135
|
CompletionSource2["TypeOnlyAlias"] = "TypeOnlyAlias/";
|
|
133123
133136
|
CompletionSource2["ObjectLiteralMethodSnippet"] = "ObjectLiteralMethodSnippet/";
|
|
133137
|
+
CompletionSource2["SwitchCases"] = "SwitchCases/";
|
|
133124
133138
|
return CompletionSource2;
|
|
133125
133139
|
})(CompletionSource || {});
|
|
133126
133140
|
var SymbolOriginInfoKind = /* @__PURE__ */ ((SymbolOriginInfoKind2) => {
|
|
@@ -133451,6 +133465,13 @@ ${lanes.join("\n")}
|
|
|
133451
133465
|
if (!isChecked) {
|
|
133452
133466
|
getJSCompletionEntries(sourceFile, location2.pos, uniqueNames, getEmitScriptTarget(compilerOptions), entries);
|
|
133453
133467
|
}
|
|
133468
|
+
let caseBlock;
|
|
133469
|
+
if (preferences.includeCompletionsWithInsertText && contextToken && (caseBlock = findAncestor(contextToken, isCaseBlock))) {
|
|
133470
|
+
const cases = getExhaustiveCaseSnippets(caseBlock, sourceFile, preferences, compilerOptions, host, program, formatContext);
|
|
133471
|
+
if (cases) {
|
|
133472
|
+
entries.push(cases.entry);
|
|
133473
|
+
}
|
|
133474
|
+
}
|
|
133454
133475
|
return {
|
|
133455
133476
|
flags: completionData.flags,
|
|
133456
133477
|
isGlobalCompletion: isInSnippetScope,
|
|
@@ -133464,6 +133485,187 @@ ${lanes.join("\n")}
|
|
|
133464
133485
|
function isCheckedFile(sourceFile, compilerOptions) {
|
|
133465
133486
|
return !isSourceFileJS(sourceFile) || !!isCheckJsEnabledForFile(sourceFile, compilerOptions);
|
|
133466
133487
|
}
|
|
133488
|
+
function getExhaustiveCaseSnippets(caseBlock, sourceFile, preferences, options, host, program, formatContext) {
|
|
133489
|
+
const clauses = caseBlock.clauses;
|
|
133490
|
+
const checker = program.getTypeChecker();
|
|
133491
|
+
const switchType = checker.getTypeAtLocation(caseBlock.parent.expression);
|
|
133492
|
+
if (switchType && switchType.isUnion() && every(switchType.types, (type) => type.isLiteral())) {
|
|
133493
|
+
const tracker = newCaseClauseTracker(checker, clauses);
|
|
133494
|
+
const target = getEmitScriptTarget(options);
|
|
133495
|
+
const quotePreference = getQuotePreference(sourceFile, preferences);
|
|
133496
|
+
const importAdder = ts_codefix_exports.createImportAdder(sourceFile, program, preferences, host);
|
|
133497
|
+
const elements = [];
|
|
133498
|
+
for (const type of switchType.types) {
|
|
133499
|
+
if (type.flags & 1024 /* EnumLiteral */) {
|
|
133500
|
+
Debug.assert(type.symbol, "An enum member type should have a symbol");
|
|
133501
|
+
Debug.assert(type.symbol.parent, "An enum member type should have a parent symbol (the enum symbol)");
|
|
133502
|
+
const enumValue = type.symbol.valueDeclaration && checker.getConstantValue(type.symbol.valueDeclaration);
|
|
133503
|
+
if (enumValue !== void 0) {
|
|
133504
|
+
if (tracker.hasValue(enumValue)) {
|
|
133505
|
+
continue;
|
|
133506
|
+
}
|
|
133507
|
+
tracker.addValue(enumValue);
|
|
133508
|
+
}
|
|
133509
|
+
const typeNode = ts_codefix_exports.typeToAutoImportableTypeNode(checker, importAdder, type, caseBlock, target);
|
|
133510
|
+
if (!typeNode) {
|
|
133511
|
+
return void 0;
|
|
133512
|
+
}
|
|
133513
|
+
const expr = typeNodeToExpression(typeNode, target, quotePreference);
|
|
133514
|
+
if (!expr) {
|
|
133515
|
+
return void 0;
|
|
133516
|
+
}
|
|
133517
|
+
elements.push(expr);
|
|
133518
|
+
} else if (!tracker.hasValue(type.value)) {
|
|
133519
|
+
switch (typeof type.value) {
|
|
133520
|
+
case "object":
|
|
133521
|
+
elements.push(factory.createBigIntLiteral(type.value));
|
|
133522
|
+
break;
|
|
133523
|
+
case "number":
|
|
133524
|
+
elements.push(factory.createNumericLiteral(type.value));
|
|
133525
|
+
break;
|
|
133526
|
+
case "string":
|
|
133527
|
+
elements.push(factory.createStringLiteral(type.value));
|
|
133528
|
+
break;
|
|
133529
|
+
}
|
|
133530
|
+
}
|
|
133531
|
+
}
|
|
133532
|
+
if (elements.length === 0) {
|
|
133533
|
+
return void 0;
|
|
133534
|
+
}
|
|
133535
|
+
const newClauses = map(elements, (element) => factory.createCaseClause(element, []));
|
|
133536
|
+
const newLineChar = getNewLineCharacter(options, maybeBind(host, host.getNewLine));
|
|
133537
|
+
const printer = createSnippetPrinter({
|
|
133538
|
+
removeComments: true,
|
|
133539
|
+
module: options.module,
|
|
133540
|
+
target: options.target,
|
|
133541
|
+
newLine: getNewLineKind(newLineChar)
|
|
133542
|
+
});
|
|
133543
|
+
const printNode = formatContext ? (node) => printer.printAndFormatNode(4 /* Unspecified */, node, sourceFile, formatContext) : (node) => printer.printNode(4 /* Unspecified */, node, sourceFile);
|
|
133544
|
+
const insertText = map(newClauses, (clause, i) => {
|
|
133545
|
+
if (preferences.includeCompletionsWithSnippetText) {
|
|
133546
|
+
return `${printNode(clause)}$${i + 1}`;
|
|
133547
|
+
}
|
|
133548
|
+
return `${printNode(clause)}`;
|
|
133549
|
+
}).join(newLineChar);
|
|
133550
|
+
const firstClause = printer.printNode(4 /* Unspecified */, newClauses[0], sourceFile);
|
|
133551
|
+
return {
|
|
133552
|
+
entry: {
|
|
133553
|
+
name: `${firstClause} ...`,
|
|
133554
|
+
kind: "" /* unknown */,
|
|
133555
|
+
sortText: SortText.GlobalsOrKeywords,
|
|
133556
|
+
insertText,
|
|
133557
|
+
hasAction: importAdder.hasFixes() || void 0,
|
|
133558
|
+
source: "SwitchCases/" /* SwitchCases */,
|
|
133559
|
+
isSnippet: preferences.includeCompletionsWithSnippetText ? true : void 0
|
|
133560
|
+
},
|
|
133561
|
+
importAdder
|
|
133562
|
+
};
|
|
133563
|
+
}
|
|
133564
|
+
return void 0;
|
|
133565
|
+
}
|
|
133566
|
+
function newCaseClauseTracker(checker, clauses) {
|
|
133567
|
+
const existingStrings = /* @__PURE__ */ new Set();
|
|
133568
|
+
const existingNumbers = /* @__PURE__ */ new Set();
|
|
133569
|
+
const existingBigInts = /* @__PURE__ */ new Set();
|
|
133570
|
+
for (const clause of clauses) {
|
|
133571
|
+
if (!isDefaultClause(clause)) {
|
|
133572
|
+
if (isLiteralExpression(clause.expression)) {
|
|
133573
|
+
const expression = clause.expression;
|
|
133574
|
+
switch (expression.kind) {
|
|
133575
|
+
case 14 /* NoSubstitutionTemplateLiteral */:
|
|
133576
|
+
case 10 /* StringLiteral */:
|
|
133577
|
+
existingStrings.add(expression.text);
|
|
133578
|
+
break;
|
|
133579
|
+
case 8 /* NumericLiteral */:
|
|
133580
|
+
existingNumbers.add(parseInt(expression.text));
|
|
133581
|
+
break;
|
|
133582
|
+
case 9 /* BigIntLiteral */:
|
|
133583
|
+
const parsedBigInt = parseBigInt(endsWith(expression.text, "n") ? expression.text.slice(0, -1) : expression.text);
|
|
133584
|
+
if (parsedBigInt) {
|
|
133585
|
+
existingBigInts.add(pseudoBigIntToString(parsedBigInt));
|
|
133586
|
+
}
|
|
133587
|
+
break;
|
|
133588
|
+
}
|
|
133589
|
+
} else {
|
|
133590
|
+
const symbol = checker.getSymbolAtLocation(clause.expression);
|
|
133591
|
+
if (symbol && symbol.valueDeclaration && isEnumMember(symbol.valueDeclaration)) {
|
|
133592
|
+
const enumValue = checker.getConstantValue(symbol.valueDeclaration);
|
|
133593
|
+
if (enumValue !== void 0) {
|
|
133594
|
+
addValue(enumValue);
|
|
133595
|
+
}
|
|
133596
|
+
}
|
|
133597
|
+
}
|
|
133598
|
+
}
|
|
133599
|
+
}
|
|
133600
|
+
return {
|
|
133601
|
+
addValue,
|
|
133602
|
+
hasValue
|
|
133603
|
+
};
|
|
133604
|
+
function addValue(value) {
|
|
133605
|
+
switch (typeof value) {
|
|
133606
|
+
case "string":
|
|
133607
|
+
existingStrings.add(value);
|
|
133608
|
+
break;
|
|
133609
|
+
case "number":
|
|
133610
|
+
existingNumbers.add(value);
|
|
133611
|
+
}
|
|
133612
|
+
}
|
|
133613
|
+
function hasValue(value) {
|
|
133614
|
+
switch (typeof value) {
|
|
133615
|
+
case "string":
|
|
133616
|
+
return existingStrings.has(value);
|
|
133617
|
+
case "number":
|
|
133618
|
+
return existingNumbers.has(value);
|
|
133619
|
+
case "object":
|
|
133620
|
+
return existingBigInts.has(pseudoBigIntToString(value));
|
|
133621
|
+
}
|
|
133622
|
+
}
|
|
133623
|
+
}
|
|
133624
|
+
function typeNodeToExpression(typeNode, languageVersion, quotePreference) {
|
|
133625
|
+
switch (typeNode.kind) {
|
|
133626
|
+
case 180 /* TypeReference */:
|
|
133627
|
+
const typeName = typeNode.typeName;
|
|
133628
|
+
return entityNameToExpression(typeName, languageVersion, quotePreference);
|
|
133629
|
+
case 196 /* IndexedAccessType */:
|
|
133630
|
+
const objectExpression = typeNodeToExpression(typeNode.objectType, languageVersion, quotePreference);
|
|
133631
|
+
const indexExpression = typeNodeToExpression(typeNode.indexType, languageVersion, quotePreference);
|
|
133632
|
+
return objectExpression && indexExpression && factory.createElementAccessExpression(objectExpression, indexExpression);
|
|
133633
|
+
case 198 /* LiteralType */:
|
|
133634
|
+
const literal = typeNode.literal;
|
|
133635
|
+
switch (literal.kind) {
|
|
133636
|
+
case 10 /* StringLiteral */:
|
|
133637
|
+
return factory.createStringLiteral(literal.text, quotePreference === 0 /* Single */);
|
|
133638
|
+
case 8 /* NumericLiteral */:
|
|
133639
|
+
return factory.createNumericLiteral(literal.text, literal.numericLiteralFlags);
|
|
133640
|
+
}
|
|
133641
|
+
return void 0;
|
|
133642
|
+
case 193 /* ParenthesizedType */:
|
|
133643
|
+
const exp = typeNodeToExpression(typeNode.type, languageVersion, quotePreference);
|
|
133644
|
+
return exp && (isIdentifier(exp) ? exp : factory.createParenthesizedExpression(exp));
|
|
133645
|
+
case 183 /* TypeQuery */:
|
|
133646
|
+
return entityNameToExpression(typeNode.exprName, languageVersion, quotePreference);
|
|
133647
|
+
case 202 /* ImportType */:
|
|
133648
|
+
Debug.fail(`We should not get an import type after calling 'codefix.typeToAutoImportableTypeNode'.`);
|
|
133649
|
+
}
|
|
133650
|
+
return void 0;
|
|
133651
|
+
}
|
|
133652
|
+
function entityNameToExpression(entityName, languageVersion, quotePreference) {
|
|
133653
|
+
if (isIdentifier(entityName)) {
|
|
133654
|
+
return entityName;
|
|
133655
|
+
}
|
|
133656
|
+
const unescapedName = unescapeLeadingUnderscores(entityName.right.escapedText);
|
|
133657
|
+
if (canUsePropertyAccess(unescapedName, languageVersion)) {
|
|
133658
|
+
return factory.createPropertyAccessExpression(
|
|
133659
|
+
entityNameToExpression(entityName.left, languageVersion, quotePreference),
|
|
133660
|
+
unescapedName
|
|
133661
|
+
);
|
|
133662
|
+
} else {
|
|
133663
|
+
return factory.createElementAccessExpression(
|
|
133664
|
+
entityNameToExpression(entityName.left, languageVersion, quotePreference),
|
|
133665
|
+
factory.createStringLiteral(unescapedName, quotePreference === 0 /* Single */)
|
|
133666
|
+
);
|
|
133667
|
+
}
|
|
133668
|
+
}
|
|
133467
133669
|
function isMemberCompletionKind(kind) {
|
|
133468
133670
|
switch (kind) {
|
|
133469
133671
|
case CompletionKind.ObjectPropertyDeclaration:
|
|
@@ -133870,7 +134072,9 @@ ${lanes.join("\n")}
|
|
|
133870
134072
|
};
|
|
133871
134073
|
return {
|
|
133872
134074
|
printSnippetList,
|
|
133873
|
-
printAndFormatSnippetList
|
|
134075
|
+
printAndFormatSnippetList,
|
|
134076
|
+
printNode,
|
|
134077
|
+
printAndFormatNode
|
|
133874
134078
|
};
|
|
133875
134079
|
function escapingWrite(s, write) {
|
|
133876
134080
|
const escaped = escapeSnippetText(s);
|
|
@@ -133919,6 +134123,40 @@ ${lanes.join("\n")}
|
|
|
133919
134123
|
const allChanges = escapes ? stableSort(concatenate(changes, escapes), (a, b) => compareTextSpans(a.span, b.span)) : changes;
|
|
133920
134124
|
return ts_textChanges_exports.applyChanges(syntheticFile.text, allChanges);
|
|
133921
134125
|
}
|
|
134126
|
+
function printNode(hint, node, sourceFile) {
|
|
134127
|
+
const unescaped = printUnescapedNode(hint, node, sourceFile);
|
|
134128
|
+
return escapes ? ts_textChanges_exports.applyChanges(unescaped, escapes) : unescaped;
|
|
134129
|
+
}
|
|
134130
|
+
function printUnescapedNode(hint, node, sourceFile) {
|
|
134131
|
+
escapes = void 0;
|
|
134132
|
+
writer.clear();
|
|
134133
|
+
printer.writeNode(hint, node, sourceFile, writer);
|
|
134134
|
+
return writer.getText();
|
|
134135
|
+
}
|
|
134136
|
+
function printAndFormatNode(hint, node, sourceFile, formatContext) {
|
|
134137
|
+
const syntheticFile = {
|
|
134138
|
+
text: printUnescapedNode(
|
|
134139
|
+
hint,
|
|
134140
|
+
node,
|
|
134141
|
+
sourceFile
|
|
134142
|
+
),
|
|
134143
|
+
getLineAndCharacterOfPosition(pos) {
|
|
134144
|
+
return getLineAndCharacterOfPosition(this, pos);
|
|
134145
|
+
}
|
|
134146
|
+
};
|
|
134147
|
+
const formatOptions = getFormatCodeSettingsForWriting(formatContext, sourceFile);
|
|
134148
|
+
const nodeWithPos = ts_textChanges_exports.assignPositionsToNode(node);
|
|
134149
|
+
const changes = ts_formatting_exports.formatNodeGivenIndentation(
|
|
134150
|
+
nodeWithPos,
|
|
134151
|
+
syntheticFile,
|
|
134152
|
+
sourceFile.languageVariant,
|
|
134153
|
+
0,
|
|
134154
|
+
0,
|
|
134155
|
+
{ ...formatContext, options: formatOptions }
|
|
134156
|
+
);
|
|
134157
|
+
const allChanges = escapes ? stableSort(concatenate(changes, escapes), (a, b) => compareTextSpans(a.span, b.span)) : changes;
|
|
134158
|
+
return ts_textChanges_exports.applyChanges(syntheticFile.text, allChanges);
|
|
134159
|
+
}
|
|
133922
134160
|
}
|
|
133923
134161
|
function originToCompletionEntryData(origin) {
|
|
133924
134162
|
const ambientModuleName = origin.fileName ? void 0 : stripQuotes(origin.moduleSymbol.name);
|
|
@@ -134122,6 +134360,9 @@ ${lanes.join("\n")}
|
|
|
134122
134360
|
return entries;
|
|
134123
134361
|
}
|
|
134124
134362
|
function getSymbolCompletionFromEntryId(program, log, sourceFile, position, entryId, host, preferences) {
|
|
134363
|
+
if (entryId.source === "SwitchCases/" /* SwitchCases */) {
|
|
134364
|
+
return { type: "cases" };
|
|
134365
|
+
}
|
|
134125
134366
|
if (entryId.data) {
|
|
134126
134367
|
const autoImport = getAutoImportSymbolFromCompletionEntryData(entryId.name, entryId.data, program, host);
|
|
134127
134368
|
if (autoImport) {
|
|
@@ -134160,9 +134401,9 @@ ${lanes.join("\n")}
|
|
|
134160
134401
|
const typeChecker = program.getTypeChecker();
|
|
134161
134402
|
const compilerOptions = program.getCompilerOptions();
|
|
134162
134403
|
const { name, source, data } = entryId;
|
|
134163
|
-
const contextToken =
|
|
134164
|
-
if (isInString(sourceFile, position,
|
|
134165
|
-
return ts_Completions_StringCompletions_exports.getStringLiteralCompletionDetails(name, sourceFile, position,
|
|
134404
|
+
const { previousToken, contextToken } = getRelevantTokens(position, sourceFile);
|
|
134405
|
+
if (isInString(sourceFile, position, previousToken)) {
|
|
134406
|
+
return ts_Completions_StringCompletions_exports.getStringLiteralCompletionDetails(name, sourceFile, position, previousToken, typeChecker, compilerOptions, host, cancellationToken, preferences);
|
|
134166
134407
|
}
|
|
134167
134408
|
const symbolCompletion = getSymbolCompletionFromEntryId(program, log, sourceFile, position, entryId, host, preferences);
|
|
134168
134409
|
switch (symbolCompletion.type) {
|
|
@@ -134182,14 +134423,49 @@ ${lanes.join("\n")}
|
|
|
134182
134423
|
}
|
|
134183
134424
|
}
|
|
134184
134425
|
case "symbol": {
|
|
134185
|
-
const { symbol, location: location2, contextToken: contextToken2, origin, previousToken } = symbolCompletion;
|
|
134186
|
-
const { codeActions, sourceDisplay } = getCompletionEntryCodeActionsAndSourceDisplay(name, location2, contextToken2, origin, symbol, program, host, compilerOptions, sourceFile, position,
|
|
134426
|
+
const { symbol, location: location2, contextToken: contextToken2, origin, previousToken: previousToken2 } = symbolCompletion;
|
|
134427
|
+
const { codeActions, sourceDisplay } = getCompletionEntryCodeActionsAndSourceDisplay(name, location2, contextToken2, origin, symbol, program, host, compilerOptions, sourceFile, position, previousToken2, formatContext, preferences, data, source, cancellationToken);
|
|
134187
134428
|
return createCompletionDetailsForSymbol(symbol, typeChecker, sourceFile, location2, cancellationToken, codeActions, sourceDisplay);
|
|
134188
134429
|
}
|
|
134189
134430
|
case "literal": {
|
|
134190
134431
|
const { literal } = symbolCompletion;
|
|
134191
134432
|
return createSimpleDetails(completionNameForLiteral(sourceFile, preferences, literal), "string" /* string */, typeof literal === "string" ? 8 /* stringLiteral */ : 7 /* numericLiteral */);
|
|
134192
134433
|
}
|
|
134434
|
+
case "cases": {
|
|
134435
|
+
const { entry, importAdder } = getExhaustiveCaseSnippets(
|
|
134436
|
+
contextToken.parent,
|
|
134437
|
+
sourceFile,
|
|
134438
|
+
preferences,
|
|
134439
|
+
program.getCompilerOptions(),
|
|
134440
|
+
host,
|
|
134441
|
+
program,
|
|
134442
|
+
void 0
|
|
134443
|
+
);
|
|
134444
|
+
if (importAdder.hasFixes()) {
|
|
134445
|
+
const changes = ts_textChanges_exports.ChangeTracker.with(
|
|
134446
|
+
{ host, formatContext, preferences },
|
|
134447
|
+
importAdder.writeFixes
|
|
134448
|
+
);
|
|
134449
|
+
return {
|
|
134450
|
+
name: entry.name,
|
|
134451
|
+
kind: "" /* unknown */,
|
|
134452
|
+
kindModifiers: "",
|
|
134453
|
+
displayParts: [],
|
|
134454
|
+
sourceDisplay: void 0,
|
|
134455
|
+
codeActions: [{
|
|
134456
|
+
changes,
|
|
134457
|
+
description: diagnosticToString([Diagnostics.Includes_imports_of_types_referenced_by_0, name])
|
|
134458
|
+
}]
|
|
134459
|
+
};
|
|
134460
|
+
}
|
|
134461
|
+
return {
|
|
134462
|
+
name: entry.name,
|
|
134463
|
+
kind: "" /* unknown */,
|
|
134464
|
+
kindModifiers: "",
|
|
134465
|
+
displayParts: [],
|
|
134466
|
+
sourceDisplay: void 0
|
|
134467
|
+
};
|
|
134468
|
+
}
|
|
134193
134469
|
case "none":
|
|
134194
134470
|
return allKeywordsCompletions().some((c) => c.name === name) ? createSimpleDetails(name, "keyword" /* keyword */, 5 /* keyword */) : void 0;
|
|
134195
134471
|
default:
|
|
@@ -141250,7 +141526,7 @@ ${lanes.join("\n")}
|
|
|
141250
141526
|
return emptyArray;
|
|
141251
141527
|
},
|
|
141252
141528
|
getEditsForAction: function getRefactorEditsToExtractType(context, actionName2) {
|
|
141253
|
-
const { file } = context;
|
|
141529
|
+
const { file, program } = context;
|
|
141254
141530
|
const info = getRangeToExtract(context);
|
|
141255
141531
|
Debug.assert(info && !isRefactorErrorInfo(info), "Expected to find a range to extract");
|
|
141256
141532
|
const name = getUniqueName("NewType", file);
|
|
@@ -141261,7 +141537,7 @@ ${lanes.join("\n")}
|
|
|
141261
141537
|
return doTypeAliasChange(changes, file, name, info);
|
|
141262
141538
|
case extractToTypeDefAction.name:
|
|
141263
141539
|
Debug.assert(info.isJS, "Invalid actionName/JS combo");
|
|
141264
|
-
return doTypedefChange(changes, file, name, info);
|
|
141540
|
+
return doTypedefChange(changes, program, file, name, info);
|
|
141265
141541
|
case extractToInterfaceAction.name:
|
|
141266
141542
|
Debug.assert(!info.isJS && !!info.typeElements, "Invalid actionName/JS combo");
|
|
141267
141543
|
return doInterfaceChange(changes, file, name, info);
|
|
@@ -141284,12 +141560,14 @@ ${lanes.join("\n")}
|
|
|
141284
141560
|
if (!selection || !isTypeNode(selection))
|
|
141285
141561
|
return { error: getLocaleSpecificMessage(Diagnostics.Selection_is_not_a_valid_type_node) };
|
|
141286
141562
|
const checker = context.program.getTypeChecker();
|
|
141287
|
-
const
|
|
141288
|
-
|
|
141563
|
+
const enclosingNode = getEnclosingNode(selection, isJS);
|
|
141564
|
+
if (enclosingNode === void 0)
|
|
141565
|
+
return { error: getLocaleSpecificMessage(Diagnostics.No_type_could_be_extracted_from_this_type_node) };
|
|
141566
|
+
const typeParameters = collectTypeParameters(checker, selection, enclosingNode, file);
|
|
141289
141567
|
if (!typeParameters)
|
|
141290
141568
|
return { error: getLocaleSpecificMessage(Diagnostics.No_type_could_be_extracted_from_this_type_node) };
|
|
141291
141569
|
const typeElements = flattenTypeLiteralNodeReference(checker, selection);
|
|
141292
|
-
return { isJS, selection,
|
|
141570
|
+
return { isJS, selection, enclosingNode, typeParameters, typeElements };
|
|
141293
141571
|
}
|
|
141294
141572
|
function flattenTypeLiteralNodeReference(checker, node) {
|
|
141295
141573
|
if (!node)
|
|
@@ -141315,7 +141593,7 @@ ${lanes.join("\n")}
|
|
|
141315
141593
|
function rangeContainsSkipTrivia(r1, node, file) {
|
|
141316
141594
|
return rangeContainsStartEnd(r1, skipTrivia(file.text, node.pos), node.end);
|
|
141317
141595
|
}
|
|
141318
|
-
function collectTypeParameters(checker, selection,
|
|
141596
|
+
function collectTypeParameters(checker, selection, enclosingNode, file) {
|
|
141319
141597
|
const result = [];
|
|
141320
141598
|
return visitor(selection) ? void 0 : result;
|
|
141321
141599
|
function visitor(node) {
|
|
@@ -141328,7 +141606,7 @@ ${lanes.join("\n")}
|
|
|
141328
141606
|
if (decl.name.escapedText === typeName.escapedText && rangeContainsSkipTrivia(decl, selection, file)) {
|
|
141329
141607
|
return true;
|
|
141330
141608
|
}
|
|
141331
|
-
if (rangeContainsSkipTrivia(
|
|
141609
|
+
if (rangeContainsSkipTrivia(enclosingNode, decl, file) && !rangeContainsSkipTrivia(selection, decl, file)) {
|
|
141332
141610
|
pushIfUnique(result, decl);
|
|
141333
141611
|
break;
|
|
141334
141612
|
}
|
|
@@ -141348,7 +141626,7 @@ ${lanes.join("\n")}
|
|
|
141348
141626
|
} else if (isTypeQueryNode(node)) {
|
|
141349
141627
|
if (isIdentifier(node.exprName)) {
|
|
141350
141628
|
const symbol = checker.resolveName(node.exprName.text, node.exprName, 111551 /* Value */, false);
|
|
141351
|
-
if ((symbol == null ? void 0 : symbol.valueDeclaration) && rangeContainsSkipTrivia(
|
|
141629
|
+
if ((symbol == null ? void 0 : symbol.valueDeclaration) && rangeContainsSkipTrivia(enclosingNode, symbol.valueDeclaration, file) && !rangeContainsSkipTrivia(selection, symbol.valueDeclaration, file)) {
|
|
141352
141630
|
return true;
|
|
141353
141631
|
}
|
|
141354
141632
|
} else {
|
|
@@ -141364,19 +141642,19 @@ ${lanes.join("\n")}
|
|
|
141364
141642
|
}
|
|
141365
141643
|
}
|
|
141366
141644
|
function doTypeAliasChange(changes, file, name, info) {
|
|
141367
|
-
const {
|
|
141645
|
+
const { enclosingNode, selection, typeParameters } = info;
|
|
141368
141646
|
const newTypeNode = factory.createTypeAliasDeclaration(
|
|
141369
141647
|
void 0,
|
|
141370
141648
|
name,
|
|
141371
141649
|
typeParameters.map((id) => factory.updateTypeParameterDeclaration(id, id.modifiers, id.name, id.constraint, void 0)),
|
|
141372
141650
|
selection
|
|
141373
141651
|
);
|
|
141374
|
-
changes.insertNodeBefore(file,
|
|
141652
|
+
changes.insertNodeBefore(file, enclosingNode, ignoreSourceNewlines(newTypeNode), true);
|
|
141375
141653
|
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 });
|
|
141376
141654
|
}
|
|
141377
141655
|
function doInterfaceChange(changes, file, name, info) {
|
|
141378
141656
|
var _a2;
|
|
141379
|
-
const {
|
|
141657
|
+
const { enclosingNode, selection, typeParameters, typeElements } = info;
|
|
141380
141658
|
const newTypeNode = factory.createInterfaceDeclaration(
|
|
141381
141659
|
void 0,
|
|
141382
141660
|
name,
|
|
@@ -141385,11 +141663,11 @@ ${lanes.join("\n")}
|
|
|
141385
141663
|
typeElements
|
|
141386
141664
|
);
|
|
141387
141665
|
setTextRange(newTypeNode, (_a2 = typeElements[0]) == null ? void 0 : _a2.parent);
|
|
141388
|
-
changes.insertNodeBefore(file,
|
|
141666
|
+
changes.insertNodeBefore(file, enclosingNode, ignoreSourceNewlines(newTypeNode), true);
|
|
141389
141667
|
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 });
|
|
141390
141668
|
}
|
|
141391
|
-
function doTypedefChange(changes, file, name, info) {
|
|
141392
|
-
const {
|
|
141669
|
+
function doTypedefChange(changes, program, file, name, info) {
|
|
141670
|
+
const { enclosingNode, selection, typeParameters } = info;
|
|
141393
141671
|
setEmitFlags(selection, 3072 /* NoComments */ | 4096 /* NoNestedComments */);
|
|
141394
141672
|
const node = factory.createJSDocTypedefTag(
|
|
141395
141673
|
factory.createIdentifier("typedef"),
|
|
@@ -141407,9 +141685,21 @@ ${lanes.join("\n")}
|
|
|
141407
141685
|
);
|
|
141408
141686
|
templates.push(template);
|
|
141409
141687
|
});
|
|
141410
|
-
|
|
141688
|
+
const jsDoc = factory.createJSDocComment(void 0, factory.createNodeArray(concatenate(templates, [node])));
|
|
141689
|
+
if (isJSDoc(enclosingNode)) {
|
|
141690
|
+
const pos = enclosingNode.getStart(file);
|
|
141691
|
+
const newLineCharacter = getNewLineCharacter(program.getCompilerOptions());
|
|
141692
|
+
changes.insertNodeAt(file, enclosingNode.getStart(file), jsDoc, {
|
|
141693
|
+
suffix: newLineCharacter + newLineCharacter + file.text.slice(getPrecedingNonSpaceCharacterPosition(file.text, pos - 1), pos)
|
|
141694
|
+
});
|
|
141695
|
+
} else {
|
|
141696
|
+
changes.insertNodeBefore(file, enclosingNode, jsDoc, true);
|
|
141697
|
+
}
|
|
141411
141698
|
changes.replaceNode(file, selection, factory.createTypeReferenceNode(name, typeParameters.map((id) => factory.createTypeReferenceNode(id.name, void 0))));
|
|
141412
141699
|
}
|
|
141700
|
+
function getEnclosingNode(node, isJS) {
|
|
141701
|
+
return findAncestor(node, isStatement) || (isJS ? findAncestor(node, isJSDoc) : void 0);
|
|
141702
|
+
}
|
|
141413
141703
|
|
|
141414
141704
|
// src/services/refactors/helpers.ts
|
|
141415
141705
|
function isRefactorErrorInfo(info) {
|