-
Notifications
You must be signed in to change notification settings - Fork 6
Conversation
This achieves a very similar to the current approach of using multiple parameter with dot-notation on specifying object structure. Example of using current params with objects: This seems like doing almost the same, but it will require extra navigation in docs to read actual params - which is not good. Same applies to the code: reading sources with docs where it is relevant is better, instead of navigating to some other file or line in the file to read it. If it is a common passable object around, it worth a class and that is the way currently. |
What does this do to the TypeDoc output (which we'll switch to in the not too distant future)? |
Currently it looks rather anemic, I opened an issue about it: TypeStrong/typedoc#2454 They seem to parse the complete type information here though - so I'm not sure if this is just a template issue or something: So right now it looks just as anemic as callbacks in typedoc: |
@Maksims Yes, I see your points, but you cannot substitute typedefs with object-with-dot-notation parameters. Mathematically speaking, object-with-dot-notation parameters are only a subset of typedefs. You also cannot substitute typedefs with classes for "fake typing" in all cases, for example I reported bugs in the engine that stem from JSON data not being typed. I use old assets and their JSON data lack all kinds of new properties. So instead of something being So personally I find it more efficient to simply click on a link and receive full type information in docs while having no errors in the engine than a multitude of bugs and hours of debugging, because... people can't handle a typedef in BTW I'm not advocating for replacing object-with-dot-notation parameters with typedefs, there are simply instances that object-with-dot-notation parameters cannot cover. The reality in the engine right now is simply... type bugs: And I feel rather dedicated to fix them all, one by one... a bit of trust in the process 🙏 |
Makes sense. This probably worth an information in CONTRIBUTING.md to ensure developers have good guideline where object-with-dot-notation is preferred (e.g. constructor with passing one-off objects) and where typedef is preferred (common objects passed between different methods/classes). |
Good point 👍 I have possibilities in mind that can act as good example when the time is ripe for it 👀 |
Very nice, we can fix callbacks and typedefs via this plugin: npm install typedoc-plugin-missing-exports --save-dev And changing "typedocs": "typedoc --plugin typedoc-plugin-missing-exports", Now it looks like this: (big thank you to @Gerrit0) |
Closing since we have now moved to TypeDoc. |
I wanted to do this for a long time 😅
This allows us to finally declare a typedef like:
And it will be exposed like this in
docs/pc.html
:If you click on it you see the full definiton:
Having a function that accepts a typedef will also lead you to the correct definition, similar to this scenario:
My main motivation is a type issue I found in the engine, basically both
VertexIteratorAccessor
andVertexFormat
define what avertex element
is, but with latest Splat changes we suddenly have one definition differing from the other (there is a newasInt
property).(...there are more cases we can use typedefs for to create a better
playcanvas.d.ts
)I confirm I have read the contributing guidelines and signed the Contributor License Agreement.