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

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

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

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

評価

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

調査の方向性

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.

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

説明

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"].

主要言語
Rust
スター
245
フォーク
26
平均マージ
1日 42分
マージ済み PR(30日)
83

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

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

voidzero-dev/oxc-angular-compiler のほかの issue

voidzero-dev/oxc-angular-compiler の issue をすべて見る

似ている issue

Rust の issue をもっと見る

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

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