+
Skip to content
This repository was archived by the owner on Aug 31, 2023. It is now read-only.

feat: Support TS satisfies expression #3846

Merged
merged 10 commits into from
Nov 28, 2022

Conversation

nissy-dev
Copy link
Contributor

@nissy-dev nissy-dev commented Nov 24, 2022

Fix #3748

Summary

This PR is initial implementation for satisfies expression released in TS.4.9.
This is almost same as the implementation of TsAsExpression.

Test Plan

I added some parser and formatter tests. Also, I updated prettier tests about satisfies expression.

I was able to pass most of the Prettier test cases except for comments-unstable.ts. As for comments-unstable.ts, I don't understand how to pass it. I would appreciate it if you could give me some advice.

@nissy-dev nissy-dev requested a review from a team November 24, 2022 12:08
@netlify
Copy link

netlify bot commented Nov 24, 2022

Deploy Preview for docs-rometools canceled.

Name Link
🔨 Latest commit e36ee2e
🔍 Latest deploy log https://app.netlify.com/sites/docs-rometools/deploys/63846ef85402d7000903212c

@MichaReiser MichaReiser changed the title feat: support satisfies expression feat: Support TS satisfies expression Nov 25, 2022
Copy link
Contributor

@MichaReiser MichaReiser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is awesome work! Well done and thank you

@MichaReiser
Copy link
Contributor

MichaReiser commented Nov 25, 2022

There's one failing test that needs updating before merging the PR

@@ -2756,6 +2756,44 @@ impl IntoFormat<crate::JsFormatContext> for rome_js_syntax::TsAsExpression {
)
}
}
impl FormatRule<rome_js_syntax::TsSatisfiesExpression>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MichaReiser should we add this file to .gitattributes?

if TypeScript.is_unsupported(p) {
p.error(ts_only_syntax_error(
p,
"'satisfies' expression",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add a test where we emit this new diagnostic? Ideally, just a JS file with this new syntax, should be enough.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added in 8e31e54 !

@nissy-dev nissy-dev requested a review from a team as a code owner November 26, 2022 14:34
@nissy-dev
Copy link
Contributor Author

nissy-dev commented Nov 26, 2022

There's one failing test that needs updating before merging the PR

After checking one failing test, I confirmed the tests will pass by commenting out this line in check_reformat.rs. And then, I confirmed the formatted result is not different from prettiter's one so I removed comments-unstable.ts.snap. Currently, only unrelated tests failed.

@MichaReiser
Copy link
Contributor

There's one failing test that needs updating before merging the PR

After checking one failing test, I confirmed the tests will pass by commenting out this line in check_reformat.rs. And then, I confirmed the formatted result is not different from prettiter's one so I removed comments-unstable.ts.snap. Currently, only unrelated tests failed.

I pushed a commit that handles leading own line comments by creating an indent around the type. The resulting formatting differs from Prettier but is stable.

@MichaReiser MichaReiser merged commit f01fbe5 into rome:main Nov 28, 2022
@MichaReiser MichaReiser mentioned this pull request Nov 30, 2022
2 tasks
@nissy-dev nissy-dev deleted the support-satifies-expression branch January 8, 2023 00:31
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

🐛 Update parser to support satisfies keyword (Typescript 4.9+)
3 participants
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载