-
-
Notifications
You must be signed in to change notification settings - Fork 506
Description
What problem does this feature solve?
<!-- @fallthroughAttributes true --> is a great tool on components meant to wrap and extend other components.
In practice, there are a few details that could be more accurate.
Let's call O the outside wrapper and I the inner component.
-
All fallthrough attributes are optional props on
O, so unlike regular DX there's no indication when you use<O>and do not set a required props.
Ideally this should take into account any prop directly set byOonI, which means it's now optional onOitself (or should it not be a prop at all? I'm not sure whether$attrsfallback or explicitly defined props take precedence). -
In a component compiled with
fallthroughAttributes, esp. when consider the previous point where missing mandatory props are required on wrapper component, vue-tsc should not display an error because of missing required properties onI(because those props will fallthrough fromOusage). I currently use<!-- @vue-ignore -->to mute it but this is a heavy hammer: any other legit vue error is also ignored. -
The type generation should omit props from
Othat hide existing props fromI, as at runtime they will not fallthrough. It creates TS error when the types are not compatible: for exampleIhasa: number,Ohasa: string, then when using<O a="test">TS complains that"test"is not an assignable tonumber.
In my opinion number (3) is the most annoying issue because it creates a lot of errors in the codebase that can't be avoided.
(1) is not actually creating TS error (although DX will not warn about potential runtime errors), and (2) can be ignored with a single comment in the wrapper template.
What does the proposed solution look like?
No visible change in api or options.
All changes impact the props type generation, as described above.