Skip to content

Commit 5ddfa61

Browse files
authored
fix: update to TypeScript 4.8 (#1453)
* fix: update to TypeScript 4.8 * style: fix lint
1 parent 9baa584 commit 5ddfa61

25 files changed

+83
-80
lines changed

Diff for: package-lock.json

+13-13
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@
137137
"source-map-support": "0.5.21",
138138
"sqlite3": "5.0.11",
139139
"ts-node": "10.9.1",
140-
"typescript": "4.7.4",
140+
"typescript": "4.8.4",
141141
"uuid-validate": "0.0.3"
142142
},
143143
"peerDependencies": {

Diff for: src/associations/belongs-to-many/belongs-to-many-association.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ import { ModelType } from '../../model/model/model';
1010
import { ThroughOptions } from '../through/through-options';
1111

1212
export class BelongsToManyAssociation<
13-
TCreationAttributes,
14-
TModelAttributes,
15-
TCreationAttributesThrough,
16-
TModelAttributesThrough
13+
TCreationAttributes extends {},
14+
TModelAttributes extends {},
15+
TCreationAttributesThrough extends {},
16+
TModelAttributesThrough extends {}
1717
> extends BaseAssociation<TCreationAttributes, TModelAttributes> {
1818
constructor(
1919
associatedClassGetter: ModelClassGetter<TCreationAttributes, TModelAttributes>,

Diff for: src/associations/belongs-to-many/belongs-to-many-options.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@ import { BelongsToManyOptions as OriginBelongsToManyOptions } from 'sequelize';
22
import { ModelClassGetter } from '../../model/shared/model-class-getter';
33
import { ThroughOptions } from '../through/through-options';
44

5-
export type BelongsToManyOptions<TCreationAttributesThrough, TModelAttributesThrough> = {
5+
export type BelongsToManyOptions<
6+
TCreationAttributesThrough extends {},
7+
TModelAttributesThrough extends {}
8+
> = {
69
[K in keyof OriginBelongsToManyOptions]: K extends 'through'
710
?
811
| ModelClassGetter<TCreationAttributesThrough, TModelAttributesThrough>

Diff for: src/associations/belongs-to-many/belongs-to-many.ts

+12-12
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,30 @@ import { ModelClassGetter } from '../../model/shared/model-class-getter';
44
import { addAssociation } from '../shared/association-service';
55

66
export function BelongsToMany<
7-
TCreationAttributes,
8-
TModelAttributes,
9-
TCreationAttributesThrough,
10-
TModelAttributesThrough
7+
TCreationAttributes extends {},
8+
TModelAttributes extends {},
9+
TCreationAttributesThrough extends {},
10+
TModelAttributesThrough extends {}
1111
>(
1212
associatedClassGetter: ModelClassGetter<TCreationAttributes, TModelAttributes>,
1313
through: ModelClassGetter<TCreationAttributesThrough, TModelAttributesThrough> | string,
1414
foreignKey?: string,
1515
otherKey?: string
1616
): Function;
1717
export function BelongsToMany<
18-
TCreationAttributes,
19-
TModelAttributes,
20-
TCreationAttributesThrough,
21-
TModelAttributesThrough
18+
TCreationAttributes extends {},
19+
TModelAttributes extends {},
20+
TCreationAttributesThrough extends {},
21+
TModelAttributesThrough extends {}
2222
>(
2323
associatedClassGetter: ModelClassGetter<TCreationAttributes, TModelAttributes>,
2424
options: BelongsToManyOptions<TCreationAttributesThrough, TModelAttributesThrough>
2525
): Function;
2626
export function BelongsToMany<
27-
TCreationAttributes,
28-
TModelAttributes,
29-
TCreationAttributesThrough,
30-
TModelAttributesThrough
27+
TCreationAttributes extends {},
28+
TModelAttributes extends {},
29+
TCreationAttributesThrough extends {},
30+
TModelAttributesThrough extends {}
3131
>(
3232
associatedClassGetter: ModelClassGetter<TCreationAttributes, TModelAttributes>,
3333
throughOrOptions:

Diff for: src/associations/belongs-to/belongs-to-association.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ import { Association } from '../shared/association';
77
import { ModelType } from '../../model/model/model';
88
import { UnionAssociationOptions } from '../shared/union-association-options';
99

10-
export class BelongsToAssociation<TCreationAttributes, TModelAttributes> extends BaseAssociation<
11-
TCreationAttributes,
12-
TModelAttributes
13-
> {
10+
export class BelongsToAssociation<
11+
TCreationAttributes extends {},
12+
TModelAttributes extends {}
13+
> extends BaseAssociation<TCreationAttributes, TModelAttributes> {
1414
constructor(
1515
associatedClassGetter: ModelClassGetter<TCreationAttributes, TModelAttributes>,
1616
protected options: BelongsToOptions

Diff for: src/associations/belongs-to/belongs-to.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@ import { BelongsToAssociation } from './belongs-to-association';
44
import { ModelClassGetter } from '../../model/shared/model-class-getter';
55
import { addAssociation, getPreparedAssociationOptions } from '../shared/association-service';
66

7-
export function BelongsTo<TCreationAttributes, TModelAttributes>(
7+
export function BelongsTo<TCreationAttributes extends {}, TModelAttributes extends {}>(
88
associatedClassGetter: ModelClassGetter<TCreationAttributes, TModelAttributes>,
99
foreignKey?: string
1010
): Function;
1111

12-
export function BelongsTo<TCreationAttributes, TModelAttributes>(
12+
export function BelongsTo<TCreationAttributes extends {}, TModelAttributes extends {}>(
1313
associatedClassGetter: ModelClassGetter<TCreationAttributes, TModelAttributes>,
1414
options?: BelongsToOptions
1515
): Function;
1616

17-
export function BelongsTo<TCreationAttributes, TModelAttributes>(
17+
export function BelongsTo<TCreationAttributes extends {}, TModelAttributes extends {}>(
1818
associatedClassGetter: ModelClassGetter<TCreationAttributes, TModelAttributes>,
1919
optionsOrForeignKey?: string | BelongsToOptions
2020
): Function {

Diff for: src/associations/foreign-key/foreign-key-meta.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { ModelClassGetter } from '../../model/shared/model-class-getter';
22

3-
export interface ForeignKeyMeta<TCreationAttributes, TModelAttributes> {
3+
export interface ForeignKeyMeta<TCreationAttributes extends {}, TModelAttributes extends {}> {
44
relatedClassGetter: ModelClassGetter<TCreationAttributes, TModelAttributes>;
55
foreignKey: string;
66
}

Diff for: src/associations/foreign-key/foreign-key-service.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ import { ModelType } from '../../model/model/model';
77
const FOREIGN_KEYS_KEY = 'sequelize:foreignKeys';
88

99
export function getForeignKeyOptions<
10-
TCreationAttributes,
11-
TModelAttributes,
12-
TCreationAttributesThrough,
13-
TModelAttributesThrough
10+
TCreationAttributes extends {},
11+
TModelAttributes extends {},
12+
TCreationAttributesThrough extends {},
13+
TModelAttributesThrough extends {}
1414
>(
1515
relatedClass: ModelType<TCreationAttributes, TModelAttributes>,
1616
classWithForeignKey?: ModelType<TCreationAttributesThrough, TModelAttributesThrough>,
@@ -48,7 +48,7 @@ export function getForeignKeyOptions<
4848
/**
4949
* Adds foreign key meta data for specified class
5050
*/
51-
export function addForeignKey<TCreationAttributes, TModelAttributes>(
51+
export function addForeignKey<TCreationAttributes extends {}, TModelAttributes extends {}>(
5252
target: any,
5353
relatedClassGetter: ModelClassGetter<TCreationAttributes, TModelAttributes>,
5454
foreignKey: string
@@ -67,7 +67,7 @@ export function addForeignKey<TCreationAttributes, TModelAttributes>(
6767
/**
6868
* Returns foreign key meta data from specified class
6969
*/
70-
export function getForeignKeys<TCreationAttributes, TModelAttributes>(
70+
export function getForeignKeys<TCreationAttributes extends {}, TModelAttributes extends {}>(
7171
target: any
7272
): ForeignKeyMeta<TCreationAttributes, TModelAttributes>[] | undefined {
7373
const foreignKeys = Reflect.getMetadata(FOREIGN_KEYS_KEY, target);

Diff for: src/associations/foreign-key/foreign-key.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { addForeignKey } from './foreign-key-service';
22
import { ModelClassGetter } from '../../model/shared/model-class-getter';
33

4-
export function ForeignKey<TCreationAttributes, TModelAttributes>(
4+
export function ForeignKey<TCreationAttributes extends {}, TModelAttributes extends {}>(
55
relatedClassGetter: ModelClassGetter<TCreationAttributes, TModelAttributes>
66
): Function {
77
return (target: any, propertyName: string) => {

Diff for: src/associations/has/has-association.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ import { Association } from '../shared/association';
77
import { UnionAssociationOptions } from '../shared/union-association-options';
88
import { ModelType } from '../../model/model/model';
99

10-
export class HasAssociation<TCreationAttributes, TModelAttributes> extends BaseAssociation<
11-
TCreationAttributes,
12-
TModelAttributes
13-
> {
10+
export class HasAssociation<
11+
TCreationAttributes extends {},
12+
TModelAttributes extends {}
13+
> extends BaseAssociation<TCreationAttributes, TModelAttributes> {
1414
constructor(
1515
associatedClassGetter: ModelClassGetter<TCreationAttributes, TModelAttributes>,
1616
protected options: HasManyOptions | HasOneOptions,

Diff for: src/associations/has/has-many.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,17 @@ import { ModelClassGetter } from '../../model/shared/model-class-getter';
55
import { addAssociation, getPreparedAssociationOptions } from '../shared/association-service';
66
import { Association } from '../shared/association';
77

8-
export function HasMany<TCreationAttributes, TModelAttributes>(
8+
export function HasMany<TCreationAttributes extends {}, TModelAttributes extends {}>(
99
associatedClassGetter: ModelClassGetter<TCreationAttributes, TModelAttributes>,
1010
foreignKey?: string
1111
): Function;
1212

13-
export function HasMany<TCreationAttributes, TModelAttributes>(
13+
export function HasMany<TCreationAttributes extends {}, TModelAttributes extends {}>(
1414
associatedClassGetter: ModelClassGetter<TCreationAttributes, TModelAttributes>,
1515
options?: HasManyOptions
1616
): Function;
1717

18-
export function HasMany<TCreationAttributes, TModelAttributes>(
18+
export function HasMany<TCreationAttributes extends {}, TModelAttributes extends {}>(
1919
associatedClassGetter: ModelClassGetter<TCreationAttributes, TModelAttributes>,
2020
optionsOrForeignKey?: string | HasManyOptions
2121
): Function {

Diff for: src/associations/has/has-one.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,17 @@ import { ModelClassGetter } from '../../model/shared/model-class-getter';
55
import { addAssociation, getPreparedAssociationOptions } from '../shared/association-service';
66
import { Association } from '../shared/association';
77

8-
export function HasOne<TCreationAttributes, TModelAttributes>(
8+
export function HasOne<TCreationAttributes extends {}, TModelAttributes extends {}>(
99
associatedClassGetter: ModelClassGetter<TCreationAttributes, TModelAttributes>,
1010
foreignKey?: string
1111
): Function;
1212

13-
export function HasOne<TCreationAttributes, TModelAttributes>(
13+
export function HasOne<TCreationAttributes extends {}, TModelAttributes extends {}>(
1414
associatedClassGetter: ModelClassGetter<TCreationAttributes, TModelAttributes>,
1515
options?: HasOneOptions
1616
): Function;
1717

18-
export function HasOne<TCreationAttributes, TModelAttributes>(
18+
export function HasOne<TCreationAttributes extends {}, TModelAttributes extends {}>(
1919
associatedClassGetter: ModelClassGetter<TCreationAttributes, TModelAttributes>,
2020
optionsOrForeignKey?: string | HasOneOptions
2121
): Function {

Diff for: src/associations/shared/association-service.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export function getPreparedAssociationOptions(
2828
/**
2929
* Stores association meta data for specified class
3030
*/
31-
export function addAssociation<TCreationAttributes, TModelAttributes>(
31+
export function addAssociation<TCreationAttributes extends {}, TModelAttributes extends {}>(
3232
target: any,
3333
association: BaseAssociation<TCreationAttributes, TModelAttributes>
3434
): void {
@@ -44,7 +44,7 @@ export function addAssociation<TCreationAttributes, TModelAttributes>(
4444
/**
4545
* Returns association meta data from specified class
4646
*/
47-
export function getAssociations<TCreationAttributes, TModelAttributes>(
47+
export function getAssociations<TCreationAttributes extends {}, TModelAttributes extends {}>(
4848
target: any
4949
): BaseAssociation<TCreationAttributes, TModelAttributes>[] | undefined {
5050
const associations = Reflect.getMetadata(ASSOCIATIONS_KEY, target);
@@ -53,17 +53,17 @@ export function getAssociations<TCreationAttributes, TModelAttributes>(
5353
}
5454
}
5555

56-
export function setAssociations<TCreationAttributes, TModelAttributes>(
56+
export function setAssociations<TCreationAttributes extends {}, TModelAttributes extends {}>(
5757
target: any,
5858
associations: BaseAssociation<TCreationAttributes, TModelAttributes>[]
5959
): void {
6060
Reflect.defineMetadata(ASSOCIATIONS_KEY, associations, target);
6161
}
6262

63-
export function getAssociationsByRelation<TCreationAttributes, TModelAttributes>(
64-
target: any,
65-
relatedClass: any
66-
): BaseAssociation<TCreationAttributes, TModelAttributes>[] {
63+
export function getAssociationsByRelation<
64+
TCreationAttributes extends {},
65+
TModelAttributes extends {}
66+
>(target: any, relatedClass: any): BaseAssociation<TCreationAttributes, TModelAttributes>[] {
6767
const associations = getAssociations<TCreationAttributes, TModelAttributes>(target);
6868
return (associations || []).filter((association) => {
6969
const _relatedClass = association.getAssociatedClass();

Diff for: src/associations/shared/base-association.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { ModelClassGetter } from '../../model/shared/model-class-getter';
44
import { ModelType } from '../../model/model/model';
55
import { Sequelize } from '../../sequelize/sequelize/sequelize';
66

7-
export abstract class BaseAssociation<TCreationAttributes, TModelAttributes> {
7+
export abstract class BaseAssociation<TCreationAttributes extends {}, TModelAttributes extends {}> {
88
constructor(
99
private associatedClassGetter: ModelClassGetter<TCreationAttributes, TModelAttributes>,
1010
protected options: UnionAssociationOptions

Diff for: src/associations/through/through-options.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { ThroughOptions as OriginThroughOptions } from 'sequelize';
22
import { ModelClassGetter } from '../../model/shared/model-class-getter';
33

4-
export type ThroughOptions<TCreationAttributes, TModelAttributes> = {
4+
export type ThroughOptions<TCreationAttributes extends {}, TModelAttributes extends {}> = {
55
[K in keyof OriginThroughOptions]: K extends 'model'
66
? ModelClassGetter<TCreationAttributes, TModelAttributes> | string
77
: OriginThroughOptions[K];

Diff for: src/model/model/model.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import { AssociationActionOptions } from './association/association-action-optio
1616
import { AssociationCreateOptions } from './association/association-create-options';
1717
import { Repository } from '../../sequelize/repository/repository';
1818

19-
export type ModelType<TCreationAttributes, TModelAttributes> = new (
19+
export type ModelType<TCreationAttributes extends {}, TModelAttributes extends {}> = new (
2020
values?: TCreationAttributes,
2121
options?: any
2222
) => Model<TModelAttributes, TCreationAttributes>;

Diff for: src/model/shared/model-class-getter.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { ModelType } from '../model/model';
22

3-
export type ModelClassGetter<TCreationAttributes, TModelAttributes> = (
3+
export type ModelClassGetter<TCreationAttributes extends {}, TModelAttributes extends {}> = (
44
returns?: void
55
) => ModelType<TCreationAttributes, TModelAttributes>;

Diff for: src/scopes/default-scope.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ export function DefaultScope(scopeGetter: DefaultScopeGetter): Function;
1111
* Decorator for defining default Model scope
1212
* @deprecated
1313
*/
14-
export function DefaultScope<TCreationAttributes, TModelAttributes>(
14+
export function DefaultScope<TCreationAttributes extends {}, TModelAttributes extends {}>(
1515
scope: ScopeFindOptions<TCreationAttributes, TModelAttributes>
1616
): Function;
1717

1818
/**
1919
* Decorator for defining default Model scope
2020
*/
21-
export function DefaultScope<TCreationAttributes, TModelAttributes>(
21+
export function DefaultScope<TCreationAttributes extends {}, TModelAttributes extends {}>(
2222
scopeOrSsopeGetter: ScopeFindOptions<TCreationAttributes, TModelAttributes> | DefaultScopeGetter
2323
): Function {
2424
return (target: any) => {

Diff for: src/scopes/scope-find-options.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import { Association, FindOptions, IncludeOptions } from 'sequelize';
22
import { ModelClassGetter } from '../model/shared/model-class-getter';
33

4-
export type ScopeIncludeOptions<TCreationAttributes, TModelAttributes> = {
4+
export type ScopeIncludeOptions<TCreationAttributes extends {}, TModelAttributes extends {}> = {
55
[K in keyof IncludeOptions]: K extends 'model'
66
? ModelClassGetter<TCreationAttributes, TModelAttributes>
77
: K extends 'include'
88
? ScopeIncludeOptions<TCreationAttributes, TModelAttributes>
99
: IncludeOptions[K];
1010
};
1111

12-
export type ScopeFindOptions<TCreationAttributes, TModelAttributes> = {
12+
export type ScopeFindOptions<TCreationAttributes extends {}, TModelAttributes extends {}> = {
1313
[K in keyof FindOptions]: K extends 'include'
1414
?
1515
| ModelClassGetter<TCreationAttributes, TModelAttributes>[]

0 commit comments

Comments
 (0)