Skip to content

import type {} from 'x' prints as a value import #171

Description

@zloirock
import type {} from "x";   // ImportDeclaration { importKind: 'type', specifiers: [] }

prints

import "x";

A type-only import erases at build time; the printed spelling is a live side-effect import - the module now executes at runtime. importKind needs to survive even with zero specifiers.

Context: found by a parse -> print -> reparse structural gate over a ~8.5k-file TS/JS corpus while adopting esrap in core-js's build plugin, then re-verified in isolation. esrap 2.3.5; the ASTs below come from @typescript-eslint/typescript-estree 8.67 with loc/range enabled, so the repros are independent of our own (oxc-based) pipeline.

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