在我的react和typescript应用程序中,我使用:
onChange={(e) => data.motto = (e.target as any).value}
我如何正确地定义类的类型,这样我就不必用any
破解类型系统了?
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'.