-
Notifications
You must be signed in to change notification settings - Fork 12.4k
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
Remove getAllAccessorDeclarations from the EmitResolver #57993
Remove getAllAccessorDeclarations from the EmitResolver #57993
Conversation
@typescript-bot perf test this faster |
@weswigham Here they are:
tscComparison Report - baseline..pr
System info unknown
Hosts
Scenarios
Developer Information: |
if (node.kind === SyntaxKind.Parameter && node.parent.kind === SyntaxKind.SetAccessor) { | ||
const other = getAllAccessorDeclarationsForDeclaration(node.parent as SetAccessorDeclaration).getAccessor; | ||
if (other) { | ||
return getEffectiveReturnTypeNode(other); | ||
} | ||
} |
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.
Just to be clear, this code is a noop, right? Since we're not actually handling these and no baselines change? This is brand new code, so, checking.
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.
Yes, for now. My goal is to move the full "should this node be reused" logic check into the node builder, to minimize the EmitResolver
's API surface. Today, the node builder never has to emit nonlocal types for get
and set
accessors. If one is missing an annotation, it gets the type the other one has, and if both have the same type, it prints them as a property, rather than accessors. Meanwhile, declaration emit proper obviously leaves accessor declarations as-is nowadays, and uses logic like this to pull the type node from the other accessor when one is missing an annotation. So this is slightly future-looking, in that it enables the node builder to properly reuse nodes for get
/set
pairs that are missing one type node, even though the declaration emitter doesn't yet ask it to do that (and you can't get an inferred type with a get
/set
pair without them having differing types, and thus both annotated).
This reduces the coupling between the checker and the transforms a bit. We actually had a
getAllAccessorDeclarations
inutilities
already - the only difference being it required the container node, too (which was readily available at all callsites). Within the checker, the reverse is done - it no longer uses thegetAllAccessorDeclarations
utilities
function, and now reliably uses thesymbol
-based lookup method theEmitResolver
previously exported, and more reliably looks up the type nodes from accessors. (This does not change any baselines yet, because accessors currently disqualify node reuse - another followup will change that.)