Line

packages/ast/stateShape

AST package: "bag of flags" state-shape detection -- the shape STATE-001 flags in workflow and hook files: state typed (or initialised) as one object whose fields are several co-occurring status-style booleans (`loadi...

AST, v0.9. Source: packages/ast/stateShape.mjs.

Functions#

classifyStateFields()#

classifyStateFields(members): object

Defined in: packages/ast/stateShape.mjs:115

Classify one member list into the flags / error / data fields the heuristic cares about, or null when the combination is allowed.

Parameters#

members

object[]

The shape's own fields.

Returns#

object

The offending fields, or null.

data

data: any

error

error: any

flags

flags: string[]


collectBagOfFlagsStates()#

collectBagOfFlagsStates(ast, source): object[]

Defined in: packages/ast/stateShape.mjs:171

Every "bag of flags" state shape in a parsed file (the shape STATE-001 flags), in source order.

Parameters#

ast

any

A parsed Program (from parseToAst).

source

string

The same file's source text (for the type text of the fields it names).

Returns#

object[]

One entry per offending shape: kind is interface | type | initial (a top-level const named like an initial state) | useState | useReducer | context; name is the declared type/const name (typeName is what the suggested union is called); fields are the offending member names; suggestion is a compiling union rewrite.