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

InputTextarea/InputText: Typescript incompatible ref type #3635

Closed
mikejav opened this issue Nov 14, 2022 · 7 comments · Fixed by #3640
Closed

InputTextarea/InputText: Typescript incompatible ref type #3635

mikejav opened this issue Nov 14, 2022 · 7 comments · Fixed by #3640
Assignees
Labels
Typescript Issue or pull request is *only* related to TypeScript definition
Milestone

Comments

@mikejav
Copy link

mikejav commented Nov 14, 2022

Describe the bug

When you are using InputTextarea component and want to access the DOM Element using the reference - it indicates the wrong type.

Expected behavior

The HTMLTextAreaElement type should be used for ref.

Reproducer

https://stackblitz.com/edit/vitejs-vite-6zkqc4?file=package.json,src%2FApp.tsx

PrimeReact version

8.7.2

React version

18.x

Language

TypeScript

Build / Runtime

Vite

Browser(s)

Chrome 106

@mikejav mikejav added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Nov 14, 2022
@mikejav
Copy link
Author

mikejav commented Nov 14, 2022

Related issue: #3172

@melloware melloware added Typescript Issue or pull request is *only* related to TypeScript definition 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 14, 2022
@melloware
Copy link
Member

melloware commented Nov 14, 2022

I am not a typescript expert but here is how its currently being extended.

export interface InputTextareaProps 
    extends Omit<React.DetailedHTMLProps<React.TextareaHTMLAttributes<HTMLTextAreaElement>, HTMLTextAreaElement>, 'ref'>

@mikejav
Copy link
Author

mikejav commented Nov 14, 2022

The following should work:

export declare const InputTextarea: React.ForwardRefExoticComponent<InputTextareaProps & RefAttributes<HTMLTextAreaElement>>;

@melloware melloware changed the title InputTextarea: Typescript incompatible ref type InputTextarea/InputText: Typescript incompatible ref type Nov 14, 2022
@melloware melloware self-assigned this Nov 14, 2022
@melloware melloware added this to the 8.7.3 milestone Nov 14, 2022
@melloware
Copy link
Member

This is fantastic! Trying it now it seems to work so fixing InputText as well.

@melloware
Copy link
Member

OK this is now causing other issue it hthe TypeScript checking...

Error: components/lib/inputmask/inputmask.d.ts(42,26): error TS274[9](https://github.com/primefaces/primereact/actions/runs/3462195764/jobs/5780762361#step:7:10): 'InputText' refers to a value, but is being used as a type here. Did you mean 'typeof InputText'?
Error: components/lib/inputnumber/inputnumber.d.ts(76,24): error TS2749: 'InputText' refers to a value, but is being used as a type here. Did you mean 'typeof InputText'?
Error: components/lib/mention/mention.d.ts(62,24): error TS2749: 'InputTextarea' refers to a value, but is being used as a type here. Did you mean 'typeof InputTextarea'?
Error: components/lib/password/password.d.ts(56,24): error TS2749: 'InputText' refers to a value, but is being used as a type here. Did you mean 'typeof InputText'?

@melloware
Copy link
Member

@mikejav thanks for the assist on this! this has been driving me nuts for a while now...

@mikejav
Copy link
Author

mikejav commented Nov 14, 2022

@melloware no problem :)
I'm glad we make it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Typescript Issue or pull request is *only* related to TypeScript definition
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants