Closed karlhorky closed 3 years ago
Hey :)
You can use the -r/--require
hook to bring in ts-node/register
& that's it. All the built-in drivers require
the migration files already, so that'd invoke any/all require hooks out of the box.
$ ley -r ts-node/register <cmd>
You may need to add a separate ts-node
config block to your root tsconfig.json
in order to apply ts-node
-specific overrides. For example, you're probably outputting ESM targets but you'll need to change this to commonjs
for node/ley to consume it correctly. You can check out an example override from uvu
examples
Also, in case you didn't know, you can use jsdoc type hints to get most of the way there:
/** @param {import('pg').Client} DB */
exports.up = async function (DB) {
await DB.query(...)
}
Hope that helps!
Nice, that's great - thanks! Didn't know about the require
option!
I've opened a PR to document both TS and JSDoc in the readme in #14
Hey @lukeed 👋
I wanted to reach out and ask for your opinion on supporting TypeScript migration files. Do you have an opinion here?
Sometimes having the extra type information in the files can be useful to catch errors...