UNPKG

1.26 kBTypeScriptView Raw
1import * as ts from 'typescript';
2export declare function endsControlFlow(statement: ts.Statement | ts.BlockLike, checker?: ts.TypeChecker): boolean;
3export declare type ControlFlowStatement = ts.BreakStatement | ts.ContinueStatement | ts.ReturnStatement | ts.ThrowStatement | ts.ExpressionStatement & {
4 expression: ts.CallExpression;
5};
6export interface ControlFlowEnd {
7 /**
8 * Statements that may end control flow at this statement.
9 * Does not contain control flow statements that jump only inside the statement, for example a `continue` inside a nested for loop.
10 */
11 readonly statements: ReadonlyArray<ControlFlowStatement>;
12 /** `true` if control flow definitely ends. */
13 readonly end: boolean;
14}
15export declare function getControlFlowEnd(statement: ts.Statement | ts.BlockLike, checker?: ts.TypeChecker): ControlFlowEnd;
16export declare enum SignatureEffect {
17 Never = 1,
18 Asserts = 2
19}
20/**
21 * Dermines whether a top level CallExpression has a control flow effect according to TypeScript's rules.
22 * This handles functions returning `never` and `asserts`.
23 */
24export declare function callExpressionAffectsControlFlow(node: ts.CallExpression, checker: ts.TypeChecker): SignatureEffect | undefined;