fix(NcSelect*): add nullish types to modelValue#8214
fix(NcSelect*): add nullish types to modelValue#8214Sector6759 wants to merge 1 commit intonextcloud-libraries:mainfrom
Conversation
Signed-off-by: Sector6759 <149817326+Sector6759@users.noreply.github.com>
susnux
left a comment
There was a problem hiding this comment.
I think we should only have one valid "unset" variant.
Either null or undefined but not both.
I would prefer undefined as it has not the weird type issue as null being an object.
Also undefined is the default for Vue refs like with const foo = ref<MyType>() it would default to undefined not null.
|
I agree with using |
susnux
left a comment
There was a problem hiding this comment.
Yes but for SelectUsers it was never allowed / documented to put null but the types already included undefined so that component is fine like it ist.
For the other two components - yes somehow implicitly typed like that.
Maybe leave it like you did for those two but state that null is deprecated in the prop documentation of them.
| * otherwise a single user data object will be emitted. | ||
| */ | ||
| const modelValue = defineModel<NcSelectUsersModel | NcSelectUsersModel[]>('modelValue') | ||
| const modelValue = defineModel<NcSelectUsersModel | NcSelectUsersModel[] | null>('modelValue') |
There was a problem hiding this comment.
here it was always undefined
| const modelValue = defineModel<NcSelectUsersModel | NcSelectUsersModel[] | null>('modelValue') | |
| const modelValue = defineModel<NcSelectUsersModel | NcSelectUsersModel[]>('modelValue') |
|
The default value for
NcSelect,NcSelectTagsisnulland forNcSelectUsersit'sundefined, but neithernullnorundefinedare part of themodelValueunion type in any of those components. Furthermore, clicking the clear button of those components sets themodelValuetonull. Manually setting therefbound to thev-modeltoundefineddoes indeed work as of now and even "clears" theNcSelect*components the same way as setting it tonulldoes. So in my opinion,nullandundefinedshould be part of the union type. ThemodelValueof theNcSelecUserscomponent, which currently is the only one of those 3 written in TypeScript, already includesundefinedin its union type because it does not itself declare a default value:🏁 Checklist
stable8for maintained Vue 2 version or not applicable