@@ -16,13 +16,19 @@ import { getInstanceStateFromItem } from './identity-map';
16
16
import { getClassTypeFromInstance } from '@deepkit/core' ;
17
17
18
18
export type FlattenIfArray < T > = T extends Array < any > ? T [ 0 ] : T ;
19
- export type FieldName < T > = keyof T & string ;
19
+ export type FieldName < T > = {
20
+ [ Key in keyof T & string ] : T [ Key ] extends Function ? never : Key ;
21
+ } [ keyof T & string ] ;
20
22
21
- export function getClassSchemaInstancePairs < T extends OrmEntity > ( items : Iterable < T > ) : Map < ReflectionClass < any > , T [ ] > {
23
+ export function getClassSchemaInstancePairs < T extends OrmEntity > (
24
+ items : Iterable < T >
25
+ ) : Map < ReflectionClass < any > , T [ ] > {
22
26
const map = new Map < ReflectionClass < any > , T [ ] > ( ) ;
23
27
24
28
for ( const item of items ) {
25
- const classSchema = ReflectionClass . from ( getClassTypeFromInstance ( item ) ) ;
29
+ const classSchema = ReflectionClass . from (
30
+ getClassTypeFromInstance ( item )
31
+ ) ;
26
32
let items = map . get ( classSchema ) ;
27
33
if ( ! items ) {
28
34
items = [ ] ;
@@ -34,13 +40,18 @@ export function getClassSchemaInstancePairs<T extends OrmEntity>(items: Iterable
34
40
return map ;
35
41
}
36
42
37
-
38
- export function findQuerySatisfied < T extends { [ index : string ] : any } > ( target : T , query : FilterQuery < T > ) : boolean {
43
+ export function findQuerySatisfied < T extends { [ index : string ] : any } > (
44
+ target : T ,
45
+ query : FilterQuery < T >
46
+ ) : boolean {
39
47
//get rid of "Excessive stack depth comparing types 'any' and 'SiftQuery<T[]>'."
40
48
return ( sift as any ) ( query as any , [ target ] as any [ ] ) . length > 0 ;
41
49
}
42
50
43
- export function findQueryList < T extends { [ index : string ] : any } > ( items : T [ ] , query : FilterQuery < T > ) : T [ ] {
51
+ export function findQueryList < T extends { [ index : string ] : any } > (
52
+ items : T [ ] ,
53
+ query : FilterQuery < T >
54
+ ) : T [ ] {
44
55
//get rid of "Excessive stack depth comparing types 'any' and 'SiftQuery<T[]>'."
45
56
return ( sift as any ) ( query as any , items as any [ ] ) ;
46
57
}
@@ -53,5 +64,8 @@ export function buildChangesFromInstance<T>(item: T): Changes<T> {
53
64
const state = getInstanceStateFromItem ( item ) ;
54
65
const lastSnapshot = state . getSnapshot ( ) ;
55
66
const currentSnapshot = state . classState . snapshot ( item ) ;
56
- return state . classState . changeDetector ( lastSnapshot , currentSnapshot , item ) || new Changes ;
67
+ return (
68
+ state . classState . changeDetector ( lastSnapshot , currentSnapshot , item ) ||
69
+ new Changes ( )
70
+ ) ;
57
71
}
0 commit comments