Skip to content

Remove FlowNodes and FlowFlags from public API #58036

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/compiler/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4070,6 +4070,7 @@ export interface JSDocImportTag extends JSDocTag {

// NOTE: Ensure this is up-to-date with src/debug/debug.ts
// dprint-ignore
/** @internal */
export const enum FlowFlags {
Unreachable = 1 << 0, // Unreachable code
Start = 1 << 1, // Start of flow graph
Expand All @@ -4089,6 +4090,7 @@ export const enum FlowFlags {
Condition = TrueCondition | FalseCondition,
}

/** @internal */
export type FlowNode =
| FlowStart
| FlowLabel
Expand All @@ -4099,6 +4101,7 @@ export type FlowNode =
| FlowCall
| FlowReduceLabel;

/** @internal */
export interface FlowNodeBase {
flags: FlowFlags;
id?: number; // Node id used by flow type cache in checker
Expand All @@ -4107,35 +4110,41 @@ export interface FlowNodeBase {
// FlowStart represents the start of a control flow. For a function expression or arrow
// function, the node property references the function (which in turn has a flowNode
// property for the containing control flow).
/** @internal */
export interface FlowStart extends FlowNodeBase {
node?: FunctionExpression | ArrowFunction | MethodDeclaration | GetAccessorDeclaration | SetAccessorDeclaration;
}

// FlowLabel represents a junction with multiple possible preceding control flows.
/** @internal */
export interface FlowLabel extends FlowNodeBase {
antecedents: FlowNode[] | undefined;
}

// FlowAssignment represents a node that assigns a value to a narrowable reference,
// i.e. an identifier or a dotted name that starts with an identifier or 'this'.
/** @internal */
export interface FlowAssignment extends FlowNodeBase {
node: Expression | VariableDeclaration | BindingElement;
antecedent: FlowNode;
}

/** @internal */
export interface FlowCall extends FlowNodeBase {
node: CallExpression;
antecedent: FlowNode;
}

// FlowCondition represents a condition that is known to be true or false at the
// node's location in the control flow.
/** @internal */
export interface FlowCondition extends FlowNodeBase {
node: Expression;
antecedent: FlowNode;
}

// dprint-ignore
/** @internal */
export interface FlowSwitchClause extends FlowNodeBase {
switchStatement: SwitchStatement;
clauseStart: number; // Start index of case/default clause range
Expand All @@ -4145,11 +4154,13 @@ export interface FlowSwitchClause extends FlowNodeBase {

// FlowArrayMutation represents a node potentially mutates an array, i.e. an
// operation of the form 'x.push(value)', 'x.unshift(value)' or 'x[n] = value'.
/** @internal */
export interface FlowArrayMutation extends FlowNodeBase {
node: CallExpression | BinaryExpression;
antecedent: FlowNode;
}

/** @internal */
export interface FlowReduceLabel extends FlowNodeBase {
target: FlowLabel;
antecedents: FlowNode[];
Expand Down
55 changes: 0 additions & 55 deletions tests/baselines/reference/api/typescript.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5793,61 +5793,6 @@ declare namespace ts {
readonly moduleSpecifier: Expression;
readonly attributes?: ImportAttributes;
}
enum FlowFlags {
Unreachable = 1,
Start = 2,
BranchLabel = 4,
LoopLabel = 8,
Assignment = 16,
TrueCondition = 32,
FalseCondition = 64,
SwitchClause = 128,
ArrayMutation = 256,
Call = 512,
ReduceLabel = 1024,
Referenced = 2048,
Shared = 4096,
Label = 12,
Condition = 96,
}
type FlowNode = FlowStart | FlowLabel | FlowAssignment | FlowCondition | FlowSwitchClause | FlowArrayMutation | FlowCall | FlowReduceLabel;
interface FlowNodeBase {
flags: FlowFlags;
id?: number;
}
interface FlowStart extends FlowNodeBase {
node?: FunctionExpression | ArrowFunction | MethodDeclaration | GetAccessorDeclaration | SetAccessorDeclaration;
}
interface FlowLabel extends FlowNodeBase {
antecedents: FlowNode[] | undefined;
}
interface FlowAssignment extends FlowNodeBase {
node: Expression | VariableDeclaration | BindingElement;
antecedent: FlowNode;
}
interface FlowCall extends FlowNodeBase {
node: CallExpression;
antecedent: FlowNode;
}
interface FlowCondition extends FlowNodeBase {
node: Expression;
antecedent: FlowNode;
}
interface FlowSwitchClause extends FlowNodeBase {
switchStatement: SwitchStatement;
clauseStart: number;
clauseEnd: number;
antecedent: FlowNode;
}
interface FlowArrayMutation extends FlowNodeBase {
node: CallExpression | BinaryExpression;
antecedent: FlowNode;
}
interface FlowReduceLabel extends FlowNodeBase {
target: FlowLabel;
antecedents: FlowNode[];
antecedent: FlowNode;
}
type FlowType = Type | IncompleteType;
interface IncompleteType {
flags: TypeFlags | 0;
Expand Down