-
-
Notifications
You must be signed in to change notification settings - Fork 35
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
kyselyType annotation: support types defined in other modules #61
Comments
As an addendum to this, I have a use case where I want to put |
I think an optional prelude is a good idea. I'll try to get to this soon. |
Workaround for now. We did this to have Json types be equivalent between Prisma and Kysely declare global {
export type JsonObject = { [Key in string]?: JsonValue }
/**
* From https://github.com/sindresorhus/type-fest/
* Matches a JSON array.
*/
export interface JsonArray extends Array<JsonValue> {}
/**
* From https://github.com/sindresorhus/type-fest/
* Matches any valid JSON value.
*/
export type JsonValue =
| string
| number
| boolean
| JsonObject
| JsonArray
| null
} Can then be used in schema annotations, as the type is available globally
To keep things clean, also possible to export in a global namespace, declare global {
namespace App {
....
}
} |
Turns out this was possible all along, and I didn't realize it. See this comment: |
I noticed that kyselyType annotation doesn't work with types defined in other ts files.
I can fix this by adding something like
import type { Custom } from 'other-module.js'
in the generated file, but it would be much better to have this feature built-in.The text was updated successfully, but these errors were encountered: