
[microsoft/TypeScript] Inconsistent lookup/resolution for `typeof` in JSDoc (Issue #61959)
DRANK
DanielRosenwasser created an issue (microsoft/TypeScript#61959) ```js /** * @template T * @param {T} a * @return {typeof a} */ function f(a) { return a; } ``` Today, this gives the following error ([playground link](https://www.typescriptlang.org/play/?filetype=js#code/PQKhFgCgAIWgBALgUwLYAcA2BDF0AqUsC62ATtqtAN74C+02Rc8ZyiArmQHY2ICe6ZAHsAZozrNgUUR24BjRAEthvUQApsAShpFo+tpx6MA3FDpA)): ``` * @return {typeof a} ~ error: Cannot find name 'a'. ``` However, if you add an outer declaration of `a`: ```js let a = 123; /** * @template T * @param {T} a * @return {typeof a} */ function f(a) { return a; } ``` You get a different error ``` return a; ~~~~~~ Type 'T' is not assignable to type 'number'. ``` Go-to-definition and find-all-references also resolves locally to the parameter, not the outer local. -- Reply to this email directly or view it on GitHub: https://github.com/microsoft/TypeScript/issues/61959 You are receiving this because you are subscribed to this thread. Message ID: <microsoft/TypeScript/issues/61959@github.com>
👀 github.com/microsoft/Type…