Skip to content

Type the parsers and printers exports by their keys - #93

Merged
nene merged 1 commit into
nene:masterfrom
abrahamguo:printers-type
Oct 21, 2026
Merged

nene merged 1 commit into
nene:masterfrom
abrahamguo:printers-type

Conversation

@abrahamguo

Copy link
Copy Markdown
Contributor

parsers and printers are typed as Record<string, …>, so with noUncheckedIndexedAccess enabled, parsers.postgresql and printers["sql-cst"] are possibly undefined. Reusing or wrapping one of them then needs a non-null assertion:

import { parsers, printers } from "prettier-plugin-sql-cst";

const postgresqlParser = parsers.postgresql!;
const sqlPrinter = printers["sql-cst"]!;

This narrows the keys to the ones the plugin defines: DialectName for parsers and "sql-cst" for printers. The value types stay the same, and dist/index.js is unchanged.

@nene

nene commented Oct 21, 2026

Copy link
Copy Markdown
Owner

Thanks!

@nene
nene merged commit 0370fe5 into nene:master Oct 21, 2026
1 check passed
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.

2 participants