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 Super
from Expression
alias
#14750
Remove Super
from Expression
alias
#14750
Conversation
JLHwung
commented
Jul 12, 2022
•
edited
edited
Q | A |
---|---|
Fixed Issues? | #14739 (comment) |
Patch: Bug Fix? | |
Major: Breaking Change? | |
Minor: New Feature? | |
Tests Added + Pass? | Yes |
Documentation PR Link | babel/website#2765 |
Any Dependency Changes? | |
License | MIT |
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/52487/ |
8b59890
to
4476644
Compare
@@ -653,7 +653,7 @@ describe("scope", () => { | |||
describe("duplicate declaration", () => { | |||
it("should not throw error on duplicate class and function declaration", () => { | |||
const ast = [ | |||
t.classDeclaration(t.identifier("A"), t.super(), t.classBody([]), []), | |||
t.classDeclaration(t.identifier("A"), null, t.classBody([]), []), |
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.
class A extends super {}
is invalid.
callee.object = t.assignmentExpression( | ||
"=", | ||
temp, | ||
// object must not be Super when `temp` is an identifier | ||
callee.object as t.Expression, |
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 is pretty annoying that we can't have TS narrowed down the object
type in such pattern const foo = scope.maybeGenerateMemoised(object); if (foo) { // object must not be Super | TopicReference ... }
. I tried conditional type like
maybeGenerateMemoised<T extends t.Node>(object: T): T extends t.Super ? null : t.Identifier
TS can infer maybeGenerateMemoised
returns null
when object
is Super
, but it can't infer T
from the return results.
432acf6
to
3835ae1
Compare
Super
from Expression
alias