@greffon/ts-plugin
v0.1.1
Published
TypeScript language-service plugin: in-editor Greffon subset diagnostics (shares the capture validator).
Maintainers
Readme
@greffon/ts-plugin
The editor surface of Greffon, expression trees for TypeScript: a language-service plugin that puts red squiggles on out-of-subset syntax in query lambdas, as you type.
One validator backs three hosts: the plugin shares @greffon/capture's subset checks with the build transform and
@greffon/eslint-plugin, so an invalid lambda
gets the same Rxxxx code and the same span as an editor squiggle, a lint
finding, and a build error.
Install
npm install -D @greffon/ts-pluginUsage
List the plugin in tsconfig.json:
{
"compilerOptions": {
"plugins": [{ "name": "@greffon/ts-plugin" }]
}
}The plugin checks lambdas written at query call sites and inside expr(). It resolves the receiver by type, so
db.users.filter(…) is checked even when db is imported from another module, while an ordinary rows.filter(…) on
an array is left alone.
Two things to know:
- The
pluginsfield configures the language service only — it changes what your editor reports, never whattscemits. Reifying trees in atsc-only build is a separate concern: Compiling with tsc. - Editors load language-service plugins from the workspace TypeScript (the peer dependency is
typescript>=5), so point your editor at the workspace version. In VS Code: TypeScript: Select TypeScript Version → Use Workspace Version.
