ts-mysql-plugin
A typescript language service plugin that gives superpowers to SQL tagged template literals. Specifically aimed at the MySQL syntax.
Features
- Autocomplete for MySQL keywords
- Autocomplete for table names and column names (powered by your schema)
- Hover documentation for MySQL keywords
- Hover documentation for tables and columns (powered by your schema)
- Diagnostics for MySQL syntax errors
- Diagnostics for invalid table names and column names (powered by your schema)
- Diagnostics for invalid column types (powered by your schema)
- Works in all major editors (VSCode, Sublime Text, Atom, etc.)
Installing
Step 1: Yarn.
yarn add --dev ts-mysql-plugin
Step 2: TS Config.
Add the plugin to your compiler options in tsconfig.json
. Note that databaseUri
is optional, but recommended.
You can also optionally override the default tags ("SQL" and "sql") by adding a "tags" array to the config. For example, if you want the plugin to activate only on "Sql" tags:
If you add @ts-mysql-plugin ignore
in a comment at the top of a file, then the plugin will skip the file.
Developing
Run the following:
yarn installyarn build
Testing
Assuming you've run all the steps in the "Development" section, then run the following:
cd e2eyarn installdocker-compose up -dcd ..yarn test
Publishing
We use np
to cut and publish new releases. Run the following:
yarn run pub