You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
interfaceTestProps{foo(num: number): number;}classTestextendsReact.Component<TestProps>{/** * sometimes we override functions and keep their parameters unchanged * in this case, the type of `nextProps` should be `Readonly<TestProps>` but inferred as `any` * we have to specify its type `nextProps: TestProps` * is there any way to tell typescript that we need to keep its parameters unchanged? * and typescript can find its type from the overridden function */componentWillReceiveProps(nextProps){nextProps.foo(123);}}
Examples
in parent classes
interfaceTestProps{foo(num: number): number;}namespaceReact{classComponent<T>{/** * Any function that override it will inferred as (T) => void by default */[somekeywords?]componentWillReceiveProps(nextProps: T);}}
in child classes
interfaceTestProps{foo(num: number): number;}classTestextendsReact.Component<TestProps>{/** * use (Readonly<P>) => void declared at React.Component */[somekeywords?]componentWillReceiveProps(nextProps){nextProps.foo(123);}}
The text was updated successfully, but these errors were encountered:
Use Cases
Examples
in parent classes
in child classes
The text was updated successfully, but these errors were encountered: