Skip to content

Expose parser AST statements and expression/codegen types in published TypeScript declarations - #2527

Draft
mathiasrw with Copilot wants to merge 3 commits into
developfrom
copilot/expose-parser-ast-tojs-docs
Draft

Expose parser AST statements and expression/codegen types in published TypeScript declarations#2527
mathiasrw with Copilot wants to merge 3 commits into
developfrom
copilot/expose-parser-ast-tojs-docs

Conversation

Copilot AI commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

AlaSQL’s published types only exposed AlaSQLAST.compile(...), leaving parser/codegen consumers to cast around undocumented internals (statements, where, toJS). This PR surfaces the existing parser API in types/alasql.d.ts and documents stable expression node shapes already used in practice.

  • Type surface: expose parsed statements

    • Adds statements: Statement[] to AlaSQLAST.
    • Introduces a typed Statement shape with where?: ExpressionWrapper to model common parser access patterns.
  • Type surface: document expression codegen contract

    • Adds base AlaSQLExpression with:
      • toJS(context: string, tableid: string | number, defcols: AlaSQLDefaultColumns | null): string
    • Captures default-column map as AlaSQLDefaultColumns.
  • Type surface: publish stable node shapes

    • Adds explicit node interfaces for:
      • Op (left, op, right/right1/right2)
      • Column (columnid, optional tableid, databaseid)
      • ParamValue (param)
      • NumValue (value)
      • StringValue (value)
      • LogicValue (value)
      • UniOp (op, right)
    • Adds ExpressionNode union over concrete node types.
  • Regression coverage for parser consumers

    • Adds test/test2498.js to lock in:
      • parse(...).statements[0].where
      • where.toJS(...) producing executable JS expression
      • expected node-field access for the documented shapes
const ast = alasql.parse('SELECT 1 FROM ? WHERE x < $y');
const where = ast.statements[0].where;
const js = where.toJS('p', '', null);
const fn = new Function('alasql', 'p', 'params', `return Boolean(${js});`);

Copilot AI changed the title [WIP] Expose and document the parser AST and toJS() in published types Expose parser AST statements and expression/codegen types in published TypeScript declarations Aug 20, 2026
Copilot AI requested a review from mathiasrw August 20, 2026 11:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Expose and document the parser AST + toJS() in the published types

2 participants