Skip to content

Export default of type emits invalid codeΒ #55087

Closed
@EliLichtblau

Description

@EliLichtblau

Bug Report

πŸ”Ž Search Terms

Export default type
Export default type reference error

πŸ•— Version & Regression Information

This has always been the behavior

⏯ Playground Link

Playground link

πŸ’» Code

import type {SyntaxKind} from "typescript"

export default SyntaxKind

Emits ESM

export default SyntaxKind

Emits CommonJs

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = SyntaxKind;

which causes a reference error.

πŸ™ Actual behavior

Emitted code errors at runtime with reference error

πŸ™‚ Expected behavior

If I am default exporting a type I'd like that to be dropped from the emitted code as to not error.

Since this is old behavior I'm guessing this might have something to do with globals that I do not understand? Any clarification on the issue is also super appreciated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptHelp WantedYou can do this

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions