BugDomain: check: Type CircularityHelp Wanted
Repository metrics
- Stars
- Â (48,455 stars)
- PR merge metrics
-  (å¹³åããŒãž 6d 17h) (30d ã§ 9 merged PRs)
説æ
Bug Report
ð Search Terms
TS7022
ð Version & Regression Information
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about
TS7022
⯠Playground Link
ð» Code
/** @template T */
class GenericClass {
/**
* @param {(data: T) => void} handler
*/
setHandler(handler) {
}
}
/** @type {GenericClass<typeof handlers>} */
const theClass = new GenericClass();
theClass.setHandler(() => {});
function emptyFunction() {}
const handlers = {
thisWorksFine: emptyFunction,
thisDoesnt: console.log,
};
ð Actual behavior
'theClass' is referenced directly or indirectly in its own type annotation, happens only in the JavaScript equivalent of this code and only if an external type is included in the handlers object.
Uncommenting thisDoesnt: console.log seems to remove the type errors for some reason.
theClass.setHandler(() => {}); also seems to be required for this
ð Expected behavior
No error, because there is no error in the TypeScript equivalent either.