-
Notifications
You must be signed in to change notification settings - Fork 222
wip: porting to typescript #23
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
Conversation
Hey @endel, I do agree that strong typing would be great for javascript, however I'm not currently a typescript user. If TypeScript were supported by browsers natively then I would jump onboard, however I really like not requiring a build step during development, and on the same note not forcing others to require one also. |
Thanks for the feedback @gordonnl, I understand additional compilation steps can be annoying sometimes. The fewer barriers the best. I've "completed" the TypeScript port. Here are a few compilation errors that may actually result in runtime errors:
Here are some notes regarding the typings and changes I've made (which can be improved a lot! I've just made it compile atm)
|
I've also changed the examples to continue to work, using the compiled JavaScript files generated by |
Thanks for this mate, will go through it today |
Ok I've had some time, thanks again for this - it's a great learning reference for me. TL;DR I think it's too early, once OGL hits beta I'd be willing. Or, if there was browser support it'd be no issue. For the errors, the first one was a helpful find, thanks - I've added
For the Math Function classes, they can work with number arrays or typed arrays, they don't require any of the extended class functionality, so I'd remove the cyclic dependencies as you're not forced to pass in specific Math instances. So, I think that there are pros and cons, one of the main goals for this library was to keep it as simple as possible, enhancing its use as a WebGL learning resource, and as a beginner-friendly code-base. I obviously see the benefit that types bring to an IDE, however the required build step is a process I'm very much looking to avoid. The library still has some missing holes, largely multi render targets, depth textures, cube-maps, shadow maps, GLTF, along with others. As I don't use TypeScript, this would make it more difficult for the author, slowing progress and adding complication. Once the library is in a happy state and I don't have glaring changes to implement, I'm willing to revisit. |
Thanks for the clarification, agreed, I totally understand your concerns :) |
Or this #29 |
Hey @gordonnl,
Thanks a lot for your efforts on this library, it looks really clean. I wonder if you have strong opinions against using TypeScript?
I've started porting it to TypeScript today, as the codebase is quite large I'm going to open this PR as a draft for now, if you like it I can continue the migration. (there are still 498 compilation errors due to lack of type annotations. )
TypeScript helps a lot avoiding silly mistakes (e.g. calling nonexistent methods, or passing wrong type of arguments), provides code completion for end-users, and more good stuff.
Let me know what you think! Cheers