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

fix: additional commas in TsTypeLiteral #1157

Merged

Conversation

henryqdineen
Copy link
Contributor

This is very pretty similar to #868 but with TsTypeLiteral. We were working on a codemod that involves adding to a type and it was resulting in syntactically incorrect code like this (notice the ;,):

type FooProps = {
  bar: string;,
  children?: React.ReactNode
}

We were able to patch-package but I figured I would make an upstream fix. Thank you!

Copy link
Collaborator

@eventualbuddha eventualbuddha left a comment

Choose a reason for hiding this comment

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

Thanks! It'd be very useful to have a test that fails before the changes you've made. Mind doing that?

@henryqdineen henryqdineen force-pushed the fix-ts-type-literal-comma branch 2 times, most recently from de3213d to 5c660cf Compare July 30, 2022 01:59
@henryqdineen
Copy link
Contributor Author

Thanks! I just pushed a commit to add a test following a similar pattern as #1157

Against master the test fails with this error:

  1) TypeScript
       TypeLiteral: unwanted comma:

      AssertionError [ERR_ASSERTION]: Expected values to be strictly equal:
+ actual - expected

+ 'type A = {\n  x: boolean;,\n  y: number;\n}'
- 'type A = {\n  x: boolean;\n  y: number;\n}'
                            ^
      + expected - actual

       type A = {
      -  x: boolean;,
      +  x: boolean;
         y: number;
       }

Copy link
Collaborator

@eventualbuddha eventualbuddha left a comment

Choose a reason for hiding this comment

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

Thanks! Will merge and do a release soon.

@eventualbuddha eventualbuddha merged commit 52c2ec1 into benjamn:master Aug 3, 2022
@eventualbuddha
Copy link
Collaborator

Released in v0.21.2.

benjamn added a commit that referenced this pull request Dec 10, 2022
Follow-up to PR #1157 that I caught while trying to regenerate the
TypeScript declarations for ast-types, and noticed a bunch of (IMHO
reasonable) semicolons going missing.
coderaiser pushed a commit to coderaiser/recast that referenced this pull request May 27, 2024
Follow-up to PR benjamn#1157 that I caught while trying to regenerate the
TypeScript declarations for ast-types, and noticed a bunch of (IMHO
reasonable) semicolons going missing.
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.

2 participants