Skip to content

Type stripping changes an interpolated template into a tagged template #12039

Description

@magic-akari

Describe the bug

In strip-only mode, removing a type declaration between an expression and an interpolated template literal changes the remaining code into a tagged template expression.

Input code

f
type T = 0;
`${0}`;

Config

N/A

Link to the code that reproduces this issue

https://play.swc.rs/?version=1.15.43&code=H4sIAAAAAAAAA0vjKqksSFUIUbBVMLDmSlCpNqhNsAYA3KRIuRUAAAA%3D&config=H4sIAAAAAAAAA6vmUlBQyipOVrJSqAYygZyCxKLi1CI4HyhSXJlXklgBFFEqqSxILU4uyiwoUQJL1nKBcC0AuLhMNkUAAAA%3D&strip-types=1

SWC Info output

Repository commit: 762e5d213972536fb3053a561a21a78171c19084

Expected behavior

The expression and template literal should remain separate statements:

f
;
`${0}`;

Actual behavior

The stripped output is parsed as a tagged template expression:

f

`${0}`;

Version

All

Additional context

The output is valid JavaScript, but its runtime behavior is different from the input.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions