Export parser AST types from the alasql module declaration - #2547
Open
assapir wants to merge 1 commit into
Open
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes the follow-up in #2498 (comment).
Problem
v4.19.0 added the parser AST interfaces, but consumers can't name them:
In an ambient module declaration, all declarations are implicitly exported unless the module contains an export assignment.
export = alasqlis that assignment, so nothing but theconstescaped.Fix
exporton the top-level declarations insidedeclare 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:import type {Statement, AlaSQLAST}import a = require('alasql'); a.AlaSQLASTimport * as a; a.AlaSQLASTparse()import alasql from 'alasql'+ call /.options/.fn