Closed
Description
Bug Report
Our shop prefers arrow function style and JSDoc annotations. I've got a type predicate that works as a function declaration but as an arrow function, I get 2775
🔎 Search Terms
- arrow function
- type predicate
- TS2775
🕗 Version & Regression Information
Version 4.2.3 (and whatever version the playground runs)
- This is the behavior in every version I tried
⏯ Playground Link
💻 Code
// @ts-check
/**
* @typedef {{ legs: number }} Animal
*/
/**
* @typedef { Animal & { says: 'bark'}} Dog
*/
/**
* @param {Animal} specimen
* @returns { asserts specimen is Dog }
*/
export const canine = specimen => {
if (/** @type { Dog } */ (specimen).says !== 'bark') throw TypeError();
return undefined;
};
/** @param { string[] } argv */
export const main = argv => {
/** @type { Animal } */
const specimen1 = JSON.parse(argv[3]);
canine(specimen1);
console.log(specimen1.says);
};
🙁 Actual behavior
Assertions require every name in the call target to be declared with an explicit type annotation.(2775)
🙂 Expected behavior
same as when I change the arrow function to a function declaration: