-
Notifications
You must be signed in to change notification settings - Fork 42
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
Improve TypeScript types #112
Conversation
Note that there are additional changes that are worth making (namely adding overloads to |
Hi there, thanks for this! On a high level, I'd like to restrict the JSDoc annotations to standard tags, and the Using I'd be open to more specificity in type checking if we can do it without major changes to the docs generation or the creation of separate type definitions. |
I think it would only be useful for TypeScript users, I don't think VSCode will do anything with the annotations when using vanilla JS.
Okay, so that is a "yes" or a "no" to using |
Another option would be to move the type definitions to DefinitelyTyped (and make a |
I'm not totally against using
The hand-maintenance / generation of types in a I'm all in favor if we can do this while still hitting the requirements above. But if not, then I would have to say that yes, this is a limitation of using a JS library in TypeScript. |
Thanks for your consideration and timely response. At this point I'm leaning toward just making these types improvements in @types/three (which is my impetus for working on this). I'll probably use a patch file to just patch the parts of the definition files that I'm making changes to in order to make sure I'm keeping up with any changes to the declaration file from here. While hand-maintenance of the types may feel brittle, it seems like the only option for the type improvements I'm planning to make. I would love for other users of lil-gui outside of @types/three to benefit from these type changes, let me know if you're ever interested in including these changes here instead of just in @types/three. |
My only other thought is:
If you're planning to just be a JS library, it seems worth considering not shipping TypeScript type definitions and let that be handled by the TypeScript community on DefinitelyTyped. |
All good! Yes, I'm curious about this idea of "patching" the type definitions that can't be described easily in JSDoc. Could you tell me a bit more about what that looks like? Thanks! |
Yeah, let me play around with that a little bit and I'll create a draft PR showing what that could look like. |
There are some short-comings in the types as they currently exist, namely:
GUI.add
, there is no type-checking to make sure thatproperty
is a key of theobject
.GUI.add
with an array or object of options for the third argument, there is no type-checking to make sure the options are assignable to the property's value.Controller.onChange
and also therefore the parameter for the callback that is passed toController.onChange
is not inferred, sinceonChange
accepts any function.I wanted to go and create a draft PR to get some initial feedback since I believe this is treading new territory. Most of the existing JSDoc comments are fairly standardized, these would be the first JSDoc comments that are really targeted toward making the type definitions better. It seems like both linting and API creation don't like this new direction.
Is this something you're open to? Or is there a alternative, preferred way to improving the type definitions?