marklovers / kaplay

🦖 A JavaScript game library
https://kaplayjs.com
MIT License
232 stars 15 forks source link

feat: `makeComponent` helper #140

Open lajbel opened 3 weeks ago

lajbel commented 3 weeks ago

A makeComponent helper will help to create strong typed components.

Example:

makeComponent("body", (mass) => {
   return {
      jump() {
          this // type: GameObj<AreaComp> & this
          // ...
      }
   }
}, [area]);

Tasks:

niceEli commented 3 weeks ago

consitering that this is a plugin it shouldnt be the most difficult thing, you would just need to ask @neverUsedGithub really tbh

lajbel commented 3 weeks ago

is not the same that the plugin, it will incorporate a special type context. You can't simply call the component to assert the type

niceEli commented 3 weeks ago

true