Skip to content

[Bug]: TypeScript plugin drops class export #14945

@marvinhagemeister

Description

@marvinhagemeister

💻

  • Would you like to work on a fix?

How are you using Babel?

Programmatic API (babel.transform, babel.parse)

Input code

declare class Signal<T = any> {
	value: T
}

function Signal(this: Signal, value?: unknown) {
	this.value = value
}

export { Signal };

Configuration file name

No response

Configuration

{
  "presets": ["@babel/preset-typescript"]
}

Current and expected behavior

Actual output:

function Signal(value) {
  this.value = value;
}

export {};

Expected output, see this TypeScript playground:

function Signal(value) {
    this.value = value;
}
export { Signal };

Basically there is a compilation difference between babel's TypeScript preset and TypeScript itself.

Environment

OS: macOS 12.5.1
Node: 18.8.0
Yarn: 1.22.17
@babel/core: 7.19.1
@babel/preset-typescript: 7.18.6
Monorepo: no

Possible solution

No response

Additional context

My assumption is that babel sees the declare class Signal {} line and tags it as a type-only thing or something like that.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions