File tree Expand file tree Collapse file tree 3 files changed +12
-9
lines changed Expand file tree Collapse file tree 3 files changed +12
-9
lines changed Original file line number Diff line number Diff line change 1+ import { SystemInSetSchema } from "@mat3ra/esse/dist/js/types" ;
12import { InMemoryEntityConstructor } from "../in_memory" ;
3+ export type SystemInSet = Required < SystemInSetSchema > ;
4+ export type InSet = SystemInSet [ "inSet" ] [ 0 ] ;
25export declare function InMemoryEntityInSetMixin < T extends InMemoryEntityConstructor > ( superclass : T ) : {
36 new ( ...args : any [ ] ) : {
47 inSet : {
Original file line number Diff line number Diff line change @@ -23,8 +23,7 @@ exports.InMemoryEntityInSetMixin = InMemoryEntityInSetMixin;
2323function InMemoryEntitySetMixin ( superclass ) {
2424 return class InMemoryEntitySetMixin extends superclass {
2525 containsEntity ( entity ) {
26- var _a ;
27- return ( _a = entity === null || entity === void 0 ? void 0 : entity . inSet ) === null || _a === void 0 ? void 0 : _a . some ( ( ref ) => ref . _id === this . id ) ;
26+ return entity === null || entity === void 0 ? void 0 : entity . inSet . some ( ( ref ) => ref . _id === this . id ) ;
2827 }
2928 } ;
3029}
Original file line number Diff line number Diff line change @@ -2,15 +2,16 @@ import { SystemInSetSchema } from "@mat3ra/esse/dist/js/types";
22
33import { InMemoryEntityConstructor } from "../in_memory" ;
44
5- type SystemInSet = Required < SystemInSetSchema > ;
5+ export type SystemInSet = Required < SystemInSetSchema > ;
6+ export type InSet = SystemInSet [ "inSet" ] [ 0 ] ;
67
78export function InMemoryEntityInSetMixin < T extends InMemoryEntityConstructor > ( superclass : T ) {
89 return class InMemoryEntityInSetMixin extends superclass implements SystemInSet {
910 get inSet ( ) {
10- return this . prop ( "inSet" , [ ] ) ;
11+ return this . prop < InSet [ ] > ( "inSet" , [ ] ) ;
1112 }
1213
13- set inSet ( inSet : SystemInSet [ "inSet" ] ) {
14+ set inSet ( inSet : InSet [ ] ) {
1415 this . setProp ( "inSet" , inSet ) ;
1516 }
1617
@@ -26,12 +27,12 @@ export function InMemoryEntityInSetMixin<T extends InMemoryEntityConstructor>(su
2627 } ;
2728}
2829
30+ type BaseEntityInSet = InstanceType < ReturnType < typeof InMemoryEntityInSetMixin > > ;
31+
2932export function InMemoryEntitySetMixin < T extends InMemoryEntityConstructor > ( superclass : T ) {
3033 return class InMemoryEntitySetMixin extends superclass {
31- containsEntity < T extends InstanceType < ReturnType < typeof InMemoryEntityInSetMixin > > > (
32- entity ?: T ,
33- ) {
34- return entity ?. inSet ?. some ( ( ref ) => ref . _id === this . id ) ;
34+ containsEntity < T extends BaseEntityInSet > ( entity ?: T ) {
35+ return entity ?. inSet . some ( ( ref ) => ref . _id === this . id ) ;
3536 }
3637 } ;
3738}
You can’t perform that action at this time.
0 commit comments