File tree Expand file tree Collapse file tree 1 file changed +16
-4
lines changed Expand file tree Collapse file tree 1 file changed +16
-4
lines changed Original file line number Diff line number Diff line change @@ -77,8 +77,8 @@ export abstract class Resource extends DataObject {
77
77
type Thunk < T > = T | ( ( ) => T ) ;
78
78
79
79
export type ResourceShape < T > = AbstractClassType < T > & {
80
- Props : string [ ] ;
81
- SecuredProps : string [ ] ;
80
+ Props ? : string [ ] ;
81
+ SecuredProps ? : string [ ] ;
82
82
// An optional list of props that exist on the BaseNode in the DB.
83
83
// Default should probably be considered the props on Resource class.
84
84
BaseNodeProps ?: string [ ] ;
@@ -195,12 +195,24 @@ export class EnhancedResource<T extends ResourceShape<any>> {
195
195
196
196
@Once ( )
197
197
get props ( ) : ReadonlySet < keyof T [ 'prototype' ] & string > {
198
- return new Set < keyof T [ 'prototype' ] & string > ( this . type . Props as any ) ;
198
+ const props = this . type . Props ;
199
+ if ( ! props ) {
200
+ throw new Error (
201
+ `${ this . name } has not been decorated with @RegisterResource` ,
202
+ ) ;
203
+ }
204
+ return new Set < keyof T [ 'prototype' ] & string > ( props ) ;
199
205
}
200
206
201
207
@Once ( )
202
208
get securedProps ( ) : ReadonlySet < SecuredResourceKey < T , false > > {
203
- return new Set < SecuredResourceKey < T , false > > ( this . type . SecuredProps as any ) ;
209
+ const props = this . type . SecuredProps ;
210
+ if ( ! props ) {
211
+ throw new Error (
212
+ `${ this . name } has not been decorated with @RegisterResource` ,
213
+ ) ;
214
+ }
215
+ return new Set < SecuredResourceKey < T , false > > ( props as any ) ;
204
216
}
205
217
206
218
@Once ( )
You can’t perform that action at this time.
0 commit comments