Which is the correct syntax to pass constructor arguments? #80
-
I'm reading the components.js document recently, and found some inconsistency in its descriptions. I'm not sure whether they are both accepted, or is because of some legacy syntax. The most noticeable question is: there are two ways of passing arguments to constructor parameters, and I'm confused about which one is the correct one. In this section in Introduction, it says On the other hand, in this section in Workflow Typescript, it says This makes me quite confused. Are they both accepted? Or, is one of them an old way while the other is more preferred? To me, the first one is more intuitive. But because there is no specific context for the class, it creates confusion for multiple classes. The second one is the reverse, though it also does not have context for the class. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hmm, that one is in fact incorrect. It is missing the context of my-package. (feel free to submit a PR to fix this) However, once that context is present, both The availability of the shorter |
Beta Was this translation helpful? Give feedback.
Hmm, that one is in fact incorrect. It is missing the context of my-package. (feel free to submit a PR to fix this)
However, once that context is present, both
"name"
and"MyComponent:_name"
are in fact accepted.This is because using this JSON-LD context, they both expand to the same property URL.
The availability of the shorter
"name"
was added only very recently, so that's why some places may still be using the old (but still valid)"MyComponent:_name"
version. (if you find any, PRs are welcome! :-))