typescript 6.0.0-dev.20251113 → 6.0.0-dev.20251115
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 +99 -115
- package/lib/typescript.js +105 -99
- 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 = "6.0";
|
|
21
|
-
var version = `${versionMajorMinor}.0-dev.
|
|
21
|
+
var version = `${versionMajorMinor}.0-dev.20251115`;
|
|
22
22
|
|
|
23
23
|
// src/compiler/core.ts
|
|
24
24
|
var emptyArray = [];
|
|
@@ -368,20 +368,6 @@ function some(array, predicate) {
|
|
|
368
368
|
}
|
|
369
369
|
return false;
|
|
370
370
|
}
|
|
371
|
-
function getRangesWhere(arr, pred, cb) {
|
|
372
|
-
let start;
|
|
373
|
-
for (let i = 0; i < arr.length; i++) {
|
|
374
|
-
if (pred(arr[i])) {
|
|
375
|
-
start = start === void 0 ? i : start;
|
|
376
|
-
} else {
|
|
377
|
-
if (start !== void 0) {
|
|
378
|
-
cb(start, i);
|
|
379
|
-
start = void 0;
|
|
380
|
-
}
|
|
381
|
-
}
|
|
382
|
-
}
|
|
383
|
-
if (start !== void 0) cb(start, arr.length);
|
|
384
|
-
}
|
|
385
371
|
function concatenate(array1, array2) {
|
|
386
372
|
if (array2 === void 0 || array2.length === 0) return array1;
|
|
387
373
|
if (array1 === void 0 || array1.length === 0) return array2;
|
|
@@ -3362,6 +3348,7 @@ var NodeFlags = /* @__PURE__ */ ((NodeFlags3) => {
|
|
|
3362
3348
|
NodeFlags3[NodeFlags3["JsonFile"] = 134217728] = "JsonFile";
|
|
3363
3349
|
NodeFlags3[NodeFlags3["TypeCached"] = 268435456] = "TypeCached";
|
|
3364
3350
|
NodeFlags3[NodeFlags3["Deprecated"] = 536870912] = "Deprecated";
|
|
3351
|
+
NodeFlags3[NodeFlags3["Unreachable"] = 1073741824] = "Unreachable";
|
|
3365
3352
|
NodeFlags3[NodeFlags3["BlockScoped"] = 7] = "BlockScoped";
|
|
3366
3353
|
NodeFlags3[NodeFlags3["Constant"] = 6] = "Constant";
|
|
3367
3354
|
NodeFlags3[NodeFlags3["ReachabilityCheckFlags"] = 1536] = "ReachabilityCheckFlags";
|
|
@@ -6997,7 +6984,7 @@ var Diagnostics = {
|
|
|
6997
6984
|
Compiler_option_0_may_only_be_used_with_build: diag(5093, 1 /* Error */, "Compiler_option_0_may_only_be_used_with_build_5093", "Compiler option '--{0}' may only be used with '--build'."),
|
|
6998
6985
|
Compiler_option_0_may_not_be_used_with_build: diag(5094, 1 /* Error */, "Compiler_option_0_may_not_be_used_with_build_5094", "Compiler option '--{0}' may not be used with '--build'."),
|
|
6999
6986
|
Option_0_can_only_be_used_when_module_is_set_to_preserve_commonjs_or_es2015_or_later: diag(5095, 1 /* Error */, "Option_0_can_only_be_used_when_module_is_set_to_preserve_commonjs_or_es2015_or_later_5095", "Option '{0}' can only be used when 'module' is set to 'preserve', 'commonjs', or 'es2015' or later."),
|
|
7000
|
-
|
|
6987
|
+
Option_allowImportingTsExtensions_can_only_be_used_when_one_of_noEmit_emitDeclarationOnly_or_rewriteRelativeImportExtensions_is_set: diag(5096, 1 /* Error */, "Option_allowImportingTsExtensions_can_only_be_used_when_one_of_noEmit_emitDeclarationOnly_or_rewrite_5096", "Option 'allowImportingTsExtensions' can only be used when one of 'noEmit', 'emitDeclarationOnly', or 'rewriteRelativeImportExtensions' is set."),
|
|
7001
6988
|
An_import_path_can_only_end_with_a_0_extension_when_allowImportingTsExtensions_is_enabled: diag(5097, 1 /* Error */, "An_import_path_can_only_end_with_a_0_extension_when_allowImportingTsExtensions_is_enabled_5097", "An import path can only end with a '{0}' extension when 'allowImportingTsExtensions' is enabled."),
|
|
7002
6989
|
Option_0_can_only_be_used_when_moduleResolution_is_set_to_node16_nodenext_or_bundler: diag(5098, 1 /* Error */, "Option_0_can_only_be_used_when_moduleResolution_is_set_to_node16_nodenext_or_bundler_5098", "Option '{0}' can only be used when 'moduleResolution' is set to 'node16', 'nodenext', or 'bundler'."),
|
|
7003
6990
|
Option_0_is_deprecated_and_will_stop_functioning_in_TypeScript_1_Specify_compilerOption_ignoreDeprecations_Colon_2_to_silence_this_error: diag(5101, 1 /* Error */, "Option_0_is_deprecated_and_will_stop_functioning_in_TypeScript_1_Specify_compilerOption_ignoreDeprec_5101", `Option '{0}' is deprecated and will stop functioning in TypeScript {1}. Specify compilerOption '"ignoreDeprecations": "{2}"' to silence this error.`),
|
|
@@ -12484,9 +12471,6 @@ function isDeclaration(node) {
|
|
|
12484
12471
|
function isDeclarationStatement(node) {
|
|
12485
12472
|
return isDeclarationStatementKind(node.kind);
|
|
12486
12473
|
}
|
|
12487
|
-
function isStatementButNotDeclaration(node) {
|
|
12488
|
-
return isStatementKindButNotDeclarationKind(node.kind);
|
|
12489
|
-
}
|
|
12490
12474
|
function isStatement(node) {
|
|
12491
12475
|
const kind = node.kind;
|
|
12492
12476
|
return isStatementKindButNotDeclarationKind(kind) || isDeclarationStatementKind(kind) || isBlockStatement(node);
|
|
@@ -18225,12 +18209,6 @@ function hasJsonModuleEmitEnabled(options) {
|
|
|
18225
18209
|
}
|
|
18226
18210
|
return true;
|
|
18227
18211
|
}
|
|
18228
|
-
function unreachableCodeIsError(options) {
|
|
18229
|
-
return options.allowUnreachableCode === false;
|
|
18230
|
-
}
|
|
18231
|
-
function unusedLabelIsError(options) {
|
|
18232
|
-
return options.allowUnusedLabels === false;
|
|
18233
|
-
}
|
|
18234
18212
|
function moduleResolutionSupportsPackageJsonExportsAndImports(moduleResolution) {
|
|
18235
18213
|
return moduleResolution >= 3 /* Node16 */ && moduleResolution <= 99 /* NodeNext */ || moduleResolution === 100 /* Bundler */;
|
|
18236
18214
|
}
|
|
@@ -18801,11 +18779,6 @@ function matchPatternOrExact(parsedPatterns, candidate) {
|
|
|
18801
18779
|
}
|
|
18802
18780
|
return findBestPatternMatch(patterns, (_) => _, candidate);
|
|
18803
18781
|
}
|
|
18804
|
-
function sliceAfter(arr, value) {
|
|
18805
|
-
const index = arr.indexOf(value);
|
|
18806
|
-
Debug.assert(index !== -1);
|
|
18807
|
-
return arr.slice(index);
|
|
18808
|
-
}
|
|
18809
18782
|
function addRelatedInfo(diagnostic, ...relatedInformation) {
|
|
18810
18783
|
if (!relatedInformation.length) {
|
|
18811
18784
|
return diagnostic;
|
|
@@ -20155,6 +20128,21 @@ function addEmitFlagsRecursively(node, flag, getChild) {
|
|
|
20155
20128
|
function getFirstChild(node) {
|
|
20156
20129
|
return forEachChild(node, (child) => child);
|
|
20157
20130
|
}
|
|
20131
|
+
function canHaveStatements(node) {
|
|
20132
|
+
return isBlock(node) || isModuleBlock(node) || isSourceFile(node) || isCaseClause(node) || isDefaultClause(node);
|
|
20133
|
+
}
|
|
20134
|
+
function isPotentiallyExecutableNode(node) {
|
|
20135
|
+
if (244 /* FirstStatement */ <= node.kind && node.kind <= 260 /* LastStatement */) {
|
|
20136
|
+
if (isVariableStatement(node)) {
|
|
20137
|
+
if (getCombinedNodeFlags(node.declarationList) & 7 /* BlockScoped */) {
|
|
20138
|
+
return true;
|
|
20139
|
+
}
|
|
20140
|
+
return some(node.declarationList.declarations, (d) => d.initializer !== void 0);
|
|
20141
|
+
}
|
|
20142
|
+
return true;
|
|
20143
|
+
}
|
|
20144
|
+
return isClassDeclaration(node) || isEnumDeclaration(node) || isModuleDeclaration(node);
|
|
20145
|
+
}
|
|
20158
20146
|
|
|
20159
20147
|
// src/compiler/factory/baseNodeFactory.ts
|
|
20160
20148
|
function createBaseNodeFactory() {
|
|
@@ -42370,13 +42358,6 @@ function createBinder() {
|
|
|
42370
42358
|
/*antecedent*/
|
|
42371
42359
|
void 0
|
|
42372
42360
|
);
|
|
42373
|
-
var reportedUnreachableFlow = createFlowNode(
|
|
42374
|
-
1 /* Unreachable */,
|
|
42375
|
-
/*node*/
|
|
42376
|
-
void 0,
|
|
42377
|
-
/*antecedent*/
|
|
42378
|
-
void 0
|
|
42379
|
-
);
|
|
42380
42361
|
var bindBinaryExpressionFlow = createBindBinaryExpressionFlow();
|
|
42381
42362
|
return bindSourceFile2;
|
|
42382
42363
|
function createDiagnosticForNode2(node, message, ...args) {
|
|
@@ -42392,7 +42373,6 @@ function createBinder() {
|
|
|
42392
42373
|
symbolCount = 0;
|
|
42393
42374
|
Symbol13 = objectAllocator.getSymbolConstructor();
|
|
42394
42375
|
Debug.attachFlowNodeDebugInfo(unreachableFlow);
|
|
42395
|
-
Debug.attachFlowNodeDebugInfo(reportedUnreachableFlow);
|
|
42396
42376
|
if (!file.locals) {
|
|
42397
42377
|
(_a = tracing) == null ? void 0 : _a.push(
|
|
42398
42378
|
tracing.Phase.Bind,
|
|
@@ -42765,16 +42745,19 @@ function createBinder() {
|
|
|
42765
42745
|
function bindChildren(node) {
|
|
42766
42746
|
const saveInAssignmentPattern = inAssignmentPattern;
|
|
42767
42747
|
inAssignmentPattern = false;
|
|
42768
|
-
if (
|
|
42769
|
-
if (canHaveFlowNode(node)
|
|
42748
|
+
if (currentFlow === unreachableFlow) {
|
|
42749
|
+
if (canHaveFlowNode(node)) {
|
|
42770
42750
|
node.flowNode = void 0;
|
|
42771
42751
|
}
|
|
42752
|
+
if (isPotentiallyExecutableNode(node)) {
|
|
42753
|
+
node.flags |= 1073741824 /* Unreachable */;
|
|
42754
|
+
}
|
|
42772
42755
|
bindEachChild(node);
|
|
42773
42756
|
bindJSDoc(node);
|
|
42774
42757
|
inAssignmentPattern = saveInAssignmentPattern;
|
|
42775
42758
|
return;
|
|
42776
42759
|
}
|
|
42777
|
-
if (
|
|
42760
|
+
if (244 /* FirstStatement */ <= node.kind && node.kind <= 260 /* LastStatement */ && canHaveFlowNode(node)) {
|
|
42778
42761
|
node.flowNode = currentFlow;
|
|
42779
42762
|
}
|
|
42780
42763
|
switch (node.kind) {
|
|
@@ -43361,8 +43344,8 @@ function createBinder() {
|
|
|
43361
43344
|
};
|
|
43362
43345
|
bind(node.label);
|
|
43363
43346
|
bind(node.statement);
|
|
43364
|
-
if (!activeLabelList.referenced
|
|
43365
|
-
|
|
43347
|
+
if (!activeLabelList.referenced) {
|
|
43348
|
+
node.label.flags |= 1073741824 /* Unreachable */;
|
|
43366
43349
|
}
|
|
43367
43350
|
activeLabelList = activeLabelList.next;
|
|
43368
43351
|
addAntecedent(postStatementLabel, currentFlow);
|
|
@@ -44139,20 +44122,6 @@ function createBinder() {
|
|
|
44139
44122
|
const span = getSpanOfTokenAtPosition(file, node.pos);
|
|
44140
44123
|
file.bindDiagnostics.push(createFileDiagnostic(file, span.start, span.length, message, ...args));
|
|
44141
44124
|
}
|
|
44142
|
-
function errorOrSuggestionOnNode(isError, node, message) {
|
|
44143
|
-
errorOrSuggestionOnRange(isError, node, node, message);
|
|
44144
|
-
}
|
|
44145
|
-
function errorOrSuggestionOnRange(isError, startNode, endNode, message) {
|
|
44146
|
-
addErrorOrSuggestionDiagnostic(isError, { pos: getTokenPosOfNode(startNode, file), end: endNode.end }, message);
|
|
44147
|
-
}
|
|
44148
|
-
function addErrorOrSuggestionDiagnostic(isError, range, message) {
|
|
44149
|
-
const diag2 = createFileDiagnostic(file, range.pos, range.end - range.pos, message);
|
|
44150
|
-
if (isError) {
|
|
44151
|
-
file.bindDiagnostics.push(diag2);
|
|
44152
|
-
} else {
|
|
44153
|
-
file.bindSuggestionDiagnostics = append(file.bindSuggestionDiagnostics, { ...diag2, category: 2 /* Suggestion */ });
|
|
44154
|
-
}
|
|
44155
|
-
}
|
|
44156
44125
|
function bind(node) {
|
|
44157
44126
|
if (!node) {
|
|
44158
44127
|
return;
|
|
@@ -45039,61 +45008,6 @@ function createBinder() {
|
|
|
45039
45008
|
declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 526824 /* TypeParameterExcludes */);
|
|
45040
45009
|
}
|
|
45041
45010
|
}
|
|
45042
|
-
function shouldReportErrorOnModuleDeclaration(node) {
|
|
45043
|
-
const instanceState = getModuleInstanceState(node);
|
|
45044
|
-
return instanceState === 1 /* Instantiated */ || instanceState === 2 /* ConstEnumOnly */ && shouldPreserveConstEnums(options);
|
|
45045
|
-
}
|
|
45046
|
-
function checkUnreachable(node) {
|
|
45047
|
-
if (!(currentFlow.flags & 1 /* Unreachable */)) {
|
|
45048
|
-
return false;
|
|
45049
|
-
}
|
|
45050
|
-
if (currentFlow === unreachableFlow) {
|
|
45051
|
-
const reportError = (
|
|
45052
|
-
// report error on all statements except empty ones
|
|
45053
|
-
isStatementButNotDeclaration(node) && node.kind !== 243 /* EmptyStatement */ || // report error on class declarations
|
|
45054
|
-
node.kind === 264 /* ClassDeclaration */ || // report errors on enums with preserved emit
|
|
45055
|
-
isEnumDeclarationWithPreservedEmit(node, options) || // report error on instantiated modules
|
|
45056
|
-
node.kind === 268 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)
|
|
45057
|
-
);
|
|
45058
|
-
if (reportError) {
|
|
45059
|
-
currentFlow = reportedUnreachableFlow;
|
|
45060
|
-
if (!options.allowUnreachableCode) {
|
|
45061
|
-
const isError = unreachableCodeIsError(options) && !(node.flags & 33554432 /* Ambient */) && (!isVariableStatement(node) || !!(getCombinedNodeFlags(node.declarationList) & 7 /* BlockScoped */) || node.declarationList.declarations.some((d) => !!d.initializer));
|
|
45062
|
-
eachUnreachableRange(node, options, (start, end) => errorOrSuggestionOnRange(isError, start, end, Diagnostics.Unreachable_code_detected));
|
|
45063
|
-
}
|
|
45064
|
-
}
|
|
45065
|
-
}
|
|
45066
|
-
return true;
|
|
45067
|
-
}
|
|
45068
|
-
}
|
|
45069
|
-
function isEnumDeclarationWithPreservedEmit(node, options) {
|
|
45070
|
-
return node.kind === 267 /* EnumDeclaration */ && (!isEnumConst(node) || shouldPreserveConstEnums(options));
|
|
45071
|
-
}
|
|
45072
|
-
function eachUnreachableRange(node, options, cb) {
|
|
45073
|
-
if (isStatement(node) && isExecutableStatement(node) && isBlock(node.parent)) {
|
|
45074
|
-
const { statements } = node.parent;
|
|
45075
|
-
const slice = sliceAfter(statements, node);
|
|
45076
|
-
getRangesWhere(slice, isExecutableStatement, (start, afterEnd) => cb(slice[start], slice[afterEnd - 1]));
|
|
45077
|
-
} else {
|
|
45078
|
-
cb(node, node);
|
|
45079
|
-
}
|
|
45080
|
-
function isExecutableStatement(s) {
|
|
45081
|
-
return !isFunctionDeclaration(s) && !isPurelyTypeDeclaration(s) && // `var x;` may declare a variable used above
|
|
45082
|
-
!(isVariableStatement(s) && !(getCombinedNodeFlags(s) & 7 /* BlockScoped */) && s.declarationList.declarations.some((d) => !d.initializer));
|
|
45083
|
-
}
|
|
45084
|
-
function isPurelyTypeDeclaration(s) {
|
|
45085
|
-
switch (s.kind) {
|
|
45086
|
-
case 265 /* InterfaceDeclaration */:
|
|
45087
|
-
case 266 /* TypeAliasDeclaration */:
|
|
45088
|
-
return true;
|
|
45089
|
-
case 268 /* ModuleDeclaration */:
|
|
45090
|
-
return getModuleInstanceState(s) !== 1 /* Instantiated */;
|
|
45091
|
-
case 267 /* EnumDeclaration */:
|
|
45092
|
-
return !isEnumDeclarationWithPreservedEmit(s, options);
|
|
45093
|
-
default:
|
|
45094
|
-
return false;
|
|
45095
|
-
}
|
|
45096
|
-
}
|
|
45097
45011
|
}
|
|
45098
45012
|
function isExportsOrModuleExportsOrAlias(sourceFile, node) {
|
|
45099
45013
|
let i = 0;
|
|
@@ -46434,6 +46348,8 @@ function createTypeChecker(host) {
|
|
|
46434
46348
|
var currentNode;
|
|
46435
46349
|
var varianceTypeParameter;
|
|
46436
46350
|
var isInferencePartiallyBlocked = false;
|
|
46351
|
+
var withinUnreachableCode = false;
|
|
46352
|
+
var reportedUnreachableNodes;
|
|
46437
46353
|
var emptySymbols = createSymbolTable();
|
|
46438
46354
|
var arrayVariances = [1 /* Covariant */];
|
|
46439
46355
|
var compilerOptions = host.getCompilerOptions();
|
|
@@ -84562,6 +84478,9 @@ function createTypeChecker(host) {
|
|
|
84562
84478
|
return false;
|
|
84563
84479
|
});
|
|
84564
84480
|
}
|
|
84481
|
+
if (node.label.flags & 1073741824 /* Unreachable */ && compilerOptions.allowUnusedLabels !== true) {
|
|
84482
|
+
errorOrSuggestion(compilerOptions.allowUnusedLabels === false, node.label, Diagnostics.Unused_label);
|
|
84483
|
+
}
|
|
84565
84484
|
checkSourceElement(node.statement);
|
|
84566
84485
|
}
|
|
84567
84486
|
function checkThrowStatement(node) {
|
|
@@ -86454,10 +86373,12 @@ function createTypeChecker(host) {
|
|
|
86454
86373
|
function checkSourceElement(node) {
|
|
86455
86374
|
if (node) {
|
|
86456
86375
|
const saveCurrentNode = currentNode;
|
|
86376
|
+
const saveWithinUnreachableCode = withinUnreachableCode;
|
|
86457
86377
|
currentNode = node;
|
|
86458
86378
|
instantiationCount = 0;
|
|
86459
86379
|
checkSourceElementWorker(node);
|
|
86460
86380
|
currentNode = saveCurrentNode;
|
|
86381
|
+
withinUnreachableCode = saveWithinUnreachableCode;
|
|
86461
86382
|
}
|
|
86462
86383
|
}
|
|
86463
86384
|
function checkSourceElementWorker(node) {
|
|
@@ -86485,8 +86406,10 @@ function createTypeChecker(host) {
|
|
|
86485
86406
|
cancellationToken.throwIfCancellationRequested();
|
|
86486
86407
|
}
|
|
86487
86408
|
}
|
|
86488
|
-
if (
|
|
86489
|
-
|
|
86409
|
+
if (compilerOptions.allowUnreachableCode !== true && !withinUnreachableCode) {
|
|
86410
|
+
if (checkSourceElementUnreachable(node)) {
|
|
86411
|
+
withinUnreachableCode = true;
|
|
86412
|
+
}
|
|
86490
86413
|
}
|
|
86491
86414
|
switch (kind) {
|
|
86492
86415
|
case 169 /* TypeParameter */:
|
|
@@ -86664,6 +86587,66 @@ function createTypeChecker(host) {
|
|
|
86664
86587
|
return checkMissingDeclaration(node);
|
|
86665
86588
|
}
|
|
86666
86589
|
}
|
|
86590
|
+
function checkSourceElementUnreachable(node) {
|
|
86591
|
+
if (!isPotentiallyExecutableNode(node)) {
|
|
86592
|
+
return false;
|
|
86593
|
+
}
|
|
86594
|
+
if (reportedUnreachableNodes == null ? void 0 : reportedUnreachableNodes.has(node)) {
|
|
86595
|
+
return true;
|
|
86596
|
+
}
|
|
86597
|
+
if (!isSourceElementUnreachable(node)) {
|
|
86598
|
+
return false;
|
|
86599
|
+
}
|
|
86600
|
+
(reportedUnreachableNodes ?? (reportedUnreachableNodes = /* @__PURE__ */ new Set())).add(node);
|
|
86601
|
+
const sourceFile = getSourceFileOfNode(node);
|
|
86602
|
+
let start = node.pos;
|
|
86603
|
+
let end = node.end;
|
|
86604
|
+
const parent = node.parent;
|
|
86605
|
+
if (canHaveStatements(parent)) {
|
|
86606
|
+
const statements = parent.statements;
|
|
86607
|
+
const offset = statements.indexOf(node);
|
|
86608
|
+
if (offset >= 0) {
|
|
86609
|
+
let first2 = offset;
|
|
86610
|
+
for (let i = offset - 1; i >= 0; i--) {
|
|
86611
|
+
const prevNode = statements[i];
|
|
86612
|
+
if (!isPotentiallyExecutableNode(prevNode) || reportedUnreachableNodes.has(prevNode) || !isSourceElementUnreachable(prevNode)) {
|
|
86613
|
+
break;
|
|
86614
|
+
}
|
|
86615
|
+
first2 = i;
|
|
86616
|
+
reportedUnreachableNodes.add(prevNode);
|
|
86617
|
+
}
|
|
86618
|
+
let last2 = offset;
|
|
86619
|
+
for (let i = offset + 1; i < statements.length; i++) {
|
|
86620
|
+
const nextNode = statements[i];
|
|
86621
|
+
if (!isPotentiallyExecutableNode(nextNode) || !isSourceElementUnreachable(nextNode)) {
|
|
86622
|
+
break;
|
|
86623
|
+
}
|
|
86624
|
+
last2 = i;
|
|
86625
|
+
reportedUnreachableNodes.add(nextNode);
|
|
86626
|
+
}
|
|
86627
|
+
start = statements[first2].pos;
|
|
86628
|
+
end = statements[last2].end;
|
|
86629
|
+
}
|
|
86630
|
+
}
|
|
86631
|
+
start = skipTrivia(sourceFile.text, start);
|
|
86632
|
+
addErrorOrSuggestion(compilerOptions.allowUnreachableCode === false, createFileDiagnostic(sourceFile, start, end - start, Diagnostics.Unreachable_code_detected));
|
|
86633
|
+
return true;
|
|
86634
|
+
}
|
|
86635
|
+
function isSourceElementUnreachable(node) {
|
|
86636
|
+
if (node.flags & 1073741824 /* Unreachable */) {
|
|
86637
|
+
switch (node.kind) {
|
|
86638
|
+
case 267 /* EnumDeclaration */:
|
|
86639
|
+
return !isEnumConst(node) || shouldPreserveConstEnums(compilerOptions);
|
|
86640
|
+
case 268 /* ModuleDeclaration */:
|
|
86641
|
+
return isInstantiatedModule(node, shouldPreserveConstEnums(compilerOptions));
|
|
86642
|
+
default:
|
|
86643
|
+
return true;
|
|
86644
|
+
}
|
|
86645
|
+
} else if (canHaveFlowNode(node) && node.flowNode) {
|
|
86646
|
+
return !isReachableFlowNode(node.flowNode);
|
|
86647
|
+
}
|
|
86648
|
+
return false;
|
|
86649
|
+
}
|
|
86667
86650
|
function checkJSDocCommentWorker(node) {
|
|
86668
86651
|
if (isArray(node)) {
|
|
86669
86652
|
forEach(node, (tag) => {
|
|
@@ -86826,6 +86809,7 @@ function createTypeChecker(host) {
|
|
|
86826
86809
|
mark(afterMark);
|
|
86827
86810
|
measure("Check", beforeMark, afterMark);
|
|
86828
86811
|
(_b = tracing) == null ? void 0 : _b.pop();
|
|
86812
|
+
reportedUnreachableNodes = void 0;
|
|
86829
86813
|
}
|
|
86830
86814
|
function unusedIsError(kind, isAmbient) {
|
|
86831
86815
|
if (isAmbient) {
|
|
@@ -124524,7 +124508,7 @@ function createProgram(_rootNamesOrOptions, _options, _host, _oldProgram, _confi
|
|
|
124524
124508
|
}
|
|
124525
124509
|
}
|
|
124526
124510
|
if (options.allowImportingTsExtensions && !(options.noEmit || options.emitDeclarationOnly || options.rewriteRelativeImportExtensions)) {
|
|
124527
|
-
createOptionValueDiagnostic("allowImportingTsExtensions", Diagnostics.
|
|
124511
|
+
createOptionValueDiagnostic("allowImportingTsExtensions", Diagnostics.Option_allowImportingTsExtensions_can_only_be_used_when_one_of_noEmit_emitDeclarationOnly_or_rewriteRelativeImportExtensions_is_set);
|
|
124528
124512
|
}
|
|
124529
124513
|
const moduleResolution = getEmitModuleResolutionKind(options);
|
|
124530
124514
|
if (options.resolvePackageJsonExports && !moduleResolutionSupportsPackageJsonExportsAndImports(moduleResolution)) {
|
package/lib/typescript.js
CHANGED
|
@@ -251,6 +251,7 @@ __export(typescript_exports, {
|
|
|
251
251
|
canHaveLocals: () => canHaveLocals,
|
|
252
252
|
canHaveModifiers: () => canHaveModifiers,
|
|
253
253
|
canHaveModuleSpecifier: () => canHaveModuleSpecifier,
|
|
254
|
+
canHaveStatements: () => canHaveStatements,
|
|
254
255
|
canHaveSymbol: () => canHaveSymbol,
|
|
255
256
|
canIncludeBindAndCheckDiagnostics: () => canIncludeBindAndCheckDiagnostics,
|
|
256
257
|
canJsonReportNoInputFiles: () => canJsonReportNoInputFiles,
|
|
@@ -1643,6 +1644,7 @@ __export(typescript_exports, {
|
|
|
1643
1644
|
isPlusToken: () => isPlusToken,
|
|
1644
1645
|
isPossiblyTypeArgumentPosition: () => isPossiblyTypeArgumentPosition,
|
|
1645
1646
|
isPostfixUnaryExpression: () => isPostfixUnaryExpression,
|
|
1647
|
+
isPotentiallyExecutableNode: () => isPotentiallyExecutableNode,
|
|
1646
1648
|
isPrefixUnaryExpression: () => isPrefixUnaryExpression,
|
|
1647
1649
|
isPrimitiveLiteralValue: () => isPrimitiveLiteralValue,
|
|
1648
1650
|
isPrivateIdentifier: () => isPrivateIdentifier,
|
|
@@ -2245,9 +2247,7 @@ __export(typescript_exports, {
|
|
|
2245
2247
|
unmangleScopedPackageName: () => unmangleScopedPackageName,
|
|
2246
2248
|
unorderedRemoveItem: () => unorderedRemoveItem,
|
|
2247
2249
|
unprefixedNodeCoreModules: () => unprefixedNodeCoreModules,
|
|
2248
|
-
unreachableCodeIsError: () => unreachableCodeIsError,
|
|
2249
2250
|
unsetNodeChildren: () => unsetNodeChildren,
|
|
2250
|
-
unusedLabelIsError: () => unusedLabelIsError,
|
|
2251
2251
|
unwrapInnermostStatementOfLabel: () => unwrapInnermostStatementOfLabel,
|
|
2252
2252
|
unwrapParenthesizedExpression: () => unwrapParenthesizedExpression,
|
|
2253
2253
|
updateErrorForNoInputFiles: () => updateErrorForNoInputFiles,
|
|
@@ -2286,7 +2286,7 @@ module.exports = __toCommonJS(typescript_exports);
|
|
|
2286
2286
|
|
|
2287
2287
|
// src/compiler/corePublic.ts
|
|
2288
2288
|
var versionMajorMinor = "6.0";
|
|
2289
|
-
var version = `${versionMajorMinor}.0-dev.
|
|
2289
|
+
var version = `${versionMajorMinor}.0-dev.20251115`;
|
|
2290
2290
|
var Comparison = /* @__PURE__ */ ((Comparison3) => {
|
|
2291
2291
|
Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
|
|
2292
2292
|
Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
|
|
@@ -5952,6 +5952,7 @@ var NodeFlags = /* @__PURE__ */ ((NodeFlags3) => {
|
|
|
5952
5952
|
NodeFlags3[NodeFlags3["JsonFile"] = 134217728] = "JsonFile";
|
|
5953
5953
|
NodeFlags3[NodeFlags3["TypeCached"] = 268435456] = "TypeCached";
|
|
5954
5954
|
NodeFlags3[NodeFlags3["Deprecated"] = 536870912] = "Deprecated";
|
|
5955
|
+
NodeFlags3[NodeFlags3["Unreachable"] = 1073741824] = "Unreachable";
|
|
5955
5956
|
NodeFlags3[NodeFlags3["BlockScoped"] = 7] = "BlockScoped";
|
|
5956
5957
|
NodeFlags3[NodeFlags3["Constant"] = 6] = "Constant";
|
|
5957
5958
|
NodeFlags3[NodeFlags3["ReachabilityCheckFlags"] = 1536] = "ReachabilityCheckFlags";
|
|
@@ -10384,7 +10385,7 @@ var Diagnostics = {
|
|
|
10384
10385
|
Compiler_option_0_may_only_be_used_with_build: diag(5093, 1 /* Error */, "Compiler_option_0_may_only_be_used_with_build_5093", "Compiler option '--{0}' may only be used with '--build'."),
|
|
10385
10386
|
Compiler_option_0_may_not_be_used_with_build: diag(5094, 1 /* Error */, "Compiler_option_0_may_not_be_used_with_build_5094", "Compiler option '--{0}' may not be used with '--build'."),
|
|
10386
10387
|
Option_0_can_only_be_used_when_module_is_set_to_preserve_commonjs_or_es2015_or_later: diag(5095, 1 /* Error */, "Option_0_can_only_be_used_when_module_is_set_to_preserve_commonjs_or_es2015_or_later_5095", "Option '{0}' can only be used when 'module' is set to 'preserve', 'commonjs', or 'es2015' or later."),
|
|
10387
|
-
|
|
10388
|
+
Option_allowImportingTsExtensions_can_only_be_used_when_one_of_noEmit_emitDeclarationOnly_or_rewriteRelativeImportExtensions_is_set: diag(5096, 1 /* Error */, "Option_allowImportingTsExtensions_can_only_be_used_when_one_of_noEmit_emitDeclarationOnly_or_rewrite_5096", "Option 'allowImportingTsExtensions' can only be used when one of 'noEmit', 'emitDeclarationOnly', or 'rewriteRelativeImportExtensions' is set."),
|
|
10388
10389
|
An_import_path_can_only_end_with_a_0_extension_when_allowImportingTsExtensions_is_enabled: diag(5097, 1 /* Error */, "An_import_path_can_only_end_with_a_0_extension_when_allowImportingTsExtensions_is_enabled_5097", "An import path can only end with a '{0}' extension when 'allowImportingTsExtensions' is enabled."),
|
|
10389
10390
|
Option_0_can_only_be_used_when_moduleResolution_is_set_to_node16_nodenext_or_bundler: diag(5098, 1 /* Error */, "Option_0_can_only_be_used_when_moduleResolution_is_set_to_node16_nodenext_or_bundler_5098", "Option '{0}' can only be used when 'moduleResolution' is set to 'node16', 'nodenext', or 'bundler'."),
|
|
10390
10391
|
Option_0_is_deprecated_and_will_stop_functioning_in_TypeScript_1_Specify_compilerOption_ignoreDeprecations_Colon_2_to_silence_this_error: diag(5101, 1 /* Error */, "Option_0_is_deprecated_and_will_stop_functioning_in_TypeScript_1_Specify_compilerOption_ignoreDeprec_5101", `Option '{0}' is deprecated and will stop functioning in TypeScript {1}. Specify compilerOption '"ignoreDeprecations": "{2}"' to silence this error.`),
|
|
@@ -22178,12 +22179,6 @@ function hasJsonModuleEmitEnabled(options) {
|
|
|
22178
22179
|
}
|
|
22179
22180
|
return true;
|
|
22180
22181
|
}
|
|
22181
|
-
function unreachableCodeIsError(options) {
|
|
22182
|
-
return options.allowUnreachableCode === false;
|
|
22183
|
-
}
|
|
22184
|
-
function unusedLabelIsError(options) {
|
|
22185
|
-
return options.allowUnusedLabels === false;
|
|
22186
|
-
}
|
|
22187
22182
|
function moduleResolutionSupportsPackageJsonExportsAndImports(moduleResolution) {
|
|
22188
22183
|
return moduleResolution >= 3 /* Node16 */ && moduleResolution <= 99 /* NodeNext */ || moduleResolution === 100 /* Bundler */;
|
|
22189
22184
|
}
|
|
@@ -24247,6 +24242,21 @@ function addEmitFlagsRecursively(node, flag, getChild) {
|
|
|
24247
24242
|
function getFirstChild(node) {
|
|
24248
24243
|
return forEachChild(node, (child) => child);
|
|
24249
24244
|
}
|
|
24245
|
+
function canHaveStatements(node) {
|
|
24246
|
+
return isBlock(node) || isModuleBlock(node) || isSourceFile(node) || isCaseClause(node) || isDefaultClause(node);
|
|
24247
|
+
}
|
|
24248
|
+
function isPotentiallyExecutableNode(node) {
|
|
24249
|
+
if (244 /* FirstStatement */ <= node.kind && node.kind <= 260 /* LastStatement */) {
|
|
24250
|
+
if (isVariableStatement(node)) {
|
|
24251
|
+
if (getCombinedNodeFlags(node.declarationList) & 7 /* BlockScoped */) {
|
|
24252
|
+
return true;
|
|
24253
|
+
}
|
|
24254
|
+
return some(node.declarationList.declarations, (d) => d.initializer !== void 0);
|
|
24255
|
+
}
|
|
24256
|
+
return true;
|
|
24257
|
+
}
|
|
24258
|
+
return isClassDeclaration(node) || isEnumDeclaration(node) || isModuleDeclaration(node);
|
|
24259
|
+
}
|
|
24250
24260
|
|
|
24251
24261
|
// src/compiler/factory/baseNodeFactory.ts
|
|
24252
24262
|
function createBaseNodeFactory() {
|
|
@@ -46876,13 +46886,6 @@ function createBinder() {
|
|
|
46876
46886
|
/*antecedent*/
|
|
46877
46887
|
void 0
|
|
46878
46888
|
);
|
|
46879
|
-
var reportedUnreachableFlow = createFlowNode(
|
|
46880
|
-
1 /* Unreachable */,
|
|
46881
|
-
/*node*/
|
|
46882
|
-
void 0,
|
|
46883
|
-
/*antecedent*/
|
|
46884
|
-
void 0
|
|
46885
|
-
);
|
|
46886
46889
|
var bindBinaryExpressionFlow = createBindBinaryExpressionFlow();
|
|
46887
46890
|
return bindSourceFile2;
|
|
46888
46891
|
function createDiagnosticForNode2(node, message, ...args) {
|
|
@@ -46898,7 +46901,6 @@ function createBinder() {
|
|
|
46898
46901
|
symbolCount = 0;
|
|
46899
46902
|
Symbol48 = objectAllocator.getSymbolConstructor();
|
|
46900
46903
|
Debug.attachFlowNodeDebugInfo(unreachableFlow);
|
|
46901
|
-
Debug.attachFlowNodeDebugInfo(reportedUnreachableFlow);
|
|
46902
46904
|
if (!file.locals) {
|
|
46903
46905
|
(_a = tracing) == null ? void 0 : _a.push(
|
|
46904
46906
|
tracing.Phase.Bind,
|
|
@@ -47271,16 +47273,19 @@ function createBinder() {
|
|
|
47271
47273
|
function bindChildren(node) {
|
|
47272
47274
|
const saveInAssignmentPattern = inAssignmentPattern;
|
|
47273
47275
|
inAssignmentPattern = false;
|
|
47274
|
-
if (
|
|
47275
|
-
if (canHaveFlowNode(node)
|
|
47276
|
+
if (currentFlow === unreachableFlow) {
|
|
47277
|
+
if (canHaveFlowNode(node)) {
|
|
47276
47278
|
node.flowNode = void 0;
|
|
47277
47279
|
}
|
|
47280
|
+
if (isPotentiallyExecutableNode(node)) {
|
|
47281
|
+
node.flags |= 1073741824 /* Unreachable */;
|
|
47282
|
+
}
|
|
47278
47283
|
bindEachChild(node);
|
|
47279
47284
|
bindJSDoc(node);
|
|
47280
47285
|
inAssignmentPattern = saveInAssignmentPattern;
|
|
47281
47286
|
return;
|
|
47282
47287
|
}
|
|
47283
|
-
if (
|
|
47288
|
+
if (244 /* FirstStatement */ <= node.kind && node.kind <= 260 /* LastStatement */ && canHaveFlowNode(node)) {
|
|
47284
47289
|
node.flowNode = currentFlow;
|
|
47285
47290
|
}
|
|
47286
47291
|
switch (node.kind) {
|
|
@@ -47867,8 +47872,8 @@ function createBinder() {
|
|
|
47867
47872
|
};
|
|
47868
47873
|
bind(node.label);
|
|
47869
47874
|
bind(node.statement);
|
|
47870
|
-
if (!activeLabelList.referenced
|
|
47871
|
-
|
|
47875
|
+
if (!activeLabelList.referenced) {
|
|
47876
|
+
node.label.flags |= 1073741824 /* Unreachable */;
|
|
47872
47877
|
}
|
|
47873
47878
|
activeLabelList = activeLabelList.next;
|
|
47874
47879
|
addAntecedent(postStatementLabel, currentFlow);
|
|
@@ -48645,20 +48650,6 @@ function createBinder() {
|
|
|
48645
48650
|
const span = getSpanOfTokenAtPosition(file, node.pos);
|
|
48646
48651
|
file.bindDiagnostics.push(createFileDiagnostic(file, span.start, span.length, message, ...args));
|
|
48647
48652
|
}
|
|
48648
|
-
function errorOrSuggestionOnNode(isError, node, message) {
|
|
48649
|
-
errorOrSuggestionOnRange(isError, node, node, message);
|
|
48650
|
-
}
|
|
48651
|
-
function errorOrSuggestionOnRange(isError, startNode2, endNode2, message) {
|
|
48652
|
-
addErrorOrSuggestionDiagnostic(isError, { pos: getTokenPosOfNode(startNode2, file), end: endNode2.end }, message);
|
|
48653
|
-
}
|
|
48654
|
-
function addErrorOrSuggestionDiagnostic(isError, range, message) {
|
|
48655
|
-
const diag2 = createFileDiagnostic(file, range.pos, range.end - range.pos, message);
|
|
48656
|
-
if (isError) {
|
|
48657
|
-
file.bindDiagnostics.push(diag2);
|
|
48658
|
-
} else {
|
|
48659
|
-
file.bindSuggestionDiagnostics = append(file.bindSuggestionDiagnostics, { ...diag2, category: 2 /* Suggestion */ });
|
|
48660
|
-
}
|
|
48661
|
-
}
|
|
48662
48653
|
function bind(node) {
|
|
48663
48654
|
if (!node) {
|
|
48664
48655
|
return;
|
|
@@ -49545,61 +49536,6 @@ function createBinder() {
|
|
|
49545
49536
|
declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 526824 /* TypeParameterExcludes */);
|
|
49546
49537
|
}
|
|
49547
49538
|
}
|
|
49548
|
-
function shouldReportErrorOnModuleDeclaration(node) {
|
|
49549
|
-
const instanceState = getModuleInstanceState(node);
|
|
49550
|
-
return instanceState === 1 /* Instantiated */ || instanceState === 2 /* ConstEnumOnly */ && shouldPreserveConstEnums(options);
|
|
49551
|
-
}
|
|
49552
|
-
function checkUnreachable(node) {
|
|
49553
|
-
if (!(currentFlow.flags & 1 /* Unreachable */)) {
|
|
49554
|
-
return false;
|
|
49555
|
-
}
|
|
49556
|
-
if (currentFlow === unreachableFlow) {
|
|
49557
|
-
const reportError = (
|
|
49558
|
-
// report error on all statements except empty ones
|
|
49559
|
-
isStatementButNotDeclaration(node) && node.kind !== 243 /* EmptyStatement */ || // report error on class declarations
|
|
49560
|
-
node.kind === 264 /* ClassDeclaration */ || // report errors on enums with preserved emit
|
|
49561
|
-
isEnumDeclarationWithPreservedEmit(node, options) || // report error on instantiated modules
|
|
49562
|
-
node.kind === 268 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)
|
|
49563
|
-
);
|
|
49564
|
-
if (reportError) {
|
|
49565
|
-
currentFlow = reportedUnreachableFlow;
|
|
49566
|
-
if (!options.allowUnreachableCode) {
|
|
49567
|
-
const isError = unreachableCodeIsError(options) && !(node.flags & 33554432 /* Ambient */) && (!isVariableStatement(node) || !!(getCombinedNodeFlags(node.declarationList) & 7 /* BlockScoped */) || node.declarationList.declarations.some((d) => !!d.initializer));
|
|
49568
|
-
eachUnreachableRange(node, options, (start, end) => errorOrSuggestionOnRange(isError, start, end, Diagnostics.Unreachable_code_detected));
|
|
49569
|
-
}
|
|
49570
|
-
}
|
|
49571
|
-
}
|
|
49572
|
-
return true;
|
|
49573
|
-
}
|
|
49574
|
-
}
|
|
49575
|
-
function isEnumDeclarationWithPreservedEmit(node, options) {
|
|
49576
|
-
return node.kind === 267 /* EnumDeclaration */ && (!isEnumConst(node) || shouldPreserveConstEnums(options));
|
|
49577
|
-
}
|
|
49578
|
-
function eachUnreachableRange(node, options, cb) {
|
|
49579
|
-
if (isStatement(node) && isExecutableStatement(node) && isBlock(node.parent)) {
|
|
49580
|
-
const { statements } = node.parent;
|
|
49581
|
-
const slice = sliceAfter(statements, node);
|
|
49582
|
-
getRangesWhere(slice, isExecutableStatement, (start, afterEnd) => cb(slice[start], slice[afterEnd - 1]));
|
|
49583
|
-
} else {
|
|
49584
|
-
cb(node, node);
|
|
49585
|
-
}
|
|
49586
|
-
function isExecutableStatement(s) {
|
|
49587
|
-
return !isFunctionDeclaration(s) && !isPurelyTypeDeclaration(s) && // `var x;` may declare a variable used above
|
|
49588
|
-
!(isVariableStatement(s) && !(getCombinedNodeFlags(s) & 7 /* BlockScoped */) && s.declarationList.declarations.some((d) => !d.initializer));
|
|
49589
|
-
}
|
|
49590
|
-
function isPurelyTypeDeclaration(s) {
|
|
49591
|
-
switch (s.kind) {
|
|
49592
|
-
case 265 /* InterfaceDeclaration */:
|
|
49593
|
-
case 266 /* TypeAliasDeclaration */:
|
|
49594
|
-
return true;
|
|
49595
|
-
case 268 /* ModuleDeclaration */:
|
|
49596
|
-
return getModuleInstanceState(s) !== 1 /* Instantiated */;
|
|
49597
|
-
case 267 /* EnumDeclaration */:
|
|
49598
|
-
return !isEnumDeclarationWithPreservedEmit(s, options);
|
|
49599
|
-
default:
|
|
49600
|
-
return false;
|
|
49601
|
-
}
|
|
49602
|
-
}
|
|
49603
49539
|
}
|
|
49604
49540
|
function isExportsOrModuleExportsOrAlias(sourceFile, node) {
|
|
49605
49541
|
let i = 0;
|
|
@@ -51040,6 +50976,8 @@ function createTypeChecker(host) {
|
|
|
51040
50976
|
var currentNode;
|
|
51041
50977
|
var varianceTypeParameter;
|
|
51042
50978
|
var isInferencePartiallyBlocked = false;
|
|
50979
|
+
var withinUnreachableCode = false;
|
|
50980
|
+
var reportedUnreachableNodes;
|
|
51043
50981
|
var emptySymbols = createSymbolTable();
|
|
51044
50982
|
var arrayVariances = [1 /* Covariant */];
|
|
51045
50983
|
var compilerOptions = host.getCompilerOptions();
|
|
@@ -89168,6 +89106,9 @@ function createTypeChecker(host) {
|
|
|
89168
89106
|
return false;
|
|
89169
89107
|
});
|
|
89170
89108
|
}
|
|
89109
|
+
if (node.label.flags & 1073741824 /* Unreachable */ && compilerOptions.allowUnusedLabels !== true) {
|
|
89110
|
+
errorOrSuggestion(compilerOptions.allowUnusedLabels === false, node.label, Diagnostics.Unused_label);
|
|
89111
|
+
}
|
|
89171
89112
|
checkSourceElement(node.statement);
|
|
89172
89113
|
}
|
|
89173
89114
|
function checkThrowStatement(node) {
|
|
@@ -91060,10 +91001,12 @@ function createTypeChecker(host) {
|
|
|
91060
91001
|
function checkSourceElement(node) {
|
|
91061
91002
|
if (node) {
|
|
91062
91003
|
const saveCurrentNode = currentNode;
|
|
91004
|
+
const saveWithinUnreachableCode = withinUnreachableCode;
|
|
91063
91005
|
currentNode = node;
|
|
91064
91006
|
instantiationCount = 0;
|
|
91065
91007
|
checkSourceElementWorker(node);
|
|
91066
91008
|
currentNode = saveCurrentNode;
|
|
91009
|
+
withinUnreachableCode = saveWithinUnreachableCode;
|
|
91067
91010
|
}
|
|
91068
91011
|
}
|
|
91069
91012
|
function checkSourceElementWorker(node) {
|
|
@@ -91091,8 +91034,10 @@ function createTypeChecker(host) {
|
|
|
91091
91034
|
cancellationToken.throwIfCancellationRequested();
|
|
91092
91035
|
}
|
|
91093
91036
|
}
|
|
91094
|
-
if (
|
|
91095
|
-
|
|
91037
|
+
if (compilerOptions.allowUnreachableCode !== true && !withinUnreachableCode) {
|
|
91038
|
+
if (checkSourceElementUnreachable(node)) {
|
|
91039
|
+
withinUnreachableCode = true;
|
|
91040
|
+
}
|
|
91096
91041
|
}
|
|
91097
91042
|
switch (kind) {
|
|
91098
91043
|
case 169 /* TypeParameter */:
|
|
@@ -91270,6 +91215,66 @@ function createTypeChecker(host) {
|
|
|
91270
91215
|
return checkMissingDeclaration(node);
|
|
91271
91216
|
}
|
|
91272
91217
|
}
|
|
91218
|
+
function checkSourceElementUnreachable(node) {
|
|
91219
|
+
if (!isPotentiallyExecutableNode(node)) {
|
|
91220
|
+
return false;
|
|
91221
|
+
}
|
|
91222
|
+
if (reportedUnreachableNodes == null ? void 0 : reportedUnreachableNodes.has(node)) {
|
|
91223
|
+
return true;
|
|
91224
|
+
}
|
|
91225
|
+
if (!isSourceElementUnreachable(node)) {
|
|
91226
|
+
return false;
|
|
91227
|
+
}
|
|
91228
|
+
(reportedUnreachableNodes ?? (reportedUnreachableNodes = /* @__PURE__ */ new Set())).add(node);
|
|
91229
|
+
const sourceFile = getSourceFileOfNode(node);
|
|
91230
|
+
let start = node.pos;
|
|
91231
|
+
let end = node.end;
|
|
91232
|
+
const parent2 = node.parent;
|
|
91233
|
+
if (canHaveStatements(parent2)) {
|
|
91234
|
+
const statements = parent2.statements;
|
|
91235
|
+
const offset = statements.indexOf(node);
|
|
91236
|
+
if (offset >= 0) {
|
|
91237
|
+
let first2 = offset;
|
|
91238
|
+
for (let i = offset - 1; i >= 0; i--) {
|
|
91239
|
+
const prevNode = statements[i];
|
|
91240
|
+
if (!isPotentiallyExecutableNode(prevNode) || reportedUnreachableNodes.has(prevNode) || !isSourceElementUnreachable(prevNode)) {
|
|
91241
|
+
break;
|
|
91242
|
+
}
|
|
91243
|
+
first2 = i;
|
|
91244
|
+
reportedUnreachableNodes.add(prevNode);
|
|
91245
|
+
}
|
|
91246
|
+
let last2 = offset;
|
|
91247
|
+
for (let i = offset + 1; i < statements.length; i++) {
|
|
91248
|
+
const nextNode = statements[i];
|
|
91249
|
+
if (!isPotentiallyExecutableNode(nextNode) || !isSourceElementUnreachable(nextNode)) {
|
|
91250
|
+
break;
|
|
91251
|
+
}
|
|
91252
|
+
last2 = i;
|
|
91253
|
+
reportedUnreachableNodes.add(nextNode);
|
|
91254
|
+
}
|
|
91255
|
+
start = statements[first2].pos;
|
|
91256
|
+
end = statements[last2].end;
|
|
91257
|
+
}
|
|
91258
|
+
}
|
|
91259
|
+
start = skipTrivia(sourceFile.text, start);
|
|
91260
|
+
addErrorOrSuggestion(compilerOptions.allowUnreachableCode === false, createFileDiagnostic(sourceFile, start, end - start, Diagnostics.Unreachable_code_detected));
|
|
91261
|
+
return true;
|
|
91262
|
+
}
|
|
91263
|
+
function isSourceElementUnreachable(node) {
|
|
91264
|
+
if (node.flags & 1073741824 /* Unreachable */) {
|
|
91265
|
+
switch (node.kind) {
|
|
91266
|
+
case 267 /* EnumDeclaration */:
|
|
91267
|
+
return !isEnumConst(node) || shouldPreserveConstEnums(compilerOptions);
|
|
91268
|
+
case 268 /* ModuleDeclaration */:
|
|
91269
|
+
return isInstantiatedModule(node, shouldPreserveConstEnums(compilerOptions));
|
|
91270
|
+
default:
|
|
91271
|
+
return true;
|
|
91272
|
+
}
|
|
91273
|
+
} else if (canHaveFlowNode(node) && node.flowNode) {
|
|
91274
|
+
return !isReachableFlowNode(node.flowNode);
|
|
91275
|
+
}
|
|
91276
|
+
return false;
|
|
91277
|
+
}
|
|
91273
91278
|
function checkJSDocCommentWorker(node) {
|
|
91274
91279
|
if (isArray(node)) {
|
|
91275
91280
|
forEach(node, (tag) => {
|
|
@@ -91432,6 +91437,7 @@ function createTypeChecker(host) {
|
|
|
91432
91437
|
mark(afterMark);
|
|
91433
91438
|
measure("Check", beforeMark, afterMark);
|
|
91434
91439
|
(_b = tracing) == null ? void 0 : _b.pop();
|
|
91440
|
+
reportedUnreachableNodes = void 0;
|
|
91435
91441
|
}
|
|
91436
91442
|
function unusedIsError(kind, isAmbient) {
|
|
91437
91443
|
if (isAmbient) {
|
|
@@ -129369,7 +129375,7 @@ function createProgram(_rootNamesOrOptions, _options, _host, _oldProgram, _confi
|
|
|
129369
129375
|
}
|
|
129370
129376
|
}
|
|
129371
129377
|
if (options.allowImportingTsExtensions && !(options.noEmit || options.emitDeclarationOnly || options.rewriteRelativeImportExtensions)) {
|
|
129372
|
-
createOptionValueDiagnostic("allowImportingTsExtensions", Diagnostics.
|
|
129378
|
+
createOptionValueDiagnostic("allowImportingTsExtensions", Diagnostics.Option_allowImportingTsExtensions_can_only_be_used_when_one_of_noEmit_emitDeclarationOnly_or_rewriteRelativeImportExtensions_is_set);
|
|
129373
129379
|
}
|
|
129374
129380
|
const moduleResolution = getEmitModuleResolutionKind(options);
|
|
129375
129381
|
if (options.resolvePackageJsonExports && !moduleResolutionSupportsPackageJsonExportsAndImports(moduleResolution)) {
|
|
@@ -183638,6 +183644,7 @@ __export(ts_exports2, {
|
|
|
183638
183644
|
canHaveLocals: () => canHaveLocals,
|
|
183639
183645
|
canHaveModifiers: () => canHaveModifiers,
|
|
183640
183646
|
canHaveModuleSpecifier: () => canHaveModuleSpecifier,
|
|
183647
|
+
canHaveStatements: () => canHaveStatements,
|
|
183641
183648
|
canHaveSymbol: () => canHaveSymbol,
|
|
183642
183649
|
canIncludeBindAndCheckDiagnostics: () => canIncludeBindAndCheckDiagnostics,
|
|
183643
183650
|
canJsonReportNoInputFiles: () => canJsonReportNoInputFiles,
|
|
@@ -185030,6 +185037,7 @@ __export(ts_exports2, {
|
|
|
185030
185037
|
isPlusToken: () => isPlusToken,
|
|
185031
185038
|
isPossiblyTypeArgumentPosition: () => isPossiblyTypeArgumentPosition,
|
|
185032
185039
|
isPostfixUnaryExpression: () => isPostfixUnaryExpression,
|
|
185040
|
+
isPotentiallyExecutableNode: () => isPotentiallyExecutableNode,
|
|
185033
185041
|
isPrefixUnaryExpression: () => isPrefixUnaryExpression,
|
|
185034
185042
|
isPrimitiveLiteralValue: () => isPrimitiveLiteralValue,
|
|
185035
185043
|
isPrivateIdentifier: () => isPrivateIdentifier,
|
|
@@ -185632,9 +185640,7 @@ __export(ts_exports2, {
|
|
|
185632
185640
|
unmangleScopedPackageName: () => unmangleScopedPackageName,
|
|
185633
185641
|
unorderedRemoveItem: () => unorderedRemoveItem,
|
|
185634
185642
|
unprefixedNodeCoreModules: () => unprefixedNodeCoreModules,
|
|
185635
|
-
unreachableCodeIsError: () => unreachableCodeIsError,
|
|
185636
185643
|
unsetNodeChildren: () => unsetNodeChildren,
|
|
185637
|
-
unusedLabelIsError: () => unusedLabelIsError,
|
|
185638
185644
|
unwrapInnermostStatementOfLabel: () => unwrapInnermostStatementOfLabel,
|
|
185639
185645
|
unwrapParenthesizedExpression: () => unwrapParenthesizedExpression,
|
|
185640
185646
|
updateErrorForNoInputFiles: () => updateErrorForNoInputFiles,
|
|
@@ -198400,6 +198406,7 @@ if (typeof console !== "undefined") {
|
|
|
198400
198406
|
canHaveLocals,
|
|
198401
198407
|
canHaveModifiers,
|
|
198402
198408
|
canHaveModuleSpecifier,
|
|
198409
|
+
canHaveStatements,
|
|
198403
198410
|
canHaveSymbol,
|
|
198404
198411
|
canIncludeBindAndCheckDiagnostics,
|
|
198405
198412
|
canJsonReportNoInputFiles,
|
|
@@ -199792,6 +199799,7 @@ if (typeof console !== "undefined") {
|
|
|
199792
199799
|
isPlusToken,
|
|
199793
199800
|
isPossiblyTypeArgumentPosition,
|
|
199794
199801
|
isPostfixUnaryExpression,
|
|
199802
|
+
isPotentiallyExecutableNode,
|
|
199795
199803
|
isPrefixUnaryExpression,
|
|
199796
199804
|
isPrimitiveLiteralValue,
|
|
199797
199805
|
isPrivateIdentifier,
|
|
@@ -200394,9 +200402,7 @@ if (typeof console !== "undefined") {
|
|
|
200394
200402
|
unmangleScopedPackageName,
|
|
200395
200403
|
unorderedRemoveItem,
|
|
200396
200404
|
unprefixedNodeCoreModules,
|
|
200397
|
-
unreachableCodeIsError,
|
|
200398
200405
|
unsetNodeChildren,
|
|
200399
|
-
unusedLabelIsError,
|
|
200400
200406
|
unwrapInnermostStatementOfLabel,
|
|
200401
200407
|
unwrapParenthesizedExpression,
|
|
200402
200408
|
updateErrorForNoInputFiles,
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "typescript",
|
|
3
3
|
"author": "Microsoft Corp.",
|
|
4
4
|
"homepage": "https://www.typescriptlang.org/",
|
|
5
|
-
"version": "6.0.0-dev.
|
|
5
|
+
"version": "6.0.0-dev.20251115",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"description": "TypeScript is a language for application scale JavaScript development",
|
|
8
8
|
"keywords": [
|
|
@@ -115,5 +115,5 @@
|
|
|
115
115
|
"node": "20.1.0",
|
|
116
116
|
"npm": "8.19.4"
|
|
117
117
|
},
|
|
118
|
-
"gitHead": "
|
|
118
|
+
"gitHead": "cc2610fd347127c28609b4fca6fa9d55ee5063c6"
|
|
119
119
|
}
|