-
Notifications
You must be signed in to change notification settings - Fork 115
Conversation
if (!component) { | ||
return; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No point going through queries if the component does not exist.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice catch yep
@@ -52,7 +52,7 @@ export class Entity { | |||
*/ | |||
getMutableComponent<C extends Component<any>>( | |||
Component: ComponentConstructor<C> | |||
): C; | |||
): C | undefined; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think this will be annoying? Should these functions throw an error (in development mode?) instead if the component does not exist?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's valuable to return undefined
so you could check in your code if it exist or not instead of catching an error
Thanks! |
Some small changes to help with TypeScript development
undefined
andReadonly
componentsgetRemovedComponent
as wellgetComponent
could already return a readonly removed component so this should too