-
Notifications
You must be signed in to change notification settings - Fork 433
Closed
Description
The default component generated with vue cli is like this
@Options({
props: {
msg: String
}
})
export default class HelloWorld extends Vue {
msg!: string;
}
versus the Vue2 version (class components + property-decorators)
export default class HelloWorld extends Vue {
@Prop() msg!: string;
}
Reasons why the new API is an obvious downgrade:
- Boilerplate wise the new version has a fixed cost of 4 new lines + an additional cost of one redundant line per Prop, this is huge especially for something as common.
- You literrally write the same lines twice beyond the boilerplate aspect this is really annoying for thinking process of the dev as it is a non-sensical action (or at best an implementation detail that should never have leak)
2.1) You write the same types twices making no use of TS inference but actually you can write msg: Number which is an error that will not be catched at compile time. - the worst point is that
export default class HelloWorld extends Vue {
msg!: string;
}
On the line msg!: string; you have zero visual information that tells you that msg is indeed a Props, one must lookup manually on the props object and remember the association (error prone, and take harmfully cognitive load).
Can this be solved before every sane dev jump on the react ship ? 'sorry for the snark I try sincerely to be constructive here.
nicolidin, HugoKempfer, hermes85pl, zziilii, charles-allen and 5 morenicolidin
Metadata
Metadata
Assignees
Labels
No labels