Skip to content

TypeScript adds exports {} into code #41513

Closed
@jon49

Description

@jon49

When importing with just types no export {} should be added. And I would also opine that if a person wants to emit export {} they should actually write that into their code themselves or be able to add a hook into the compiler which says to do that. This breaks my browser code. We shouldn't have magical code like this in the compiler. And service workers do not understand the keyword export.

Code

import { Tester } from "./tester"
(async function test() : Promise<Tester> { return { hello: "export" } }())

Expected behavior:

(async function test() { return { hello: "export" }; }());

Actual behavior:

(async function test() { return { hello: "export" }; }());
export {};

Related Issues:

#38696
#38713
https://stackoverflow.com/questions/64798609/typescript-appends-export-to-end-of-file-in-typescript-4-but-not-typescript-3

Metadata

Metadata

Assignees

No one assigned

    Labels

    In DiscussionNot yet reached consensusSuggestionAn idea for TypeScript

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions