Closed kozak-codes closed 2 years ago
Thanks for the PR!
Mostly looks good, but I'm wondering why you switched to named exports?
Thanks! Mainly to give the user some flexibility and allow the user to decide if they would like to use default exports or named exports. When writing with typescript it is very helpful to simply write addSystem
and allow your IDE to import addSystem
from ECS; I find VSCode usually has a hard time finding default exports.
Otherwise with typescript and ESM you would have to do: import { default as ECS } from 'ecs'
at the top of every file. IMO named exports offer a bit more consistency. See this stack overflow answer. I can revert it if you think it is out of scope, but the default export should still work in all other contexts.
I can revert it if you think it is out of scope
No, I don't have that strong of an opinion about it. Though I will say this is one of several reasons why I'm not a huge fan of typescript. That said I know it's quite en vogue at the moment, so that's fine. :)
If you can make a few more tweaks, I'll merge:
0.16.0
rather than 0.15.1
(I know technically anything below 1.0
is considered breaking changes but this feels like more than a patch.)import ECS from '...'
thanks again!
oh, also please make sure all the existing tests still pass with these changes :)
Changed version and updated readme, tests ok!
Closes #33
Adds typescript definitions as js docs
Types work in the following way:
I'm not sure how you want to do versioning or if you want to update the docs in any way.
I also think it would be a good idea to export each function individually as well as a default export. That way you can get nicer type completion. eg
import { addComponentToEntity } from 'ecs'
- I added it to this PR because it enhances the typescript experience, let me know if you want me to remove it.