Skip to content

importsNotUsedAsValues: preserve is not preserving #43393

Closed
@robpalme

Description

@robpalme

Bug Report

My interpretation of the "importsNotUsedAsValues": preserve option is that the goal is to emit value imports as-is. So that you can rely on the JS emit reflecting the JS you write. Here is a case that seems to violate that.

🔎 Search Terms

importsNotUsedAsValues preserve import binding missing skipped omitted import for side-effects JS+types

🕗 Version & Regression Information

  • This is the behavior in every version I tried

⏯ Playground Link

Playground link with relevant code

💻 Code

// @importsNotUsedAsValues: preserve

// @filename: child.ts
export default 1

// @filename: main.ts
import d from './child'
eval("d");

🙁 Actual behavior

JS emit for main.ts is missing the import binding.

import './child';
eval("d");

🙂 Expected behavior

The value import should be preserved.

import d from './child';
eval("d");

Metadata

Metadata

Assignees

No one assigned

    Labels

    Fix AvailableA PR has been opened for this issueIn DiscussionNot yet reached consensusSuggestionAn idea for TypeScript

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions