typescript 5.4.0-dev.20231114 → 5.4.0-dev.20231116
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/tsc.js +44 -23
- package/lib/tsserver.js +275 -196
- package/lib/typescript.d.ts +2 -0
- package/lib/typescript.js +266 -26
- package/lib/typingsInstaller.js +51 -31
- package/package.json +2 -2
package/lib/tsc.js
CHANGED
|
@@ -18,7 +18,7 @@ and limitations under the License.
|
|
|
18
18
|
|
|
19
19
|
// src/compiler/corePublic.ts
|
|
20
20
|
var versionMajorMinor = "5.4";
|
|
21
|
-
var version = `${versionMajorMinor}.0-dev.
|
|
21
|
+
var version = `${versionMajorMinor}.0-dev.20231116`;
|
|
22
22
|
|
|
23
23
|
// src/compiler/core.ts
|
|
24
24
|
var emptyArray = [];
|
|
@@ -4521,6 +4521,7 @@ function createSystemWatchFunctions({
|
|
|
4521
4521
|
useNonPollingWatchers,
|
|
4522
4522
|
tscWatchDirectory,
|
|
4523
4523
|
inodeWatching,
|
|
4524
|
+
fsWatchWithTimestamp,
|
|
4524
4525
|
sysLog: sysLog2
|
|
4525
4526
|
}) {
|
|
4526
4527
|
const pollingWatches = /* @__PURE__ */ new Map();
|
|
@@ -4759,7 +4760,7 @@ function createSystemWatchFunctions({
|
|
|
4759
4760
|
return watchPresentFileSystemEntryWithFsWatchFile();
|
|
4760
4761
|
}
|
|
4761
4762
|
try {
|
|
4762
|
-
const presentWatcher = fsWatchWorker(
|
|
4763
|
+
const presentWatcher = (!fsWatchWithTimestamp ? fsWatchWorker : fsWatchWorkerHandlingTimestamp)(
|
|
4763
4764
|
fileOrDirectory,
|
|
4764
4765
|
recursive,
|
|
4765
4766
|
inodeWatching ? callbackChangingToMissingFileSystemEntry : callback
|
|
@@ -4822,6 +4823,18 @@ function createSystemWatchFunctions({
|
|
|
4822
4823
|
);
|
|
4823
4824
|
}
|
|
4824
4825
|
}
|
|
4826
|
+
function fsWatchWorkerHandlingTimestamp(fileOrDirectory, recursive, callback) {
|
|
4827
|
+
let modifiedTime = getModifiedTime3(fileOrDirectory) || missingFileModifiedTime;
|
|
4828
|
+
return fsWatchWorker(fileOrDirectory, recursive, (eventName, relativeFileName, currentModifiedTime) => {
|
|
4829
|
+
if (eventName === "change") {
|
|
4830
|
+
currentModifiedTime || (currentModifiedTime = getModifiedTime3(fileOrDirectory) || missingFileModifiedTime);
|
|
4831
|
+
if (currentModifiedTime.getTime() === modifiedTime.getTime())
|
|
4832
|
+
return;
|
|
4833
|
+
}
|
|
4834
|
+
modifiedTime = currentModifiedTime || getModifiedTime3(fileOrDirectory) || missingFileModifiedTime;
|
|
4835
|
+
callback(eventName, relativeFileName, modifiedTime);
|
|
4836
|
+
});
|
|
4837
|
+
}
|
|
4825
4838
|
}
|
|
4826
4839
|
function patchWriteFileEnsuringDirectory(sys2) {
|
|
4827
4840
|
const originalWriteFile = sys2.writeFile;
|
|
@@ -4850,12 +4863,13 @@ var sys = (() => {
|
|
|
4850
4863
|
let activeSession;
|
|
4851
4864
|
let profilePath = "./profile.cpuprofile";
|
|
4852
4865
|
const Buffer = require("buffer").Buffer;
|
|
4853
|
-
const
|
|
4866
|
+
const isMacOs = process.platform === "darwin";
|
|
4867
|
+
const isLinuxOrMacOs = process.platform === "linux" || isMacOs;
|
|
4854
4868
|
const platform = _os.platform();
|
|
4855
4869
|
const useCaseSensitiveFileNames2 = isFileSystemCaseSensitive();
|
|
4856
4870
|
const fsRealpath = !!_fs.realpathSync.native ? process.platform === "win32" ? fsRealPathHandlingLongPath : _fs.realpathSync.native : _fs.realpathSync;
|
|
4857
4871
|
const executingFilePath = __filename.endsWith("sys.js") ? _path.join(_path.dirname(__dirname), "__fake__.js") : __filename;
|
|
4858
|
-
const fsSupportsRecursiveFsWatch = process.platform === "win32" ||
|
|
4872
|
+
const fsSupportsRecursiveFsWatch = process.platform === "win32" || isMacOs;
|
|
4859
4873
|
const getCurrentDirectory = memoize(() => process.cwd());
|
|
4860
4874
|
const { watchFile: watchFile2, watchDirectory } = createSystemWatchFunctions({
|
|
4861
4875
|
pollingWatchFileWorker: fsWatchFileWorker,
|
|
@@ -4875,6 +4889,7 @@ var sys = (() => {
|
|
|
4875
4889
|
useNonPollingWatchers: !!process.env.TSC_NONPOLLING_WATCHER,
|
|
4876
4890
|
tscWatchDirectory: process.env.TSC_WATCHDIRECTORY,
|
|
4877
4891
|
inodeWatching: isLinuxOrMacOs,
|
|
4892
|
+
fsWatchWithTimestamp: isMacOs,
|
|
4878
4893
|
sysLog
|
|
4879
4894
|
});
|
|
4880
4895
|
const nodeSystem = {
|
|
@@ -6667,6 +6682,7 @@ var Diagnostics = {
|
|
|
6667
6682
|
Type_0_is_generic_and_can_only_be_indexed_for_reading: diag(2862, 1 /* Error */, "Type_0_is_generic_and_can_only_be_indexed_for_reading_2862", "Type '{0}' is generic and can only be indexed for reading."),
|
|
6668
6683
|
A_class_cannot_extend_a_primitive_type_like_0_Classes_can_only_extend_constructable_values: diag(2863, 1 /* Error */, "A_class_cannot_extend_a_primitive_type_like_0_Classes_can_only_extend_constructable_values_2863", "A class cannot extend a primitive type like '{0}'. Classes can only extend constructable values."),
|
|
6669
6684
|
A_class_cannot_implement_a_primitive_type_like_0_It_can_only_implement_other_named_object_types: diag(2864, 1 /* Error */, "A_class_cannot_implement_a_primitive_type_like_0_It_can_only_implement_other_named_object_types_2864", "A class cannot implement a primitive type like '{0}'. It can only implement other named object types."),
|
|
6685
|
+
Import_0_conflicts_with_local_value_so_must_be_declared_with_a_type_only_import_when_isolatedModules_is_enabled: diag(2865, 1 /* Error */, "Import_0_conflicts_with_local_value_so_must_be_declared_with_a_type_only_import_when_isolatedModules_2865", "Import '{0}' conflicts with local value, so must be declared with a type-only import when 'isolatedModules' is enabled."),
|
|
6670
6686
|
Import_declaration_0_is_using_private_name_1: diag(4e3, 1 /* Error */, "Import_declaration_0_is_using_private_name_1_4000", "Import declaration '{0}' is using private name '{1}'."),
|
|
6671
6687
|
Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: diag(4002, 1 /* Error */, "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002", "Type parameter '{0}' of exported class has or is using private name '{1}'."),
|
|
6672
6688
|
Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: diag(4004, 1 /* Error */, "Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1_4004", "Type parameter '{0}' of exported interface has or is using private name '{1}'."),
|
|
@@ -10961,7 +10977,7 @@ function isPropertyAccessOrQualifiedNameOrImportTypeNode(node) {
|
|
|
10961
10977
|
return kind === 211 /* PropertyAccessExpression */ || kind === 166 /* QualifiedName */ || kind === 205 /* ImportType */;
|
|
10962
10978
|
}
|
|
10963
10979
|
function isCallLikeOrFunctionLikeExpression(node) {
|
|
10964
|
-
return isCallLikeExpression(node) ||
|
|
10980
|
+
return isCallLikeExpression(node) || isFunctionExpressionOrArrowFunction(node);
|
|
10965
10981
|
}
|
|
10966
10982
|
function isCallLikeExpression(node) {
|
|
10967
10983
|
switch (node.kind) {
|
|
@@ -18823,10 +18839,8 @@ function createNodeFactory(flags, baseFactory2) {
|
|
|
18823
18839
|
return update(updated, original);
|
|
18824
18840
|
}
|
|
18825
18841
|
function createNumericLiteral(value, numericLiteralFlags = 0 /* None */) {
|
|
18826
|
-
const text = typeof value === "number" ? value + "" : value;
|
|
18827
|
-
Debug.assert(text.charCodeAt(0) !== 45 /* minus */, "Negative numbers should be created in combination with createPrefixUnaryExpression");
|
|
18828
18842
|
const node = createBaseDeclaration(9 /* NumericLiteral */);
|
|
18829
|
-
node.text =
|
|
18843
|
+
node.text = typeof value === "number" ? value + "" : value;
|
|
18830
18844
|
node.numericLiteralFlags = numericLiteralFlags;
|
|
18831
18845
|
if (numericLiteralFlags & 384 /* BinaryOrOctalSpecifier */)
|
|
18832
18846
|
node.transformFlags |= 1024 /* ContainsES2015 */;
|
|
@@ -43692,7 +43706,7 @@ function createTypeChecker(host) {
|
|
|
43692
43706
|
const nodeLinks2 = getNodeLinks(node);
|
|
43693
43707
|
cachedResolvedSignatures.push([nodeLinks2, nodeLinks2.resolvedSignature]);
|
|
43694
43708
|
nodeLinks2.resolvedSignature = void 0;
|
|
43695
|
-
if (
|
|
43709
|
+
if (isFunctionExpressionOrArrowFunction(node)) {
|
|
43696
43710
|
const symbolLinks2 = getSymbolLinks(getSymbolOfDeclaration(node));
|
|
43697
43711
|
const type = symbolLinks2.type;
|
|
43698
43712
|
cachedTypes2.push([symbolLinks2, type]);
|
|
@@ -48254,6 +48268,8 @@ function createTypeChecker(host) {
|
|
|
48254
48268
|
context.symbolDepth.set(id, depth + 1);
|
|
48255
48269
|
}
|
|
48256
48270
|
context.visitedTypes.add(typeId);
|
|
48271
|
+
const prevTrackedSymbols = context.trackedSymbols;
|
|
48272
|
+
context.trackedSymbols = void 0;
|
|
48257
48273
|
const startLength = context.approximateLength;
|
|
48258
48274
|
const result = transform(type2);
|
|
48259
48275
|
const addedLength = context.approximateLength - startLength;
|
|
@@ -48269,6 +48285,7 @@ function createTypeChecker(host) {
|
|
|
48269
48285
|
if (id) {
|
|
48270
48286
|
context.symbolDepth.set(id, depth);
|
|
48271
48287
|
}
|
|
48288
|
+
context.trackedSymbols = prevTrackedSymbols;
|
|
48272
48289
|
return result;
|
|
48273
48290
|
function deepCloneOrReuseNode(node) {
|
|
48274
48291
|
if (!nodeIsSynthesized(node) && getParseTreeNode(node) === node) {
|
|
@@ -48571,7 +48588,7 @@ function createTypeChecker(host) {
|
|
|
48571
48588
|
context.approximateLength += symbolName(propertySymbol).length + 1;
|
|
48572
48589
|
if (propertySymbol.flags & 98304 /* Accessor */) {
|
|
48573
48590
|
const writeType = getWriteTypeOfSymbol(propertySymbol);
|
|
48574
|
-
if (propertyType !== writeType) {
|
|
48591
|
+
if (propertyType !== writeType && !isErrorType(propertyType) && !isErrorType(writeType)) {
|
|
48575
48592
|
const getterDeclaration = getDeclarationOfKind(propertySymbol, 177 /* GetAccessor */);
|
|
48576
48593
|
const getterSignature = getSignatureFromDeclaration(getterDeclaration);
|
|
48577
48594
|
typeElements.push(
|
|
@@ -49520,7 +49537,7 @@ function createTypeChecker(host) {
|
|
|
49520
49537
|
return factory.createStringLiteral(name, !!singleQuote);
|
|
49521
49538
|
}
|
|
49522
49539
|
if (isNumericLiteralName(name) && startsWith(name, "-")) {
|
|
49523
|
-
return factory.createComputedPropertyName(factory.
|
|
49540
|
+
return factory.createComputedPropertyName(factory.createNumericLiteral(+name));
|
|
49524
49541
|
}
|
|
49525
49542
|
return createPropertyNameNodeForIdentifierOrLiteral(name, getEmitScriptTarget(compilerOptions), singleQuote, stringNamed, isMethod);
|
|
49526
49543
|
}
|
|
@@ -75403,14 +75420,9 @@ function createTypeChecker(host) {
|
|
|
75403
75420
|
case 15 /* NoSubstitutionTemplateLiteral */:
|
|
75404
75421
|
case 11 /* StringLiteral */:
|
|
75405
75422
|
return hasSkipDirectInferenceFlag(node) ? blockedStringType : getFreshTypeOfLiteralType(getStringLiteralType(node.text));
|
|
75406
|
-
case 9 /* NumericLiteral */:
|
|
75423
|
+
case 9 /* NumericLiteral */:
|
|
75407
75424
|
checkGrammarNumericLiteral(node);
|
|
75408
|
-
|
|
75409
|
-
if (!isFinite(value)) {
|
|
75410
|
-
return numberType;
|
|
75411
|
-
}
|
|
75412
|
-
return getFreshTypeOfLiteralType(getNumberLiteralType(value));
|
|
75413
|
-
}
|
|
75425
|
+
return getFreshTypeOfLiteralType(getNumberLiteralType(+node.text));
|
|
75414
75426
|
case 10 /* BigIntLiteral */:
|
|
75415
75427
|
checkGrammarBigIntLiteral(node);
|
|
75416
75428
|
return getFreshTypeOfLiteralType(getBigIntLiteralType({
|
|
@@ -80315,6 +80327,16 @@ function createTypeChecker(host) {
|
|
|
80315
80327
|
if (targetFlags & excludedMeanings) {
|
|
80316
80328
|
const message = node.kind === 281 /* ExportSpecifier */ ? Diagnostics.Export_declaration_conflicts_with_exported_declaration_of_0 : Diagnostics.Import_declaration_conflicts_with_local_declaration_of_0;
|
|
80317
80329
|
error(node, message, symbolToString(symbol));
|
|
80330
|
+
} else if (node.kind !== 281 /* ExportSpecifier */) {
|
|
80331
|
+
const appearsValueyToTranspiler = compilerOptions.isolatedModules && !findAncestor(node, isTypeOnlyImportOrExportDeclaration);
|
|
80332
|
+
if (appearsValueyToTranspiler && symbol.flags & (111551 /* Value */ | 1048576 /* ExportValue */)) {
|
|
80333
|
+
error(
|
|
80334
|
+
node,
|
|
80335
|
+
Diagnostics.Import_0_conflicts_with_local_value_so_must_be_declared_with_a_type_only_import_when_isolatedModules_is_enabled,
|
|
80336
|
+
symbolToString(symbol),
|
|
80337
|
+
isolatedModulesLikeFlagName
|
|
80338
|
+
);
|
|
80339
|
+
}
|
|
80318
80340
|
}
|
|
80319
80341
|
if (getIsolatedModules(compilerOptions) && !isTypeOnlyImportOrExportDeclaration(node) && !(node.flags & 33554432 /* Ambient */)) {
|
|
80320
80342
|
const typeOnlyAlias = getTypeOnlyAliasDeclaration(symbol);
|
|
@@ -82411,7 +82433,7 @@ function createTypeChecker(host) {
|
|
|
82411
82433
|
if (enumResult)
|
|
82412
82434
|
return enumResult;
|
|
82413
82435
|
const literalValue = type.value;
|
|
82414
|
-
return typeof literalValue === "object" ? factory.createBigIntLiteral(literalValue) : typeof literalValue === "
|
|
82436
|
+
return typeof literalValue === "object" ? factory.createBigIntLiteral(literalValue) : typeof literalValue === "number" ? factory.createNumericLiteral(literalValue) : factory.createStringLiteral(literalValue);
|
|
82415
82437
|
}
|
|
82416
82438
|
function createLiteralConstValue(node, tracker) {
|
|
82417
82439
|
const type = getTypeOfSymbol(getSymbolOfDeclaration(node));
|
|
@@ -88840,7 +88862,7 @@ function transformTypeScript(context) {
|
|
|
88840
88862
|
function transformEnumMemberDeclarationValue(member) {
|
|
88841
88863
|
const value = resolver.getConstantValue(member);
|
|
88842
88864
|
if (value !== void 0) {
|
|
88843
|
-
return typeof value === "string" ? factory2.createStringLiteral(value) :
|
|
88865
|
+
return typeof value === "string" ? factory2.createStringLiteral(value) : factory2.createNumericLiteral(value);
|
|
88844
88866
|
} else {
|
|
88845
88867
|
enableSubstitutionForNonQualifiedEnumMembers();
|
|
88846
88868
|
if (member.initializer) {
|
|
@@ -103160,7 +103182,7 @@ function transformGenerators(context) {
|
|
|
103160
103182
|
if (labelExpressions === void 0) {
|
|
103161
103183
|
labelExpressions = [];
|
|
103162
103184
|
}
|
|
103163
|
-
const expression = factory2.createNumericLiteral(
|
|
103185
|
+
const expression = factory2.createNumericLiteral(-1);
|
|
103164
103186
|
if (labelExpressions[label] === void 0) {
|
|
103165
103187
|
labelExpressions[label] = [expression];
|
|
103166
103188
|
} else {
|
|
@@ -109035,8 +109057,7 @@ function transformDeclarations(context) {
|
|
|
109035
109057
|
if (shouldStripInternal(m))
|
|
109036
109058
|
return;
|
|
109037
109059
|
const constValue = resolver.getConstantValue(m);
|
|
109038
|
-
|
|
109039
|
-
return preserveJsDoc(factory2.updateEnumMember(m, m.name, newInitializer), m);
|
|
109060
|
+
return preserveJsDoc(factory2.updateEnumMember(m, m.name, constValue !== void 0 ? typeof constValue === "string" ? factory2.createStringLiteral(constValue) : factory2.createNumericLiteral(constValue) : void 0), m);
|
|
109040
109061
|
}))
|
|
109041
109062
|
));
|
|
109042
109063
|
}
|