Skip to content

Broken type stripping for imports, "does not provide an export named" ... #58503

@shoffmeister

Description

@shoffmeister

Version

v24.1.0

Platform

Linux dell-7610 6.6.87.1-microsoft-standard-WSL2 #1 SMP PREEMPT_DYNAMIC Mon Apr 21 17:08:54 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux

Subsystem

No response

What steps will reproduce the bug?

To reproduce,

  • unpack attached archive defect.zip which contains the source code as shown below as a convenience
  • node index.ts

index.ts ==

import { f2 } from "./importOne.ts";

importOne.ts ==

import { Interface1, Interface2 } from "./importTwo.ts";

export function f2() {
  const req: Interface1 = {};
  const res: Interface2 = {};
}

importTwo.ts ==

export interface Interface1 {}

export interface Interface2 {}

How often does it reproduce? Is there a required condition?

Perfect reproduction.

What is the expected behavior? Why is that the expected behavior?

No error.

Both bun and deno are happy with these files.

What do you see instead?

(node:135845) ExperimentalWarning: Type Stripping is an experimental feature and might change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
file:///home/rch/nodejs-ts-defect/importOne.ts:1
import { Interface1, Interface2 } from "./importTwo.ts";
         ^^^^^^^^^^
SyntaxError: The requested module './importTwo.ts' does not provide an export named 'Interface1'
    at #_instantiate (node:internal/modules/esm/module_job:217:21)
    at async ModuleJob.run (node:internal/modules/esm/module_job:319:5)
    at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:663:26)
    at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:99:5)

Node.js v24.1.0

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions