score:4

Accepted answer
interface IFooProps {
   // ....Whatever props that require by the component
}

// All injected props from the store
interface IFooInjectedProps extends IFooProps {
  userId: number
}

class Foo extends Component<IFooProps> {
    get injectedProps() {
       // Cast this.props as injectedProps to bypass typechecking 
       return this.props as IFooInjectedProps;
    }

    render() {
      // Get userId from the getter `injectedProps`
      const { userId } = this.injectedProps;

      return <p>foo...</p>
    }
}

score:-1

class Foo extends Component<any>{
   render(){
     return <p>foo...</p>
   }
}

score:0

// typescript only tells you to pass a testProp
<Foo testProp={5} /> 

Related Query

More Query from same tag