[proposal] make @prop more concise
See original GitHub issueRight now you have this code in the example:
@prop(Number)
propA: number;
@prop({
type: String,
default: 'default value'
})
propB: string;
However, this could be way way more concise I believe. I would like to propose the following:
Since we’re using typescript, how about inferring the property-type from the type that’s already defined for typescript? And to make it even better, we could also infer the default value from the type definition itself. So that would change the code into the following:
@prop propA: number;
@prop propB: string = "default value";
What do you think? I would really really like it to be this concise.
While we’re at it, I would like to make one more proposition. Props also have a boolean-value for whether or not they are required of course. I would like that to be inferred as well. If no default value has been provided then I think it should be inferred that the prop is required. So in this case propA
would be a required prop. And if someone really wants propA to not be required, but also not have a default value, then of course they could define it with null
as the default value.
Let me know what you think.
Issue Analytics
- State:
- Created 7 years ago
- Comments:14 (14 by maintainers)
Top GitHub Comments
I published a new version that includes this new feature.
former one.