Skip to content

Commit 9723e1c

Browse files
committed
Mark Props/SecuredProps as optional
They will only be declared in compiled code now.
1 parent e4902e5 commit 9723e1c

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

src/common/resource.dto.ts

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ export abstract class Resource extends DataObject {
7777
type Thunk<T> = T | (() => T);
7878

7979
export type ResourceShape<T> = AbstractClassType<T> & {
80-
Props: string[];
81-
SecuredProps: string[];
80+
Props?: string[];
81+
SecuredProps?: string[];
8282
// An optional list of props that exist on the BaseNode in the DB.
8383
// Default should probably be considered the props on Resource class.
8484
BaseNodeProps?: string[];
@@ -195,12 +195,24 @@ export class EnhancedResource<T extends ResourceShape<any>> {
195195

196196
@Once()
197197
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);
199205
}
200206

201207
@Once()
202208
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);
204216
}
205217

206218
@Once()

0 commit comments

Comments
 (0)