Skip to content

Export parser AST types from the alasql module declaration - #2547

Open
assapir wants to merge 1 commit into
AlaSQL:developfrom
assapir:fix/2498-export-parser-ast-types
Open

Export parser AST types from the alasql module declaration#2547
assapir wants to merge 1 commit into
AlaSQL:developfrom
assapir:fix/2498-export-parser-ast-types

Conversation

@assapir

@assapir assapir commented Aug 30, 2026

Copy link
Copy Markdown

Closes the follow-up in #2498 (comment).

Problem

v4.19.0 added the parser AST interfaces, but consumers can't name them:

import type {Statement} from 'alasql';        // TS2305
import alasql = require('alasql');
let a: alasql.AlaSQLAST;                      // TS2503
export function p(sql: string) {
	return alasql.parse(sql);                 // TS4058
}

In an ambient module declaration, all declarations are implicitly exported unless the module contains an export assignment. export = alasql is that assignment, so nothing but the const escaped.

Fix

export on the top-level declarations inside declare module 'alasql'. Type-only, no bodies moved, export = kept — so the module stays callable.

Verification

A consumer file compiled with tsc --strict --declaration, before vs. after:

before after
import type {Statement, AlaSQLAST} TS2305 ×2 ok
import a = require('alasql'); a.AlaSQLAST TS2503 ok
import * as a; a.AlaSQLAST TS2503 ok
exported fn returning parse() TS4058 ok
import alasql from 'alasql' + call / .options / .fn ok ok

The interfaces added for AlaSQL#2498 could not be named by consumers:
`import type {Statement} from 'alasql'` failed with TS2305 and
`alasql.AlaSQLAST` with TS2503, so re-exporting parse()'s result hit
TS4058.

In an ambient module declaration all declarations are implicitly
exported unless the module contains an export assignment. `export =
alasql` is that assignment, so nothing but the const escaped. Marking
the declarations `export` restores the type-side surface while keeping
the module itself callable.

Type-only change, no bodies moved.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.

1 participant