Skip to content
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

Merged
merged 4 commits into from Jul 13, 2022

Conversation

JLHwung
Copy link
Contributor

@JLHwung JLHwung commented Jul 12, 2022

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

@babel-bot
Copy link
Collaborator

babel-bot commented Jul 12, 2022

Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/52487/

@JLHwung JLHwung force-pushed the remove-super-from-expression branch from 8b59890 to 4476644 Compare July 12, 2022 18:55
@@ -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([]), []),
Copy link
Contributor Author

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.

Comment on lines +178 to +182
callee.object = t.assignmentExpression(
"=",
temp,
// object must not be Super when `temp` is an identifier
callee.object as t.Expression,
Copy link
Contributor Author

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.

@JLHwung JLHwung marked this pull request as ready for review July 12, 2022 19:23
@JLHwung JLHwung force-pushed the remove-super-from-expression branch from 432acf6 to 3835ae1 Compare July 12, 2022 20:05
@nicolo-ribaudo nicolo-ribaudo changed the title Remove super from expression Remove Super from Expression alias Jul 13, 2022
@nicolo-ribaudo nicolo-ribaudo merged commit 0df9f62 into babel:main Jul 13, 2022
@nicolo-ribaudo nicolo-ribaudo deleted the remove-super-from-expression branch July 13, 2022 13:51
@github-actions github-actions bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Oct 13, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 13, 2022
@JLHwung JLHwung added PR: Breaking Change 💥 A type of pull request used for our changelog categories for next major release and removed babel 8 labels Aug 9, 2023
@JLHwung JLHwung added this to the v8.0.0 milestone Aug 9, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated A closed issue/PR that is archived due to age. Recommended to make a new issue PR: Breaking Change 💥 A type of pull request used for our changelog categories for next major release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants