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

Support as and satisfies expressions for Flow #15130

Merged
merged 1 commit into from Sep 16, 2023

Conversation

gkz
Copy link
Contributor

@gkz gkz commented Jul 18, 2023

Description

Adds support for printing as and satisfies expressions in Flow.

const x = y as T;

This is accomplished first by factoring out TypeScript's logic and using/extending that.

Tests are mostly copied from TS's tests. I did a diff of Flow's and TS's snapshot file to confirm that that differences were expected (from input change).

Checklist

  • I’ve added tests to confirm my change works.
  • (If the change is user-facing) I’ve added my changes to changelog_unreleased/*/XXXX.md file following changelog_unreleased/TEMPLATE.md.
  • I’ve read the contributing guidelines.

Try the playground for this PR

@gkz gkz force-pushed the as-satisfies-flow branch 3 times, most recently from aac618a to 2815cb1 Compare July 18, 2023 23:59
@gkz
Copy link
Contributor Author

gkz commented Jul 19, 2023

Does anyone have an idea why "Prod / Node.js 18 on ubuntu-latest (Full Test) (pull_request)" (and only that) is failing?
Running the tests locally passes

@fisker
Copy link
Sponsor Member

fisker commented Jul 19, 2023

FULL_TEST=1 yarn test tests/format/flow/as-satisfies-expression/jsfmt.spec.js

@thorn0
Copy link
Member

thorn0 commented Jul 20, 2023

The names isTypeExpression and printCastExpression are inconsistent and also both aren't really good names. How about isBinaryCastExpression/printBinaryCastExpression?

@gkz
Copy link
Contributor Author

gkz commented Jul 20, 2023

The names isTypeExpression and printCastExpression are inconsistent and also both aren't really good names. How about isBinaryCastExpression/printBinaryCastExpression?

All casts are binary, but you're right it should be isCastExpression & printCastExpression - will update

@fisker
Copy link
Sponsor Member

fisker commented Jul 21, 2023

But there is already a node type called TypeCastExpression.

case "TypeCastExpression":

@gkz
Copy link
Contributor Author

gkz commented Jul 21, 2023

But there is already a node type called TypeCastExpression.

You're right, I can call it isBinaryCastExpression . The other one requires parens so isn't like a binary expression.

@gkz
Copy link
Contributor Author

gkz commented Sep 1, 2023

Sorry for the delay, I went on vacation and when I got back started working on other stuff.
I've updated the PR now as per your latest comment.

@fisker
Copy link
Sponsor Member

fisker commented Sep 1, 2023

#15130 (comment)

@gkz
Copy link
Contributor Author

gkz commented Sep 1, 2023

I'm used to using Mercurial every day so forgot to add the files before amending!

@fisker
Copy link
Sponsor Member

fisker commented Sep 1, 2023

Do we need a release after merge, or we can wait?

@gkz
Copy link
Contributor Author

gkz commented Sep 1, 2023

Do we need a release after merge, or we can wait?

I'm not in a rush with this, you don't need to change your release schedule

medikoo pushed a commit to medikoo/prettier-elastic that referenced this pull request Feb 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants