Reputation: 1825
What should I add in the JSDoc @param block in the example below for my IntelliJ Webstorm IDE to stop throwing the error: Argument Type ComponentClass<undefined>
is not assignable to parameter type ??? ... `?
/**
* Renders the passed component into a div
* @param { ??? } component // Question: <<<
*/
const myRenderFunc = (component) => (
<div>{component}</div>
)
Upvotes: 4
Views: 5186
Reputation: 430
Possible solution using @typedef
/**
* @typedef { import('./Question') } Question
*/
/**
* Renders the passed component into a div
* @param { Question } component
*/
const myRenderFunc = (component) => (
<div>{component}</div>
)
or if you don't want to use @typedef
/**
* Renders the passed component into a div
* @param { import('./Question') } component
*/
const myRenderFunc = (component) => (
<div>{component}</div>
)
or if it it doesn't matter that it is a Question
component, just a React component, you can write React.ReactElement
. Be aware that you should have React imported in the file or @typedef
/**
* Renders the passed component into a div
* @param { React.ReactElement } component
*/
const myRenderFunc = (component) => (
<div>{component}</div>
)
Upvotes: 0