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

Fix world:set type #134

Merged
merged 1 commit into from
Sep 28, 2024
Merged

Fix world:set type #134

merged 1 commit into from
Sep 28, 2024

Conversation

vnnh
Copy link
Contributor

@vnnh vnnh commented Sep 27, 2024

With the current type of world:set, the snippet below is valid. The current types use the same generic T for both the component and the data, which lets you pass an optional value into a required field.

const comp = world.component<{ required: boolean }>();
let required: boolean | undefined;
world.set(world.entity(), comp, { required }); // required field is made optional!

@vnnh vnnh force-pushed the patch-1 branch 3 times, most recently from 6977a32 to 33004b9 Compare September 28, 2024 13:22
@vnnh
Copy link
Contributor Author

vnnh commented Sep 28, 2024

Sorry for the weird force-push history, I was getting a little confused.

Copy link
Collaborator

@EncodedVenom EncodedVenom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seeing as how the component should be the source of truth, the NoInfer type checks out. LGTM.

@Ukendio Ukendio merged commit c4deb71 into Ukendio:main Sep 28, 2024
1 check passed
@vnnh vnnh deleted the patch-1 branch September 28, 2024 18:24
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.

3 participants