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

feat: Type new components in a game object #512

Open
lajbel opened this issue Nov 14, 2024 Discussed in #510 · 0 comments
Open

feat: Type new components in a game object #512

lajbel opened this issue Nov 14, 2024 Discussed in #510 · 0 comments
Assignees
Labels
types A TypeScript related bug
Milestone

Comments

@lajbel
Copy link
Collaborator

lajbel commented Nov 14, 2024

Discussed in #510

Originally posted by white16819 November 13, 2024
I'm newer to kaplay and ts.
How to add AreaComp's feature such as onCollide to a existed GameObj like below:
const text = k.add([k.text("Test")])

I try to use function like this below:
text.use(k.area())

Expect the 'text' GameObj's type change into GameObj<TextComp | AreaComp>,
but the 'text' Gameobj's type still be GameObj<TextComp>.

So if I invoke the 'onCollide' function in AreaComp, the ts check will raise the error:
Property 'onCollide' does not exist on type 'GameObj<TextComp>'

Waiting for your suggestions.

@lajbel lajbel moved this to WIP in KAPLAY.js Features Nov 14, 2024
@lajbel lajbel self-assigned this Nov 28, 2024
@lajbel lajbel added the types A TypeScript related bug label Nov 28, 2024
@lajbel lajbel moved this from WIP to TODO in KAPLAY.js Features Jan 20, 2025
@lajbel lajbel changed the title feat: Add other compnent feature to existed GameObj feat: Type new components in a game object Jan 21, 2025
@lajbel lajbel added this to the 3001.1 milestone Jan 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
types A TypeScript related bug
Projects
Status: TODO
Development

No branches or pull requests

1 participant