-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: typescript support for migration files #8
Comments
The TS script would need to be processed by Esbuild or TSC so they could be loaded. I'm not sure I understand what you mean that tsconfig complains when loading "js" files. Can you specify allowJS? Your second point, having types. Do you mean types for the Migrate class or for your code/ A bit more detail on your suggestions will help me understand. |
This is where i ended up. I have a step in my build process that does an esbuild/bundling of each each individual migration script in my migrations folder. The output of tsc wasn't enough in my case as my project is using a nx monorepo and was leveraging local shared modules that aren't published anywhere. Maybe I didn't think this one through enough. The above felt a little heavyweight and I was hoping there might be a simple way to push some of this into the library to make writing migrations as typescript files easier.
My bad, I found the 'allowJS' setting after writing this. I now have a nice solution for unit testing migrations with a local dynamodb emulator and jest.
I mean types in the migration scripts. This has made discovering methods/intellisense on the async up(db: Table, migrate: Migrate, params: { dry: boolean }) {} vs async up(db, migrate, params) {} So at this point I now have a solution for writing my migration scripts in typescript with the up/down functions full typed as above. I'm not blocked. My remaining ask is a 'hand wavy' can we make it easier for users of this library (and the associated onetable-cli) to write migration scripts in Typescript. Maybe the recent PR to add typescript support to Node might make this easier in the future: nodejs/node#53725 |
Great that allowJs helped. Yes, stripping types by node would be REALLY great. |
It would be great to be able to write and test migration files as typescript files.
i.e
My current tsconfig/jest setup complains bitterly when the
Migrate
class attempts to load up some js files. I can probably bash my way through to a solution but it would be great not to have to.Secondly having the types in the up / down function definitions makes writing the actual migration logic easier. I know i can point the migrate cli / migrate class at the js files post typescript compilation but this still leads to the issue above when trying to test.
The text was updated successfully, but these errors were encountered: