Skip to content

"export { default } from" syntax doesn't error when no default export present #35721

@ianschmitz

Description

@ianschmitz

TypeScript Version: 3.7.3

Search Terms: export default

Code

Does not throw an error:

// a.ts
// whoops this should be a named export!
export { default } from "./b"

// b.ts
export const foo = "bar"

But this does throw an error:

// a.ts
// Error: Module has no default export
import foo from "./b"
export default foo;

// b.ts
export const foo = "bar"

Expected behavior:
Shorthand export { default } from syntax should error in the same way import foo from syntax does when no default export is present.

Actual behavior:
Shorthand export { default } from does not error as expected. I noticed this when debugging TSServer due to broken intellisense suggestions. The suggestions would not appear anywhere in our project, due to TSServer error "Alias targets of default exports must have a parent".

Playground Link:

Related Issues:

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptEffort: ModerateRequires experience with the TypeScript codebase, but feasible. Harder than "Effort: Casual".Help WantedYou can do this

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions