Open JustFly1984 opened 4 years ago
Hi! Unfortunately, there is no such functionality or plugin at this moment :(
@Rudeg Is it possible to request a feature? could be nice to use types from d.ts, and/or from @types/{package}.
Thank you for response, have a great day!
I was just looking into the feasibility of this, and I do think it could be possible, but I think the .js
and .d.ts
files would have to match up pretty well to make it work very well.
For example, I just had a look at a random pair of files in three.js (I'm completely unfamiliar with this code base): PropertyBinding.js and PropertyBinding.d.ts. The .d.ts
file declares PropertyBinding
as a class, whereas the JS uses functions, prototypes, and Object.assign
. It would be quite difficult for a plugin to make the association between what's written in the declaration vs what's written in the JS, unless the plugin were written specifically for this style of code. But then it also wouldn't be very generally useful. There are just so many ways you could write this type of code.
I can see other pairs of files that might work better. For example, AnimationAction.js and AnimationAction.d.ts. Both the JS and the declaration are written using a class and it seems like it would be relatively straight forward for a plugin to grab the types out of the declaration and add them to the JS.
@edsrzf I guess that in case d.ts
applicable to js
, it could be used, otherwise skipped and behavior should be the same as it is now.
PS. types are the code as any other code, so we should expect human errors in d.ts
, especially in cases then d.ts is not generated, but typed manually.
I'm trying to convert to typescript Three.js library. For some case they do not use typescript directly, but using d.ts files along with js files.
The codebase is huge, and manually copying types from d.ts is very time consuming.