How do I set up Typescript to use the JSDoc types if it exists?
I have my function annotating the parameter and return type but typescript still as any. How can I set up Typescript to define my parameter and return types by its JSDoc if a JSDoc exists? (Visual Studio Code error)
/**
* Creates arrow icon's class name to rotate it upon its x axis.
*
* Arrow icon communicates to the user that they can expand or collapse the filter.
*
* @param {boolean} isOpen If the filter is open so that it can be viewed.
* @returns {string} The class name for the arrow icon.
*/
const arrowClassName = (isOpen) =>
isOpen ? styles.arrowIcon : `${styles.arrowIcon} ${styles.expanded}`;
Error displayed on isOpen
: Parameter 'isOpen' implicitly has an 'any' type.ts(7006)
CodePudding user response:
Typescript requires files to be in Javascript (*.js
) to support most the of JSDoc annotations.