README for ts-plugin

This commit is contained in:
Tony Garnock-Jones 2021-04-26 14:21:48 +02:00
parent ccd87c09f1
commit f338373ac5
1 changed files with 62 additions and 0 deletions

View File

@ -0,0 +1,62 @@
# TypeScript plugin for Syndicate
Rewrites Syndicate DSL syntax into plain TypeScript as a `tsserver`
plugin, allowing your IDE to work directly with Syndicate constructs
and not requiring a separate preprocessing step.
Sadly, `tsc` doesn't pay attention to plugins (not as of April 2021,
anyway). If you're using `tsc` as part of your build, you will need to
use `@syndicate-lang/tsc`'s `syndicate-tsc` command instead.
## Installing the plugin
`package.json`:
{
"devDependencies": {
"@syndicate-lang/ts-plugin": "file:../..",
...
},
...
}
then `yarn install` or `npm install`.
## Enabling the plugin in the TypeScript compiler
`tsconfig.json`:
{
"compilerOptions": {
"plugins": [
{ "name": "@syndicate-lang/ts-plugin" }
],
...
},
...
}
## Getting it to work with specific editors
### Emacs with Tide
It should Just Work.
### Visual Studio Code
After `yarn install`/`npm install`, you will have a
`node_modules/typescript` directory.
Open VS Code, and select the version of TypeScript contained therein
by following instructions
[here](https://code.visualstudio.com/docs/typescript/typescript-compiling#_using-newer-typescript-versions).
Specifically, when selecting a TypeScript version,
[choose "Use Workspace Version"](https://code.visualstudio.com/docs/typescript/typescript-compiling#_using-the-workspace-version-of-typescript).
For me, the net effect of this is to create a `.vscode/settings.json`
file containing:
{
"typescript.tsdk": "node_modules/typescript/lib"
}