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(es/codegen): Fix codegen of type-only imports #8070

Merged
merged 3 commits into from
Oct 6, 2023

Conversation

ef4
Copy link
Contributor

@ef4 ef4 commented Oct 5, 2023

Type-only imports like:

import type { A } from 'b';
import { type C } from 'd';

currently emit as regular imports:

import { A } from 'b';
import { C } from 'd';

This means that if you're using swc to apply transformations to TS that don't include the typescript-to-js transform, you accidentally change the semantics of these import statements.

This PR adds tests for these cases and fixes the emitters.

Type-only imports like:

```ts
import type { A } from 'b';
import { type C } from 'd';
```

currently fail to emit correctly. This means that if you're using swc to apply transformations to TS that *don't* include stripping the types, you accidentally change the semantics of these import statements.

This PR adds tests for these cases and fixes the emitters.
@CLAassistant
Copy link

CLAassistant commented Oct 5, 2023

CLA assistant check
All committers have signed the CLA.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

ef4 added 2 commits October 5, 2023 22:29

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
Copy link
Member

@kdy1 kdy1 left a comment

Choose a reason for hiding this comment

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

swc-bump:

  • swc_ecma_codegen

@kdy1 kdy1 changed the title Fix printing of type-only imports fix(es/codegen): Fix codegen of type-only imports Oct 6, 2023
@kdy1 kdy1 added this to the Planned milestone Oct 6, 2023
@kdy1 kdy1 merged commit 6f45b46 into swc-project:main Oct 6, 2023
@kdy1 kdy1 modified the milestones: Planned, v1.3.93 Oct 13, 2023
@swc-project swc-project locked as resolved and limited conversation to collaborators Nov 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants