WhitestormJS / whs.js

:rocket: 🌪 Super-fast 3D framework for Web Applications 🥇 & Games 🎮. Based on Three.js
MIT License
6.15k stars 391 forks source link

export more interface in *.d.ts #327

Closed looading closed 7 years ago

looading commented 7 years ago

Describe your issue here.

Why not export CameraComponentParamsRenderingModuleParams and so on in typescript module? Then i don`t need to redeclare those interface in my project.

Version:
Issue type:

Tested on: ###### Desktop - [ ] Chrome - [ ] Chrome Canary - [ ] Chrome dev-channel - [ ] Firefox - [ ] Opera - [ ] Microsoft IE - [ ] Microsoft Edge ###### Android - [ ] Chrome - [ ] Firefox - [ ] Opera ###### IOS - [ ] Chrome - [ ] Firefox - [ ] Opera
hirako2000 commented 7 years ago

Hey @looading , I don't know I guess. Just tried now to create say a RenderingModule in the whitestorm typscript boilerplate app, it recognises types of the params without me having to redefine the interface of that params:

image

How would exporting specifically the param interface help the compiler and/or IDE? I might be missing something?

Note: I'm not against exporting nested interfaces if that's the recommended practice. I think the reason I did not is that it pollutes scopes. I might have been wrong.

looading commented 7 years ago

Yes, you are right in the case which your image showed. Here is my case:

image

rendering is a@Input property, here i use the type RenderingModuleParams . Is it a recommended practice? If it is recommended, there are no RenderingModuleParams exported, so i should redeclare.

hirako2000 commented 7 years ago

OK I get it (I think).

You are specifically importing a module that does not exist, because as you said, it is not exported. Btw your editor weirdly does not highlight that. See my VSCode editor lints it as an error: image

What I did in my code, is that I simply pass the fields directly. I'm not trying to import, it's inlining values passed to the function, thus no need to import the interface.

Perhaps I should have either:

I don't mind getting whs to export all param interfaces. unless it pollutes the scope too much.

Thoughts?

looading commented 7 years ago

I agree with you. There may be some wrong in my VSCode editor lints. My thoughts is that:

Of course, I will follow your decision.

hirako2000 commented 7 years ago

sorry I didn't have much time lately. I reviewed your proposition, along with your code; I do agree. I've just made a change to export all params interfaces. imo it has to do with typed assignment, which I don't use myself, but your code shows it's actually a common practice.

If you mind code reviewing, it's just adding a single word to all interfaces :)

looading commented 7 years ago

@hirako2000 Thank you very much.