control-flow.d.ts 1.2 KB

123456789101112131415161718192021222324
  1. import * as ts from 'typescript';
  2. export declare function endsControlFlow(statement: ts.Statement | ts.BlockLike, checker?: ts.TypeChecker): boolean;
  3. export declare type ControlFlowStatement = ts.BreakStatement | ts.ContinueStatement | ts.ReturnStatement | ts.ThrowStatement | ts.ExpressionStatement & {
  4. expression: ts.CallExpression;
  5. };
  6. export 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. }
  15. export declare function getControlFlowEnd(statement: ts.Statement | ts.BlockLike, checker?: ts.TypeChecker): ControlFlowEnd;
  16. export 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. */
  24. export declare function callExpressionAffectsControlFlow(node: ts.CallExpression, checker: ts.TypeChecker): SignatureEffect | undefined;