Skip to content
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

How to use this package with the official documentation? #21

Open
winston0410 opened this issue May 11, 2022 · 2 comments
Open

How to use this package with the official documentation? #21

winston0410 opened this issue May 11, 2022 · 2 comments

Comments

@winston0410
Copy link

Thank you so much for your effort for writing this package, it is awesome! But it would be even better if it can support the official typing usage for Knex.

This is the official way for defining table types for Knex:

https://knexjs.org/#typescript-support

But right now knex-types would exports an enum of Table, which we will still need to import the whole file to get the type. Can it generate a .d.ts instead, and define everything under module declare module 'knex/types/tables'?

@evert
Copy link

evert commented Sep 13, 2022

Curious how others have solved this!

@bhenderson
Copy link
Contributor

old issue, but you could probably set prefix and suffix options

updateTypes(db, {
  output: 'db.d.ts',
  prefix: `declare module 'knex/types/tables' {`
  suffix: '}'
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants