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 a bug with invalid print output when empty array is passed to t.tsInterfaceDeclaration #12921

Merged

Conversation

saitonakamura
Copy link
Contributor

@saitonakamura saitonakamura commented Feb 27, 2021

Q                       A
Fixed Issues?
Patch: Bug Fix? Yes
Major: Breaking Change? No
Minor: New Feature? No
Tests Added + Pass? Yes
Documentation PR Link
Any Dependency Changes? No
License MIT

Fix a bug with invalid print output when empty array is passed to t.tsInterfaceDeclaration
If you pass an empty array as extends in t.tsInterfaceDeclaration you'll get an invalid code printed

t.tsInterfaceDeclaration(
  t.identifier('A'),
  undefined,
  [],
  t.tsInterfaceBody([])
)

You will get

interface A extends {}

Which is an invalid TS, this PR fixes that

@babel-bot
Copy link
Collaborator

babel-bot commented Feb 27, 2021

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

@codesandbox-ci
Copy link

codesandbox-ci bot commented Feb 27, 2021

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 775544e:

Sandbox Source
babel-repl-custom-plugin Configuration
babel-plugin-multi-config Configuration

@saitonakamura saitonakamura force-pushed the fixed-empty-extends-print-when-empty-array branch from 8bd104f to 92d12b8 Compare February 27, 2021 10:31
@nicolo-ribaudo
Copy link
Member

Could you add a test in https://github.com/babel/babel/blob/main/packages/babel-generator/test/index.js? 🙏

@nicolo-ribaudo nicolo-ribaudo added pkg: generator PR: Bug Fix 🐛 A type of pull request used for our changelog categories labels Feb 27, 2021
…sInterfaceDeclaration

If you pass an empty array as `extends` in `t.tsInterfaceDeclaration` you'll get an invalid code printed

```ts
t.tsInterfaceDeclaration(
  t.identifier('x'),
  undefined,
  [],
  t.tsInterfaceBody([])
)
```

You will get
```ts
interface A extends {}
```

Which is an invalid TS, this PR fixes that
@saitonakamura saitonakamura force-pushed the fixed-empty-extends-print-when-empty-array branch from 92d12b8 to 775544e Compare February 28, 2021 07:17
@saitonakamura
Copy link
Contributor Author

Ya, totally, hope it's in the right place 😄

@JLHwung JLHwung merged commit d05fdbc into babel:main Mar 1, 2021
This was referenced Mar 5, 2021
This was referenced Mar 17, 2021
@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 Jun 1, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 1, 2021
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 pkg: generator PR: Bug Fix 🐛 A type of pull request used for our changelog categories
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants