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

InputText: Interface 'InputTextProps' incorrectly extends interface 'InputHTMLAttributes'. Password: Interface 'PasswordProps' incorrectly extends interface 'InputHTMLAttributes'. #5480

Closed
limsbeheer opened this issue Mar 27, 2024 · 16 comments
Assignees
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Milestone

Comments

@limsbeheer
Copy link

Describe the bug

tsc --build fails with the following errors:

node_modules/primevue/inputtext/InputText.d.ts:85:18 - error TS2430: Interface 'InputTextProps' incorrectly extends interface 'InputHTMLAttributes'.
  Types of property 'size' are incompatible.
    Type 'string | undefined' is not assignable to type 'Numberish'.
      Type 'undefined' is not assignable to type 'Numberish'.

85 export interface InputTextProps extends InputHTMLAttributes {
                    ~~~~~~~~~~~~~~

node_modules/primevue/password/Password.d.ts:168:18 - error TS2430: Interface 'PasswordProps' incorrectly extends interface 'InputHTMLAttributes'.
  Types of property 'disabled' are incompatible.
    Type 'boolean | undefined' is not assignable to type 'Booleanish'.
      Type 'undefined' is not assignable to type 'Booleanish'.

168 export interface PasswordProps extends InputHTMLAttributes {
                     ~~~~~~~~~~~~~

Reproducer

https://stackblitz.com/edit/vitejs-vite-gkvhqj?terminal=dev

PrimeVue version

3.50.0

Vue version

3.x

Language

ALL

Build / Runtime

TypeScript

Browser(s)

No response

Steps to reproduce the behavior

  1. Browse to https://stackblitz.com/edit/vitejs-vite-gkvhqj?terminal=dev
  2. Enter tsc --build in the terminal
  3. Errors are shown.

Expected behavior

tsc --build succeeds without errors.

@limsbeheer limsbeheer added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Mar 27, 2024
@sunny7dusk
Copy link

I am having issues with this as well. I am working on wrapping PrimeVue, and am unable to extend the associated props for InputText and Password. Other components such as ToggleButton and their props seem to extend just fine.

<script setup lang="ts">
import InputText, { InputTextProps } from 'primevue/inputtext';
const props = defineProps<InputTextProps>()
</script>
<template>
    <InputText v-bind="{...$attrs, ...props}">
        <slot v-for="slot in Object.keys($slots)" :name="slot" :slot="slot"/>
    </InputText>
</template>
[vite] Internal server error: [@vue/compiler-sfc] Failed to resolve extends base type.
If this previously worked in 3.2, you can instruct the compiler to ignore this extend by adding /* @vue-ignore */ before it, for example:

interface Props extends /* @vue-ignore */ Base {}

Note: both in 3.2 or with the ignore, the properties in the base type are treated as fallthrough attrs at runtime.

@reitbauer
Copy link

I have the same problem extending the InputTextProps. I get this error:
image

@slavco86
Copy link

slavco86 commented Jul 2, 2024

Same issue here 😭

@slavco86
Copy link

slavco86 commented Jul 2, 2024

@tugcekucukoglu, @mertsincan , @cagataycivici , please please please - can this be prioritised. Since Prime applies a very composition oriented approach towards Inputs, there is an ever growing need to build your own Input components purely out of DX interest (I don't want to be copy pasting a template of 3 elements in particular order 100 times because my standard input needs to support floating label, helper text and icons all at the same time... I would have chosen Bootstrap otherwise). And this error makes it impossible to achieve this because it involves inevitably extending InputTextProps, which breaks TS.

@sebaranowski
Copy link

sebaranowski commented Jul 17, 2024

I'm also getting an error when I try to create a simple wrapper component... 😭

[plugin:vite:vue] [@vue/compiler-sfc] Failed to resolve extends base type.
...
node_modules/primevue/inputtext/InputText.d.ts
83 |   * Defines valid properties in InputText component.
84 |   */
85 |  export interface InputTextProps extends InputHTMLAttributes {
   |                                          ^^^^^^^^^^^^^^^^^^^
86 |      /**
87 |       * Value of the component.

The wrapper component:

<script setup lang="ts">
import type { InputTextProps } from 'primevue/inputtext';
import InputText from 'primevue/inputtext';

const props = defineProps<InputTextProps>();
</script>

<template>
  <InputText v-bind="props" />
</template>

I'm using nuxt-primevue module in a Nuxt app which comes with PrimeVue v3. Will this be resolved for v4? I mean this is quite crucial, isn't it?

EDIT: Just tested it with a fresh Nuxt setup and PrimeVue v4 but still the same error...

@thomaslecoeur
Copy link

thomaslecoeur commented Jul 24, 2024

I think this needs to be fixed urgently to be able to use Primevue as UI base while keeping TS functionnalties.

I'm having the same issue on the Button component.

@slavco86
Copy link

Would be nice to have some reaction from the maintainers 🙏

@doganalper
Copy link

Having same problem here, since InputText does not have built-in error display I am creating a component with a span element to display error messages and I cannot extend my component props from InputText prop.

@thomaslecoeur
Copy link

For now, using /* @vue-ignore */ before each extend has been "solving" the issue. But seems like a temporary fix.

Here is a full extend of the Button component :

<script lang="ts" setup>
import type { ButtonEmits, ButtonProps, ButtonSlots } from 'primevue/button';
import Button from 'primevue/button';

interface BaseHigdayButtonProps extends /* @vue-ignore */ ButtonProps {
  // Custom props
}
interface BaseHigdayButtonEmits extends /* @vue-ignore */ ButtonEmits {}
interface BaseHigdayButtonSlots extends /* @vue-ignore */ ButtonSlots {}

defineProps<BaseHigdayButtonProps>();
defineEmits<BaseHigdayButtonEmits>();
defineSlots<BaseHigdayButtonSlots>();

defineOptions({
  inheritAttrs: false,
});
</script>

<template>
  <div>
    <Button v-bind="$attrs">
      <template
        v-for="(_, name) in $slots"
        #[name]="scope"
      >
        <slot
          :name
          v-bind="scope"
        />
      </template>
    </Button>
  </div>
</template>

@DjilanoS
Copy link

DjilanoS commented Aug 28, 2024

For now, using /* @vue-ignore */ before each extend has been "solving" the issue. But seems like a temporary fix.

Here is a full extend of the Button component :

<script lang="ts" setup>
import type { ButtonEmits, ButtonProps, ButtonSlots } from 'primevue/button';
import Button from 'primevue/button';

interface BaseHigdayButtonProps extends /* @vue-ignore */ ButtonProps {
  // Custom props
}
interface BaseHigdayButtonEmits extends /* @vue-ignore */ ButtonEmits {}
interface BaseHigdayButtonSlots extends /* @vue-ignore */ ButtonSlots {}

defineProps<BaseHigdayButtonProps>();
defineEmits<BaseHigdayButtonEmits>();
defineSlots<BaseHigdayButtonSlots>();

defineOptions({
  inheritAttrs: false,
});
</script>

<template>
  <div>
    <Button v-bind="$attrs">
      <template
        v-for="(_, name) in $slots"
        #[name]="scope"
      >
        <slot
          :name
          v-bind="scope"
        />
      </template>
    </Button>
  </div>
</template>

It's not really a "fix" as you're binding the $attrs here.
If you want to v-bind="props" along with interface DSButtonProps extends /* @vue-ignore */ ButtonProps, IButtonProps {} it won't work because the props from ButtonProps won't bind.

@thomaslecoeur
Copy link

@DjilanoS You're right it doesn't solve the issue and doesn't count as a solution, as the attrs are not interpreted as props. It just allowed better autocompletion for my vscode.

@Residufermente
Copy link

Same problem, a fix or a reaction from a maintainer would be appreciated

@murshex
Copy link

murshex commented Sep 30, 2024

@tugcekucukoglu ...

@Lirrrx
Copy link

Lirrrx commented Nov 4, 2024

@tugcekucukoglu, why not just rewrite internal types in such cases
from
export interface InputTextProps extends InputHTMLAttributes {...}
to
export type InputTextProps = {...} & InputHTMLAttributes?

@petitkriket
Copy link

temporary solution is not very desirable, upvoting it too

@tugcekucukoglu tugcekucukoglu added Type: Bug Issue contains a bug related to a specific component. Something about the component is not working and removed Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible labels Nov 21, 2024
@tugcekucukoglu tugcekucukoglu added this to the 4.2.3 milestone Nov 21, 2024
@tugcekucukoglu tugcekucukoglu self-assigned this Nov 21, 2024
@thomaslecoeur
Copy link

@tugcekucukoglu I'm not sure the resolving commit would solve the issue for component like Button (and probably others).

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