-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Stop an infinite loop when using an exported JSDoc function as a type #38332
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sandersn this is like, maybe, the 3rd time I've seen this condition change to fix a bug; should this check more semantic in some way, rather than mostly syntactic? Or are there actually just that many unanticipated syntactic forms?
Moreover is this fix complete? Checking just for the Class
flag seems incomplete, as an interface could be merged with the function and namespace to produce a similar shape. Isn't any SymbolFlags.Type
meaning sufficient? Or SymbolFlags.Namespace
if that's the important characteristic? I don't quite see how a class, specifically, should be the conditional, since the same structure can be made to exist thru a merged function, interface, and namespace, and a similar structure (where a symbol has type, value, and namespace meanings) is created by an Enum.
>c.s : () => void | ||
>c : C | ||
>s : () => void | ||
>c.s : any |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this seems wrong, which means that this fix may also need to be restricted to types that come through require
@weswigham
tl;dr: There are two problems: (1) an unknown number of cases that were previously being handled (2) the existing cases are tricky for me to understand.
// @filename: lib/index.js
/** @type {import('../folder/index').zzz} */
export function xxx() {
return 12;
}
// @filename: folder/index.d.ts
export function zzz(): string;
export type zzz = (n: number) => number; The intent is for
|
Deprecated by #39770 |
Fixes #36830
In JS we want to support treating values as types in a bunch of positions, the code in #35057 added the ability for this to work in classes but it was over-reaching and also getting called when you have a function. This caused an infinite loop as the type lookup was the same object and not something which could differ in the way an instance vs the 'class' (e.g. the static stuff) could differ.