Skip to content

Commit

Permalink
feat(types): add typescript 4.8 compatibility (#14990)
Browse files Browse the repository at this point in the history
  • Loading branch information
bnorbi95 committed Sep 17, 2022
1 parent 1da6657 commit 3468378
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Expand Up @@ -36,7 +36,7 @@ jobs:
strategy:
fail-fast: false
matrix:
ts-version: ["4.1", "4.2", "4.3", "4.4", "4.5"]
ts-version: ["4.1", "4.2", "4.3", "4.4", "4.5", "4.6", "4.7", "4.8"]
name: TS Typings (${{ matrix.ts-version }})
runs-on: ubuntu-latest
steps:
Expand Down
4 changes: 2 additions & 2 deletions src/hooks.d.ts
Expand Up @@ -67,8 +67,8 @@ export interface ModelHooks<M extends Model = Model, TAttributes = any> {

export interface SequelizeHooks<
M extends Model<TAttributes, TCreationAttributes> = Model,
TAttributes = any,
TCreationAttributes = TAttributes
TAttributes extends {} = any,
TCreationAttributes extends {} = TAttributes
> extends ModelHooks<M, TAttributes> {
beforeDefine(attributes: ModelAttributes<M, TCreationAttributes>, options: ModelOptions<M>): void;
afterDefine(model: ModelType): void;
Expand Down
4 changes: 2 additions & 2 deletions src/model.d.ts
Expand Up @@ -3260,15 +3260,15 @@ export abstract class Model<TModelAttributes extends {} = any, TCreationAttribut
}

/** @deprecated use ModelStatic */
export type ModelType<TModelAttributes = any, TCreationAttributes = TModelAttributes> = new () => Model<TModelAttributes, TCreationAttributes>;
export type ModelType<TModelAttributes extends {} = any, TCreationAttributes extends {} = TModelAttributes> = new () => Model<TModelAttributes, TCreationAttributes>;

type NonConstructorKeys<T> = ({[P in keyof T]: T[P] extends new () => any ? never : P })[keyof T];
type NonConstructor<T> = Pick<T, NonConstructorKeys<T>>;

/** @deprecated use ModelStatic */
export type ModelCtor<M extends Model> = ModelStatic<M>;

export type ModelDefined<S, T> = ModelStatic<Model<S, T>>;
export type ModelDefined<S extends {}, T extends {}> = ModelStatic<Model<S, T>>;

// remove the existing constructor that tries to return `Model<{},{}>` which would be incompatible with models that have typing defined & replace with proper constructor.
export type ModelStatic<M extends Model> = NonConstructor<typeof Model> & { new(): M };
Expand Down
6 changes: 3 additions & 3 deletions yarn.lock
Expand Up @@ -8322,9 +8322,9 @@ typescript@^4.4.3:
integrity sha512-TCTIul70LyWe6IJWT8QSYeA54WQe8EjQFU4wY52Fasj5UKx88LNYKCgBEHcOMOrFF1rKGbD8v/xcNWVUq9SymA==

typescript@^4.5.4:
version "4.5.4"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.5.4.tgz#a17d3a0263bf5c8723b9c52f43c5084edf13c2e8"
integrity sha512-VgYs2A2QIRuGphtzFV7aQJduJ2gyfTljngLzjpfW9FoYZF6xuw1W0vW9ghCKLfcWrCFxK81CSGRAvS1pn4fIUg==
version "4.8.3"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.8.3.tgz#d59344522c4bc464a65a730ac695007fdb66dd88"
integrity sha512-goMHfm00nWPa8UvR/CPSvykqf6dVV8x/dp0c5mFTMTIu0u0FlGWRioyy7Nn0PGAdHxpJZnuO/ut+PpQ8UiHAig==

uc.micro@^1.0.1, uc.micro@^1.0.5:
version "1.0.6"
Expand Down

0 comments on commit 3468378

Please sign in to comment.