Skip to content

[TypeScript] missing prop value for onChange-Event (RadioGroup + FormControlLabel) #13004

Closed
@PutziSan

Description

@PutziSan

TypeScript shows an error when implement the Radio Buttons-example from the docs: Property 'value' does not exist on type 'EventTarget'. or Type '(event: ChangeEvent<HTMLInputElement>, value: string) => void' is not assignable to type '(event: ChangeEvent<{}>, value: string) => void'

  • This is not a v0.x issue.
  • I have searched the issues of this repository and believe that this is not a duplicate.

Expected Behavior

The handleChange-event for RadioGroup and FormControlLabel should include the HTMLInputElement-type: (event: React.ChangeEvent<HTMLInputElement>, value: string) => void; and (event: React.ChangeEvent<HTMLInputElement>, checked: boolean) => void;

Current Behavior

Currently it is implemented via event: React.ChangeEvent<{}>, which does not include a value-prop.

Steps to Reproduce

Link: sandbox (see onChange of the <RadioGroup>)

It is implemented with an arrow function, since Sandbox displays the error here, but the implementation with a class function also results in an error (codesandbox swallows this error):

image

Context

Your Environment

Tech Version
Material-UI v3.1.1
React 16.5.2
TypeScript 3.0.3

(By the way, you could change the issue-template, currently "v1.?.?" is prefilled, but "v3.?.?" would make more sense I think? ;-) )

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions