HTMLElement does not have readonly validity: ValidityState property. Only the following elements have that property.
HTMLElement
readonly validity: ValidityState
github.com/microsoft/TypeScript/bl...
If you are using React, you can write as follows:
TS playground link
const input: React.FC = () => { return ( <input onChange={(e) => { const input: HTMLInputElement = e.target const validity: ValidityState = input.validity setValidity(validity.valid) }}/> ) }
or
const input: React.FC = () => { return ( <input onChange={(e) => { // e: React.ChangeEvent<HTMLInputElement> setValidity(e.target.validity.valid) }}/> ) }
Or if you wanted to define a handler function, you can write as follows:
const handler: (e: React.ChangeEvent<HTMLInputElement>) => void = (e) => { // ... }
const handler = (e: React.ChangeEvent<HTMLInputElement>): void => { // ... }
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
HTMLElement
does not havereadonly validity: ValidityState
property. Only the following elements have that property.github.com/microsoft/TypeScript/bl...
If you are using React, you can write as follows:
TS playground link
or
Or if you wanted to define a handler function, you can write as follows:
or