@HostBinding on a member that is not an identifier ('my-prop') compiles to `ctx.my - ctx.prop`; ngtsc uses `this["my-prop"]`

Offen
#690 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
3/5
Geschätzter Aufwand
1-2 Tage
Anfängerfreundlichkeit
72/100
Issue-Typ
Bug
Klarheit
Klar beschrieben
Aktivitätsstatus
Aktiv
Tech-Stack
rust
Bereich
compilers

Rechercherichtung

Start by reading MemberHostBindings::of in directive/metadata.rs and compare its stored member name with ngtsc's getSafePropertyAccessString behavior described in the issue. Trace how that metadata becomes partial and full output, including the non-identifier example. Done means both output forms access my-prop as a property and identifier members such as m still work.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

Found while reviewing #682.

ngtsc's extractHostBindings stores a @HostBinding member as getSafePropertyAccessString("this", member.name) (compiler-cli chunk-G5LDCSK3.js:3435): "this.m", or this["my-prop"] for a name that is not an identifier. Oxc's MemberHostBindings::of (directive/metadata.rs:201) stores the bare member name ("m", "my-prop").

@Directive({ selector: '[d]' })
export class D {
  @HostBinding('id') 'my-prop' = 1;
  @HostBinding('title') m = 2;
}
result
ngtsc partial properties: { "id": "this[\"my-prop\"]", "title": "this.m" }
Oxc partial properties:{id:"my-prop",title:"m"}
Oxc full ɵɵdomProperty("id", (ctx.my - ctx.prop))("title", ctx.m) — wrong: parsed as a subtraction

For identifier names only the partial text differs (both link to ctx.m). For names that are not identifiers, both full and partial output read the wrong value. ngtsc emits ctx["my-prop"].

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.