-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
Refactor expression evaluator #57955
Conversation
This PR doesn't have any linked issues. Please open an issue that references this PR. From there we can discuss and prioritise. |
@typescript-bot perf test this |
var evaluate = createEvaluator({ | ||
evaluateElementAccessExpression, | ||
evaluateEntityNameExpression, | ||
onNumericLiteral: checkGrammarNumericLiteral, |
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.
It feels strange to have this callback. This only needs the AST node and nothing else. Can we just walk the nodes like other grammar checks?
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.
I was trying to introduce as little extra overhead as possible, I agree that callback is kinds of the odd one out, but without an extra walk I'm not sure how we could ensure that check is performed in the same way.
The check does appear to happen in other places though. Enum members should go through checkEnumMember
which will call checkGrammarNumericLiteral
during expression checking. Similarly for template literals. So the check might be redundant for a full check. I'll test and see.
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 tested .. removing the check from here does not fail any test 😕. I do think it ends up being called through other paths.
@jakebailey Here they are:
tscComparison Report - baseline..pr
System info unknown
Hosts
Scenarios
tsserverComparison Report - baseline..pr
System info unknown
Hosts
Scenarios
startupComparison Report - baseline..pr
System info unknown
Hosts
Scenarios
Developer Information: |
…checkExpression.
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 a philosophy question here: utilities.ts
is a now 10,000 line long file of what is essentially uncategorized helper functions. Since we refer to it as "the expression evaluator", does that imply it's standalone enough that it should warrant its' own file, rather than getting tossed in alongside the other uncategorized helper functions?
Given how small it is and how often new files get created, I think it's probably fine in |
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.
Seems like a very simple change.
Refactor expression evaluator to sit outside of the checker.