在我的react和typescript应用程序中,我使用:
onChange={(e) => data.motto = (e.target as any).value}
我如何正确地定义类的类型,这样我就不必用任何类型系统来破解我的方法?
export interface InputProps extends React.HTMLProps<Input> {
...
}
export class Input extends React.Component<InputProps, {}> {
}
如果我放target: {value: string};我得到:
ERROR in [default] /react-onsenui.d.ts:87:18
Interface 'InputProps' incorrectly extends interface 'HTMLProps<Input>'.
Types of property 'target' are incompatible.
Type '{ value: string; }' is not assignable to type 'string'.