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

Add rudimentary Typescript typings #116

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

sxxov
Copy link

@sxxov sxxov commented Feb 2, 2024

Hello! Thank you for the project.

Fixes #52

Overview

I noticed discussion over at #52 about typings support, & personally I would benefit a lot from its ease-of-use. So, I went ahead & implemented it into the build process, (& taking note of the discussion thus) without migrating the entire project over to the Typescript language. This was done with some explicit JSDoc types over annonymous functions that TS didn't like, as well as some general improvements such as copying over the in-code explanations out for consumers to read inline.

Notes

  • Not everything has been typed fully, there are a lot of props 😅.
  • There exists a few extraneous type exports that are prefixed with a _ because by default Typescript exports all JSDoc @typedefs. In theory you should be able to assign the types to an unused variable & reference it with typeof, but I couldn't get it to work.
  • I added @types/three, which will now have to be tracked to the three version associated with the package. (Maybe consider making it a peer dependency in the future?)
  • There weren't any stylistic constraints on how JSDoc were to be written, so I kinda just went along with what worked. Please do make any changes there as required.
  • I had to disable the ESLint rule valid-jsdoc, since it didn't like doing typings inline within the constructor. I assume this can be workarounded by doing @prop on the class's JSDoc, but imo it becomes hard to trace when doing new implementations.

@mkkellogg
Copy link
Owner

Thanks for looking into all of this! I'm still not yet sure if I want to incorporate any TypeScript related stuff into the project, but I'll keep this PR open as I continue to consider it. There's a good chance that if I do decide to go the TypeScript route, I'm just going to migrate everything all at once :)

@sxxov
Copy link
Author

sxxov commented Feb 4, 2024

Thanks for considering the PR.

This approach retains all of the JS! At the same time acting as a stop gap between now & when the whole project migrates to TS for existing TS (: any) users (::

The only real TS stuff added is in the form of JSDoc comments, & that only covers the user-facing API, enough so that TS is able to extract declarations.

@simonbethke
Copy link

Hey, I would also really like to see types in this. I am currently trying to implement some kind of vr-holodeck application and I am a bit lost without types and without documentation.

@michi-strichi
Copy link

Any updates on this? Typescript would be a huge benefit for this library in my eyes...

@simonbethke
Copy link

I wish so too.... Still waiting for it

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.

Typescript support
4 participants