You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the feature
Currently when you select "(TS) Generate interfaces for XML files (id to class mapping)" you get something like this:
which is fine but at the end you still have to use id as string when you want to get the reference to that control via this.byId('id').
What I would like to see is something like this:
Where you get the Ids and types so you can reference to that Id using defined object which improves code quality and limits possibility of typos etc + if you ever change that Id it is very easy to check all the references to it.
The text was updated successfully, but these errors were encountered:
This approach has a lot of disadvantages, so instead of talking about it, I will recommend to check out the blog -> Control type casting section. Try to implement it, it covers your needs and additionally removes the necessity of type casting.
Got it and thank you!
Is it possible that you could explain those disadvantages? I am new to TS and if there is anything to learn i am willing to dig :).
Sure.
The main disadvantage of your approach is that it requires real code to be generated from typescript to javascript.
Types are disappearing in compilation phase, meaning that all the interfaces which my extension is generating will not be there in javascript.
With your approach it is unclear how and where to generate the IDs. In your example ids are generating right above the class itself, which is kind of tricky for extension to generate and it is not error prone for e.g. dynamic fragment loading, when it is impossible to tell from code perspective which fragments are connected to the class where ids are generated. So maybe the best way there could be to generate a separate enumeration file and use it everywhere. However, again, it will be a real boilerplate code which will be compiled to javascript, without real necessity in it.
With my proposal only types are generated, which are not compiled to javascript, and the usage of ids is not changing (it doesn't require any enumerations), so it is more intuitive to use, and, additionally, return type is determined automatically which helps to avoid manual casting.
Describe the feature
Currently when you select "(TS) Generate interfaces for XML files (id to class mapping)" you get something like this:
which is fine but at the end you still have to use id as string when you want to get the reference to that control via this.byId('id').
What I would like to see is something like this:
Where you get the Ids and types so you can reference to that Id using defined object which improves code quality and limits possibility of typos etc + if you ever change that Id it is very easy to check all the references to it.
The text was updated successfully, but these errors were encountered: