Skip to content

Commit

Permalink
Fix TS typings for component.create(), broken by 4b15771
Browse files Browse the repository at this point in the history
Resolves error TS2425: Class 'Component' defines instance member property 'create', but extended class 'MyComponent' defines it as instance member function.
  • Loading branch information
ericyhwang committed Jun 28, 2024
1 parent 14d5300 commit 74a6dce
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export abstract class Component<T extends object = object> extends Controller<T>
* `init()` could be called from the server and the browser, so do not use any DOM-only methods
* here. Put those in `create()` instead.
*/
init(_model: ChildModel): void {}
init?(_model: ChildModel): void;

/**
* Method called by Derby once a component is loaded and ready in the DOM.
Expand All @@ -110,7 +110,7 @@ export abstract class Component<T extends object = object> extends Controller<T>
*
* This will only be called in the browser.
*/
create?: (() => void) | (() => Promise<void>);
create?(): void;

destroy() {
this.emit('destroy');
Expand Down

0 comments on commit 74a6dce

Please sign in to comment.