Skip to content

ESM-only packages come with synthesized default in moduleResolution: bundlerΒ #54752

@Andarist

Description

@Andarist

Bug Report

πŸ”Ž Search Terms

module resolution bundler synthesized default

πŸ•— Version & Regression Information

  • This is the behavior in every version I tried

⏯ Playground Link

Playground link with relevant code

πŸ’» Code

// @moduleResolution: bundler
// @module: esnext
// @target: esnext

import mdast, { toString } from "mdast-util-to-string"; // types: 3.2.0

mdast.toString
toString

const mdast2 = await import("mdast-util-to-string"); // types: 3.2.0

mdast2.default
mdast2.default.toString
mdast2.toString

export {}

πŸ™ Actual behavior

default export is available here and points to the whole module. I don't think this is right, even with moduleResolution: bundler but I can be wrong about this since it's really hard to know what kind of assumptions and goals this mode has when it comes to subtle details

πŸ™‚ Expected behavior

I don't expect default to be available here since this ESM-only package doesn't have a default export.

Note that even if this isn't a bug, .default available on that dynamically imported binding should behave in the same way in the IDE as the specifier coming from the import statement. Right now the hover info isn't available on it and go to (type?) definition doesn't work on it with cmd+click.

cc @andrewbranch

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