Closed
Description
TypeScript Version: 2.3.4
Code
This works:
{
/**
* @typedef {{
type: string,
color?: string
}} Props
* @param {Props} props
*/
const foo = (props) => {
console.log(props.type); // type of type is string
};
foo({ type: 1 }); // error
// However, if I destructure the param, it breaks:
/**
* @typedef {{
type: string,
color?: string
}} Props2
* @param {Props2} props
*/
const foo2 = ({ type }) => {
console.log(type); // type of type is any, expected string
};
foo2({ type: 1 }); // expected error but got none
}
Reading through the docs on JSDoc support, I couldn't find anything to suggest why this shouldn't work.