Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

@Injectable deps entries written as [new Optional(), new Self(), Dep] inject the array as the token

クローズ
#626 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

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

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

評価

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

調査の方向性

Start with injectable/decorator.rs and trace how extract_dependency handles each deps entry; compare it with ngtsc’s getDep in compiler-cli/src/ngtsc/annotations/src/injectable.ts. Run the named ngtsc_spec.ts case, including the array-literal token scenario. Done means flagged array entries produce the token and injection flags expected by ngc across the listed forms.

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

説明

Summary

In @Injectable({ useFactory | useClass, deps }), a dep written as flags plus a token ([new Optional(), new Self(), Dep]) compiles as one token: the whole array goes to ɵɵinject, so injection fails at runtime. ngc reads it as the token Dep with the Optional and Self flags.

Found by running Angular's ngtsc spec ngtsc_spec.ts: "should compile Injectables with providedIn and factory with deps with array literal tokens" against oxc.

Reproduction

import {Injectable, Optional, Self} from '@angular/core';

@Injectable()
export class Dep {}

@Injectable({
  providedIn: 'root',
  useFactory: (dep: Dep) => new Service(dep),
  deps: [[new Optional(), new Self(), Dep]],
})
export class Service {
  constructor(dep: Dep) {}
}
Actual
__ngConditionalFactory__ = ((dep) => new Service(dep))(i0.ɵɵinject([new Optional(), new Self(), Dep]));
Expected (ngc)
__ngConditionalFactory__ = ((dep) => new Service(dep))(i0.ɵɵinject(Dep, 10));

useClass + deps, the bare form ([Optional, SkipSelf, Dep]) and new Inject(TOKEN) hit the same problem.

Cause

extract_dependency (injectable/decorator.rs) turns each deps element straight into a token. It has no port of ngtsc's getDep (compiler-cli/src/ngtsc/annotations/src/injectable.ts), which splits an array entry into a token and Inject/Optional/Self/SkipSelf flags.

主要言語
Rust
スター
244
フォーク
26
平均マージ
23時間 41分
マージ済み PR(30日)
106

環境構築

このプロジェクトには開発コンテナ、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 を短くまとめたダイジェスト。