-
-
Notifications
You must be signed in to change notification settings - Fork 9k
Description
Vue version
3.3.13
Link to minimal reproduction
Steps to reproduce
In TS with strict null checks, try to pass a null value to v-model on a textarea.
What is expected?
Works ok and no type error.
What is actually happening?
Works ok but type error because null is not an acceptable type.

The cause for this is that runtime-dom ships the following type:
export interface TextareaHTMLAttributes extends HTMLAttributes {
// other attrs removed for brievity
value?: string | ReadonlyArray<string> | number;
}I think you should add null as a valid type here.
The W3C documentation even has a special mention for it!
From https://html.spec.whatwg.org/multipage/form-elements.html#the-textarea-element:

That [LegacyNullToEmptyString] annotation indicates that when null is assigned, instead of converting to string the default JS way (which results in the string "null") the value must be converted to an empty string instead ("").
System Info
See Playground repro.Any additional comments?
This was previously reported in #7737 which was closed a little too quickly in my opinion.
The OP suggested typing as any, which @sodatea dismissed (rightly so), but the case of null (which was mentionned as a repro) wasn't specifically addressed.