Skip to content

Commit ca0d580

Browse files
committed
merge with master, fix linter issues
1 parent 9d24e0f commit ca0d580

3 files changed

Lines changed: 41 additions & 41 deletions

File tree

src/compiler/binder.ts

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ namespace ts {
99
Instantiated = 1,
1010
ConstEnumOnly = 2
1111
}
12-
12+
1313
const enum Reachability {
1414
Unintialized = 1 << 0,
1515
Reachable = 1 << 1,
1616
Unreachable = 1 << 2,
1717
ReportedUnreachable = 1 << 3
1818
}
19-
19+
2020
function or(state1: Reachability, state2: Reachability): Reachability {
2121
return (state1 | state2) & Reachability.Reachable
2222
? Reachability.Reachable
@@ -111,7 +111,7 @@ namespace ts {
111111
let labelStack: Reachability[];
112112
let labelIndexMap: Map<number>;
113113
let implicitLabels: number[];
114-
114+
115115
// If this file is an external module, then it is automatically in strict-mode according to
116116
// ES6. If it is not an external module, then we'll determine if it is in strict mode or
117117
// not depending on if we see "use strict" in certain places (or if we hit a class/namespace).
@@ -365,26 +365,26 @@ namespace ts {
365365
parent = saveParent;
366366
blockScopeContainer = savedBlockScopeContainer;
367367
}
368-
368+
369369
function shouldSaveReachabilityState(n: Node): boolean {
370370
return n.kind === SyntaxKind.SourceFile || n.kind === SyntaxKind.ModuleBlock || isFunctionLike(n);
371371
}
372-
372+
373373
function bindWithReachabilityChecks(node: Node): void {
374374
let savedReachabilityState: Reachability;
375375
let savedLabelStack: Reachability[];
376376
let savedLabels: Map<number>;
377377
let savedImplicitLabels: number[];
378378
let savedHasExplicitReturn: boolean;
379-
379+
380380
let saveState = shouldSaveReachabilityState(node);
381381
if (saveState) {
382382
savedReachabilityState = currentReachabilityState;
383383
savedLabelStack = labelStack;
384384
savedLabels = labelIndexMap;
385385
savedImplicitLabels = implicitLabels;
386386
savedHasExplicitReturn = hasExplicitReturn;
387-
387+
388388
currentReachabilityState = Reachability.Reachable;
389389
hasExplicitReturn = false;
390390
labelStack = labelIndexMap = implicitLabels = undefined;
@@ -393,7 +393,7 @@ namespace ts {
393393
if (!bindReachableStatement(node)) {
394394
forEachChild(node, bind);
395395
}
396-
396+
397397
if (currentReachabilityState === Reachability.Reachable && isFunctionLike(node) && nodeIsPresent((<FunctionLikeDeclaration>node).body)) {
398398
node.flags |= NodeFlags.HasImplicitReturn;
399399
if (hasExplicitReturn) {
@@ -451,19 +451,19 @@ namespace ts {
451451
}
452452

453453
function bindWhileStatement(n: WhileStatement): boolean {
454-
const preWhileState =
454+
const preWhileState =
455455
n.expression.kind === SyntaxKind.FalseKeyword ? Reachability.Unreachable : currentReachabilityState;
456-
const postWhileState =
456+
const postWhileState =
457457
n.expression.kind === SyntaxKind.TrueKeyword ? Reachability.Unreachable : currentReachabilityState;
458458

459459
// bind expressions (don't affect reachability)
460460
bind(n.expression);
461-
461+
462462
currentReachabilityState = preWhileState;
463463
const postWhileLabel = pushImplicitLabel();
464464
bind(n.statement);
465-
popImplicitLabel(postWhileLabel, postWhileState)
466-
465+
popImplicitLabel(postWhileLabel, postWhileState);
466+
467467
return true;
468468
}
469469

@@ -480,7 +480,7 @@ namespace ts {
480480

481481
return true;
482482
}
483-
483+
484484
function bindForStatement(n: ForStatement): boolean {
485485
const preForState = currentReachabilityState;
486486
const postForLabel = pushImplicitLabel();
@@ -505,7 +505,7 @@ namespace ts {
505505
function bindForInOrForOfStatement(n: ForInStatement | ForOfStatement): boolean {
506506
const preStatementState = currentReachabilityState;
507507
const postStatementLabel = pushImplicitLabel();
508-
508+
509509
// bind expressions (don't affect reachability)
510510
bind(n.initializer);
511511
bind(n.expression);
@@ -566,7 +566,7 @@ namespace ts {
566566
currentReachabilityState = Reachability.Unreachable;
567567

568568
return true;
569-
}
569+
}
570570

571571
function bindTryStatement(n: TryStatement): boolean {
572572
// catch\finally blocks has the same reachability as try block
@@ -597,7 +597,7 @@ namespace ts {
597597
bind(n.expression);
598598

599599
bind(n.caseBlock);
600-
600+
601601
const hasDefault = forEach(n.caseBlock.clauses, c => c.kind === SyntaxKind.DefaultClause);
602602

603603
// post switch state is unreachable if switch is exaustive (has a default case ) and does not have fallthrough from the last case
@@ -1055,7 +1055,7 @@ namespace ts {
10551055
if (!node) {
10561056
return;
10571057
}
1058-
1058+
10591059
node.parent = parent;
10601060

10611061
let savedInStrictMode = inStrictMode;
@@ -1365,46 +1365,46 @@ namespace ts {
13651365

13661366
function pushNamedLabel(name: Identifier): boolean {
13671367
initializeReachabilityStateIfNecessary();
1368-
1368+
13691369
if (hasProperty(labelIndexMap, name.text)) {
13701370
return false;
13711371
}
13721372
labelIndexMap[name.text] = labelStack.push(Reachability.Unintialized) - 1;
13731373
return true;
13741374
}
1375-
1375+
13761376
function pushImplicitLabel(): number {
13771377
initializeReachabilityStateIfNecessary();
1378-
1378+
13791379
let index = labelStack.push(Reachability.Unintialized) - 1;
13801380
implicitLabels.push(index);
13811381
return index;
13821382
}
1383-
1383+
13841384
function popNamedLabel(label: Identifier, outerState: Reachability): void {
13851385
initializeReachabilityStateIfNecessary();
1386-
1386+
13871387
let index = labelIndexMap[label.text];
13881388
Debug.assert(index !== undefined);
13891389
Debug.assert(labelStack.length == index + 1);
1390-
1390+
13911391
labelIndexMap[label.text] = undefined;
1392-
1392+
13931393
setCurrentStateAtLabel(labelStack.pop(), outerState, label);
13941394
}
1395-
1395+
13961396
function popImplicitLabel(implicitLabelIndex: number, outerState: Reachability): void {
13971397
initializeReachabilityStateIfNecessary();
1398-
1398+
13991399
Debug.assert(labelStack.length === implicitLabelIndex + 1, `Label stack: ${labelStack.length}, index:${implicitLabelIndex}`);
14001400
let i = implicitLabels.pop();
14011401
Debug.assert(implicitLabelIndex === i, `i: ${i}, index: ${implicitLabelIndex}`);
14021402
setCurrentStateAtLabel(labelStack.pop(), outerState, /*name*/ undefined);
14031403
}
1404-
1404+
14051405
function setCurrentStateAtLabel(innerMergedState: Reachability, outerState: Reachability, label: Identifier): void {
14061406
initializeReachabilityStateIfNecessary();
1407-
1407+
14081408
if (innerMergedState === Reachability.Unintialized) {
14091409
if (label && options.noUnusedLabels) {
14101410
file.bindDiagnostics.push(createDiagnosticForNode(label, Diagnostics.Unused_label));
@@ -1415,10 +1415,10 @@ namespace ts {
14151415
currentReachabilityState = or(innerMergedState, outerState);
14161416
}
14171417
}
1418-
1418+
14191419
function jumpToLabel(label: Identifier, outerState: Reachability): void {
14201420
initializeReachabilityStateIfNecessary();
1421-
1421+
14221422
const index = label ? labelIndexMap[label.text] : lastOrUndefined(implicitLabels);
14231423
if (index === undefined) {
14241424
// reference to unknown label or
@@ -1444,7 +1444,7 @@ namespace ts {
14441444

14451445
if (reportError) {
14461446
currentReachabilityState = Reachability.ReportedUnreachable;
1447-
1447+
14481448
// unreachable code is reported if
14491449
// - user has explicitly asked about it AND
14501450
// - statement is in not ambient context (statements in ambient context is already an error
@@ -1453,15 +1453,15 @@ namespace ts {
14531453
// - node is block scoped variable statement OR
14541454
// - node is not block scoped variable statement and at least one variable declaration has initializer
14551455
// Rationale: we don't want to report errors on non-initialized var's since they are hoisted
1456-
// On the other side we do want to report errors on non-initialized 'lets' because of TDZ
1457-
const reportUnreachableCode =
1456+
// On the other side we do want to report errors on non-initialized 'lets' because of TDZ
1457+
const reportUnreachableCode =
14581458
options.noUnreachableCode &&
14591459
!isInAmbientContext(node) &&
14601460
(
14611461
node.kind !== SyntaxKind.VariableStatement ||
14621462
getCombinedNodeFlags((<VariableStatement>node).declarationList) & NodeFlags.BlockScoped ||
14631463
forEach((<VariableStatement>node).declarationList.declarations, d => d.initializer)
1464-
)
1464+
);
14651465

14661466
if (reportUnreachableCode) {
14671467
file.bindDiagnostics.push(createDiagnosticForNode(node, Diagnostics.Unreachable_code_detected));

src/compiler/checker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9553,7 +9553,7 @@ namespace ts {
95539553
if (nodeIsMissing(func.body) || func.body.kind !== SyntaxKind.Block || !(func.flags & NodeFlags.HasImplicitReturn)) {
95549554
return;
95559555
}
9556-
9556+
95579557
if (func.flags & NodeFlags.HasExplicitReturn) {
95589558
if (compilerOptions.noImplicitReturns) {
95599559
error(func.type, Diagnostics.Not_all_code_paths_return_a_value);

src/compiler/types.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2074,11 +2074,11 @@ namespace ts {
20742074
experimentalDecorators?: boolean;
20752075
experimentalAsyncFunctions?: boolean;
20762076
emitDecoratorMetadata?: boolean;
2077-
moduleResolution?: ModuleResolutionKind,
2078-
noUnusedLabels?: boolean,
2079-
noImplicitReturns?: boolean,
2080-
noFallthroughCasesInSwitch?: boolean,
2081-
noUnreachableCode?: boolean,
2077+
moduleResolution?: ModuleResolutionKind;
2078+
noUnusedLabels?: boolean;
2079+
noImplicitReturns?: boolean;
2080+
noFallthroughCasesInSwitch?: boolean;
2081+
noUnreachableCode?: boolean;
20822082
/* @internal */ stripInternal?: boolean;
20832083

20842084
// Skip checking lib.d.ts to help speed up tests.

0 commit comments

Comments
 (0)