Skip to content

Invalid JavaScript output with re-exported unresolved import types (regression)Β #56445

Closed
@dragomirtitian

Description

@dragomirtitian

πŸ”Ž Search Terms

export type invalid JavaScript

πŸ•— Version & Regression Information

  • This changed between versions 5.1 and 5.2

⏯ Playground Link

Playground Link

πŸ’» Code

import type { SomeType } from './type';

export { SomeType  };

πŸ™ Actual behavior

TypeScript will generate the following JS:

export { SomeType };

This JS is invalid since SomeType is not defined. Basically the import type is removed, but the export of the type was not.

πŸ™‚ Expected behavior

Type should be removed from export as in 5.1

Additional information about the issue

In the example above the source code has errors, so it could be argued that the output does not have to be valid. The issue was however discovered when using transpileModule . transpileModule similarly can't by design resolve the types and will preserve them in the output even though the types actually exist.

This is going to block us at Bloomberg from fully adopting TS 5.2 as we have workflows that depend on transpileModule

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptFix AvailableA PR has been opened for this issue

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions