-
Notifications
You must be signed in to change notification settings - Fork 138
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
(7.x.x) - Evaluation of types.d according to jsDoc #189
Comments
We are looking for a typescript user for this task |
Is the idea here that you want https://github.com/felixmariotto/three-mesh-ui/blob/e5cee5b14a2d6bed9c62b21ad51c1309c520b6e0/src/types.d.ts evaluated to see if the auto generated types are accurate? And do we want all types to be evaluated or just font related ones this time around? |
Hey @JoeCoppola-HIA , I've manually written that part of the types definition, and commented out as I wasn't sure it would be better than the simpler placed below export declare namespace FontLibrary {
export function addFontFamily(fontFamilyName:string);
export function getFontFamily(fontFamilyName:string);
export function load(fontFamily:any, ...args:any[]):Promise<unknown>;
export function setMissingCharacterHandler(fontVariant:any, character:string):string|null;
export function missingCharacter(handler:(fontVariant:any, character:string) => string|null);
} Manually writing or updating it, isn't very exciting at all. And some names are gonna be refactored very soon. It would be good to keep types definition as accurate as possible, even if it is not fully complete / useable. The evaluation that could be done here, is : from the current output of
Having automation and guidelines could help to prevent types definition to be completely outdated, without the need to manually edit those. |
At the moment, that evaluation should be done on a branch from 7.x.x-feature/font-class-font-library |
Thank you for the explanation. As we are heavily invested into the typescript side and are using several of the more advanced APIs, I think we can help evaluate the current state of the output from |
Generated Output:Attached is the image of generated type files from running The generated
Current Evaluation:This is a useful start, but if I understand the output correctly at the moment, as well as the errors being spit out by VS Code here, it isn't usable in its current state just yet. A majority of the problems seem to stem from converting jsdoc param comments into types in the Take the following example:
It defines
And TS compilers complain that InlineCharacter can not be resolved here. Potential Solution:Simply adding the import I plan to read a little more up on how |
Another potential concern that I haven't been able to evaluate just yet is how the Right now any class that uses
|
I've just discover /**
* @param { import('express').Request } req
**/ Just wanted to let you know |
Hey @swingingtom, I noticed this directive as well, and was reading microsoft/TypeScript#22160 on the general thoughts of this. This seems like it will solve the issue as well, but seems like it could result in a lot of repetitive comments in some source files. I am fine with either this solution or the one I suggested. Just let me know what you think. If you are ok with this, I would like to clean up these errors I found and PR the fixes back to your branch. Thanks. |
It might be a bit inconsistent, but perhaps we should use that only when type is not directly referenced in the file? What do you think? And what about simply merging all definitions in one single file such as it is currently done https://github.com/felixmariotto/three-mesh-ui/blob/master/src/types.d.ts ? |
If you think it would reduce the current types gap, go for it. Thanks |
I'm not sure I'm a big fan of a single types file personally, mainly because the compiler does a nice job of exporting the type files in the original file structure of the source which could better inform implementers of Three Mesh UI original design intent. I tried outputting the types to a single file just now and it still has the same import issues. This occurs because while it is still in the same file, the modules declared keep their imports local to the module, and not to the global file. microsoft/TypeScript#22160 (comment) I am going to take a first stab at updating this to resolve the errors, which should then allow me to further evaluate the types. One thing I plan on adding that may be up for discussion is adding some additional declarations in |
#188 Refactor introduced a
tsconfig.json
that scan js files to automatically build types.This could be a nice way to stop being late on typescript on each update but an evaluation of constraints, do and don'ts should be performed prior.
The text was updated successfully, but these errors were encountered: