Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add null types to InputText and Password #2576

Closed
ig-onoffice-de opened this issue May 27, 2022 · 0 comments
Closed

Add null types to InputText and Password #2576

ig-onoffice-de opened this issue May 27, 2022 · 0 comments
Assignees
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Milestone

Comments

@ig-onoffice-de
Copy link
Contributor

I'm submitting a ... (check one with "x")

[x] bug report => Search github for a similar issue or PR before submitting
[ ] feature request => Please check if request is not on the roadmap already https://github.com/primefaces/primevue/wiki/Roadmap
[ ] support request => Please do not submit support request here, instead see http://forum.primefaces.org/viewforum.php?f=110

Current behavior
It is not possible to use a nullable Type as input for InputText or Password component.

Expected behavior
It should be possible to use also null as input in InputText and Password component.

Minimal reproduction of the problem with instructions

<script lang="ts" setup>
import { reactive } from 'vue'
import { Nullable } from 'primevue/ts-helpers'

export type TestData = {
  notNullable: string | undefined,
  nullableExplicit: string | undefined | null,
  nullableWithType: Nullable<string>
}

const data: TestData = reactive({
  notNullable: undefined,
  nullableExplicit: null,
  nullableWithType: null
})
</script>
<template>
  <InputText v-model="data.notNullable"/>
  <InputText v-model="data.nullableExplicit"/>
  <InputText v-model="data.nullableWithType"/>
</template>

The second and third InputText gives me typescript errors on build (using InputText or using Password)

 error TS2322: Type 'string | undefined | null' is not assignable to type 'string | undefined'.
  Type 'null' is not assignable to type 'string | undefined'.
         v-model="data.nullableExplicit"
error TS2322: Type 'Nullable<string>' is not assignable to type 'string | undefined'.
          v-model="data.nullableWithType"

What is the motivation / use case for changing the behavior?
I need the possibility to set my input data to null not undefined.

Please tell us about your environment:

  • Vue version: 3.2.25

  • PrimeVue version: 3.12.6

  • Browser: [all ]

@tugcekucukoglu tugcekucukoglu added the Type: Bug Issue contains a bug related to a specific component. Something about the component is not working label May 30, 2022
@tugcekucukoglu tugcekucukoglu added this to the 3.12.7 milestone May 30, 2022
@tugcekucukoglu tugcekucukoglu self-assigned this May 30, 2022
@tugcekucukoglu tugcekucukoglu changed the title Add null to types in InputText and Password Add null types to InputText and Password May 30, 2022
tugcekucukoglu added a commit that referenced this issue May 30, 2022
Fixed #2576 - Add null types to InputText and Password
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Projects
None yet
Development

No branches or pull requests

2 participants