A type imported from a JS module (declared `export type` in its .d.rx, or a package's TS-only type) compiles to a value import; the bundle fails with MISSING_EXPORT

オープン
#78 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
56/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
typescript
領域
compilers

調査の方向性

Start with compiler/src/emit.rs at the module import emission around lines 361 and 676–696, then compare the existing type filtering around line 606. Check how .d.rx declarations represent JsDecl::Type and how imports used only in type positions are tracked. Done means type-only names emit neither an ES value import nor a runtime binding; verify with the provided repro and confirm the Vite build no longer reports MISSING_EXPORT.

索引モデルが issue の本文から書いたものです。

説明

A type imported from a JS module compiles to a runtime value import, so the bundler fails on an export that only exists in TypeScript.

Versions: @reactivescript/compiler, @reactivescript/runtime, @reactivescript/language-server 0.3.1; solid-js 2.0.0-rc.21; @solidjs/vite-plugin 3.0.0-next.57.

Repro

lib.d.rx:

export type Outcome = { kind: "idle" } | { kind: "sent" }
export fn post(body: object)

lib.ts:

export type Outcome = { kind: 'idle' } | { kind: 'sent' }
export function post(_b: object) {}

main.rx:

import { StyleXStyles } from "@stylexjs/stylex"
import { Outcome } from "./lib"

export component App({ s }: { s?: StyleXStyles }) {
  source o: Outcome := { kind: "idle" }
  <p>{o.kind}</p>
}

app("main.rx", "dom") from the compiler's Node-API reports no diagnostic and emits:

import { StyleXStyles as w$StyleXStyles } from "@stylexjs/stylex";
import { Outcome as w$Outcome } from "./lib";
...
const v$StyleXStyles = w$StyleXStyles;
__rt.reg("StyleXStyles", { value: v$StyleXStyles });
const v$Outcome = w$Outcome;
__rt.reg("Outcome", { value: v$Outcome });

A Vite (Rolldown) build then fails with MISSING_EXPORT for both names: neither lib.ts nor @stylexjs/stylex exports them as values.

Expected

guide/reference.md says there is no import type and types are imported the same way, and MO-6c says an imported type "binds no value". So:

  • Outcome is declared export type in the .d.rx beside the module (MO-8a). The compiler knows it is a type and should emit neither the ES import nor the binding.
  • StyleXStyles has no .d.rx, so only its use tells the compiler it is a type. A name an import binds that is only read in type positions should be erased too. Otherwise a type from a package cannot be imported at all; the only workaround is an inline import("@stylexjs/stylex").StyleXStyles type.

Cause

.rx imports already skip types: compiler/src/emit.rs:606 checks Decl::TypeDecl / ExportSig::Type and continues ("a type binds nothing"). JS imports (resolved: None) have no such check, even when the .d.rx declares the name as JsDecl::Type:

  • compiler/src/emit.rs:361 builds the module-level import { … } from every name;
  • compiler/src/emit.rs:676-696 binds every name to w$<alias> and emits __rt.reg.

Both should drop a name the declaration file declares as a type, and ideally a name that is used only in type positions.

主要言語
TypeScript
スター
127
フォーク
7
平均マージ
15時間 42分
マージ済み PR(30日)
63

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

solidjs/reactivescript のほかの issue

solidjs/reactivescript の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。