Skip to content

InputText and DatePicker emit types include unreachable undefined, breaking strictTemplates #8441

@YevheniiKotyrlo

Description

@YevheniiKotyrlo

Describe the bug

InputText and DatePicker declare | undefined in their update:modelValue and value-change emit signatures, but neither component can emit undefined at runtime.

With strictTemplates: true in vue-tsc, the emitted | undefined is not assignable to the consumer's ref type (e.g., Ref<string> for InputText), producing 39 false-positive type errors.

InputText: Single emission path: onInput(event) -> writeValue(event.target.value). HTMLInputElement.value is always string per HTML spec. Full inheritance chain audited — no path can emit undefined.

DatePicker: All 9 emission paths traced through updateModel() -> writeValue() -> $emit(). Clear button emits null. Invalid text input throws (no emission). 7 edge cases pressure-tested. undefined is never passed to writeValue().

Related: #6041

PrimeVue version

4.5.4

Vue version

3.5.x

Language

TypeScript

Build / Runtime

Vite

Steps to reproduce the behavior

  1. Enable strictTemplates: true in tsconfig.json under vueCompilerOptions
  2. Use <InputText v-model="myString" /> where myString is ref<string>('')
  3. Run vue-tsc --noEmit
  4. Observe: Type 'string | undefined' is not assignable to type 'string'

Expected behavior

No type error — InputText always emits string, never undefined.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions