Skip to content

Remove Super from Expression alias#14750

Merged
nicolo-ribaudo merged 4 commits intobabel:mainfrom
JLHwung:remove-super-from-expression
Jul 13, 2022
Merged

Remove Super from Expression alias#14750
nicolo-ribaudo merged 4 commits intobabel:mainfrom
JLHwung:remove-super-from-expression

Conversation

@JLHwung
Copy link
Copy Markdown
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
Copy Markdown
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
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
Copy Markdown
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
Copy Markdown
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.

4 participants