-
Notifications
You must be signed in to change notification settings - Fork 280
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
74 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
declare global { | ||
/** | ||
* The interface users can extend using interface merging: | ||
* | ||
* ```ts | ||
* declare global { | ||
* interface KyselyTypeConfig { | ||
* bigIntType: number | ||
* } | ||
* } | ||
* ``` | ||
* | ||
* See {@link DefaultKyselyTypeConfig} for configs that can be | ||
* overridden. | ||
*/ | ||
interface KyselyTypeConfig {} | ||
} | ||
|
||
interface DefaultKyselyTypeConfig { | ||
dateTimeType: Date | string | ||
floatType: number | string | ||
bigIntType: bigint | number | string | ||
|
||
/** | ||
* This type can be used to specify the `sum` function's output type. | ||
*/ | ||
sumType: number | string | bigint | ||
|
||
/** | ||
* This type can be used to specify the `avg` function's output type. | ||
* By default the {@link floatType} is used. | ||
*/ | ||
avgType: never | ||
|
||
/** | ||
* This type can be used to specify the `count` and `countAll` functions' output type. | ||
* By default the {@link bigIntType} is used. | ||
*/ | ||
countType: never | ||
} | ||
|
||
export type GetConfig<K extends keyof DefaultKyselyTypeConfig> = | ||
K extends keyof KyselyTypeConfig | ||
? KyselyTypeConfig[K] | ||
: DefaultKyselyTypeConfig[K] | ||
|
||
export type GetConfigFallback< | ||
K extends keyof DefaultKyselyTypeConfig, | ||
F extends keyof DefaultKyselyTypeConfig | ||
> = GetConfig<K> extends never ? GetConfig<F> : GetConfig<K> |