Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Entity Constructor's components option optional #3027

Conversation

muhajirdev
Copy link
Contributor

@muhajirdev muhajirdev commented Apr 25, 2024

Had a conversation here https://discord.com/channels/1195771303215513671/1232877562804305920

From example in https://excaliburjs.com/docs/entities:
const entityWithName = new ex.Entity({name: 'Named Entity'});


No overload matches this call.
  Overload 1 of 2, '(options: EntityOptions<any>): Entity<any>', gave the following error.
    Argument of type '{ name: string; }' is not assignable to parameter of type 'EntityOptions<any>'.
      Property 'components' is missing in type '{ name: string; }' but required in type 'EntityOptions<any>'.
  Overload 2 of 2, '(components?: any[] | undefined, name?: string | undefined): Entity<any>', gave the following error.
    Object literal may only specify known properties, and 'name' does not exist in type 'any[]'.ts(2769)
Entity.d.ts(58, 5): 'components' is declared here.


It seems that components is not optional here

export interface EntityOptions<TComponents extends Component> {
    name?: string;
    components: TComponents[];
}

Changes:

  • Make components options optional here.

@eonarheim eonarheim merged commit 43af8cb into excaliburjs:main Apr 25, 2024
3 of 4 checks passed
@eonarheim
Copy link
Member

@muhajirdev Thanks again!

@muhajirdev muhajirdev deleted the fix/entity-constructor-components-optional branch April 25, 2024 02:47
@muhajirdev
Copy link
Contributor Author

Awesome, thanks for the quick response 🔥

eonarheim pushed a commit that referenced this pull request May 5, 2024
Had a conversation here https://discord.com/channels/1195771303215513671/1232877562804305920

```
From example in https://excaliburjs.com/docs/entities:
const entityWithName = new ex.Entity({name: 'Named Entity'});


No overload matches this call.
  Overload 1 of 2, '(options: EntityOptions<any>): Entity<any>', gave the following error.
    Argument of type '{ name: string; }' is not assignable to parameter of type 'EntityOptions<any>'.
      Property 'components' is missing in type '{ name: string; }' but required in type 'EntityOptions<any>'.
  Overload 2 of 2, '(components?: any[] | undefined, name?: string | undefined): Entity<any>', gave the following error.
    Object literal may only specify known properties, and 'name' does not exist in type 'any[]'.ts(2769)
Entity.d.ts(58, 5): 'components' is declared here.


It seems that components is not optional here

export interface EntityOptions<TComponents extends Component> {
    name?: string;
    components: TComponents[];
}

```

Changes:
- Make `components` options optional here.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants