Skip to content

TS1471: Module X cannot be imported using this construct.... for type only imports #46213

Closed
@simllll

Description

@simllll

Bug Report

🔎 Search Terms

ts1471, Module X cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.

🕗 Version & Regression Information

with ts 4.5 beta and module set to "node12"

💻 Code

// import only a type from an ES package from a CJS package
import type { AgendaScheduler } from '@hokify/scheduler';

// some other code

🙁 Actual behavior

It's clear to me that we cannot import from an ES package, but is this true also for type only imports? Is it technically really required to load the type definitions (which are only needed for compile time) with a dynamic import? If so, how would that be done?

🙂 Expected behavior

A type only import from an ES package should still work with module node12 mode within a CJS package

Metadata

Metadata

Assignees

No one assigned

    Labels

    Working as IntendedThe behavior described is the intended behavior; this is not a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions