-
Notifications
You must be signed in to change notification settings - Fork 13k
check usage before declaration for decorators #50372
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
Conversation
src/compiler/checker.ts
Outdated
return !!findAncestor(usage, current => { | ||
if (current === declContainer) { | ||
return "quit"; | ||
} | ||
if (isFunctionLike(current)) { | ||
return true; | ||
return !getImmediatelyInvokedFunctionExpression(current); |
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.
Enum is not checked properly. playground
function foo17() {
let a = (() => Enum.Yes)(); // should error
enum Enum {
No = 0,
Yes = 1,
}
}
foo17()
@typescript-bot test this |
Heya @DanielRosenwasser, I've started to run the extended test suite on this PR at 4190fb8. You can monitor the build here. |
Heya @DanielRosenwasser, I've started to run the diff-based user code test suite on this PR at 4190fb8. You can monitor the build here. Update: The results are in! |
Heya @DanielRosenwasser, I've started to run the perf test suite on this PR at 4190fb8. You can monitor the build here. Update: The results are in! |
@DanielRosenwasser Here are the results of running the user test suite comparing Everything looks good! |
Heya @DanielRosenwasser, I've run the RWC suite on this PR - assuming you're on the TS core team, you can view the resulting diff here. |
@DanielRosenwasser Here they are:
CompilerComparison Report - main..50372
System
Hosts
Scenarios
TSServerComparison Report - main..50372
System
Hosts
Scenarios
Developer Information: |
@typescript-bot test this |
@sandersn Here are the results of running the user tests with tsc comparing There were infrastructure failures potentially unrelated to your change:
Otherwise... Everything looks good! |
Hey @sandersn, the results of running the DT tests are ready. Everything looks the same! |
@sandersn Here they are:
tscComparison Report - baseline..pr
System info unknown
Hosts
Scenarios
Developer Information: |
@sandersn Here are the results of running the top 400 repos with tsc comparing Everything looks good! |
|
I'm confused; wouldn't our extended tests have caught a bad break? |
Actually, my read is wrong. #57933 only applied to passing the declared class variable to decorators used within that class, which is kosher given that the transformer injects the decorator call after the class is declared. The example from #62083, passing a block-scoped variable declared after the class to a decorator within the class body, would lead to runtime errors if transpiled by TypeScript itself – clearly the custom transpilation used there is doing something different. |
Fixes #50349