dts: `typeof X` references in ɵmod / hostDirectives use local names with no import (TS2304 in published .d.ts)

Offen
#692 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Anfängerfreundlichkeit
48/100
Issue-Typ
Bug
Klarheit
Klar beschrieben
Aktivitätsstatus
Aktiv
Tech-Stack
rust, typescript

Rechercherichtung

Start in dts.rs at the formatter locations listed in the issue: lines 392, 406, 420, 720, and 769. Trace how declarations are generated for ɵmod members and hostDirectives, then check the bundled and unbundled examples against the emitted .d.ts files. Done means referenced classes, including aliased host directives, resolve for consumers without skipLibCheck; add or run focused declaration emit tests for those cases.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

Found while reviewing #683. The member text comes from the compiler (dts.rs), so both the asset and chunk paths ship it.

ngtsc writes references to other classes in .d.ts members as typeof i1.X with import * as i1 from "./x". Oxc writes the local name with no import: format!("typeof {}", …) at dts.rs:392/406/420 (ɵmod declarations / imports / exports) and dts.rs:720/769 (hostDirectives). The name only resolves if that class happens to be declared in the same .d.ts under the same name. Declaration emit drops imports only used by decorators, so it often isn't.

A. bundled (rolldown-plugin-dts), index.ts exports only LibModule
   static ɵmod: i0.ɵɵNgModuleDeclaration<LibModule, never, [typeof InternalComponent], [typeof InternalComponent]>;
   → InternalComponent is not declared in index.d.ts → consumer tsc: TS2304 Cannot find name 'InternalComponent'

B. tsdown unbundle: true
   lib.module.d.mts: [typeof HelloComponent, typeof HighlightDirective], no import of either → 4× TS2304

C. aliased host directive: import { HighlightDirective as HD } …; hostDirectives: [{ directive: HD }]
   [{ directive: typeof HD; … }]  → no `HD` in the emitted .d.ts → TS2304 (or `any` with skipLibCheck)

With skipLibCheck: true the errors go away, but the types become any, so the consumer's Angular compiler can't see the module's exported components.

Vorherrschende Sprache
Rust
Sterne
245
Forks
26
Ø Merge
1 T. 42 Min.
Gemergte PRs (30 T.)
83

Entwicklungsumgebung

Dieses Projekt bietet weder Dev-Container noch Dockerfile noch Beitragsleitfaden – die Einrichtung liegt bei Ihnen. Beginnen Sie mit der README; die allgemeinen Schritte stehen in unserem Leitfaden für den ersten Beitrag.

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus voidzero-dev/oxc-angular-compiler

Alle Issues in voidzero-dev/oxc-angular-compiler

Ähnliche Issues

Weitere Issues zu Rust

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.