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

fix(ng_module): `ɵfac` ignores `@Inject(TOKEN)` on `@NgModule` constructor parameters

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

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

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

評価

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

調査の方向性

Start in crates/oxc_angular_compiler/src/ng_module/decorator.rs at extract_param_dependency, then compare directive/decorator.rs and pipe/decorator.rs. Check how the @Inject argument is extracted and how the other four extract_param_dependency copies differ. Done means @NgModule factories use the @Inject token, fall back to the type without @Inject, and cover both token and class-type reproductions.

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

説明

bug

The @NgModule factory reads @Optional, @Self, @SkipSelf, @Host and @Attribute on constructor parameters, but not @Inject. The token comes from the type annotation instead:

  • type with no token (unknown, an interface, a primitive) → ɵɵinvalidFactoryDep(i), and the module throws NG0202 when it is created;
  • class type → the class is injected instead of the @Inject token, with no error.

Same result for an aliased import (import {Inject as Inj}). @Injectable, @Pipe and the other handlers read @Inject fine.

Repro

import {Inject, InjectionToken, NgModule} from '@angular/core';
export const TOKEN = new InjectionToken<unknown>('TOKEN');
@NgModule({})
export class M {
  constructor(@Inject(TOKEN) x: unknown) {}
}
import {Inject, Injectable, NgModule} from '@angular/core';
@Injectable({providedIn: 'root'}) export class Real {}
@Injectable({providedIn: 'root'}) export class Other {}
@NgModule({})
export class M {
  constructor(@Inject(Other) x: Real) {}
}

OXC (#504 tip and main, same output)

static ɵfac = function M_Factory(__ngFactoryType__) {
  return new (__ngFactoryType__ || M)(i0.ɵɵinvalidFactoryDep(0));
};
// at runtime: NG0202: This constructor is not compatible with Angular Dependency Injection
// because its dependency at index 0 of the parameter list is invalid.
return new (__ngFactoryType__ || M)(i0.ɵɵinject(Real));   // should be Other

ngtsc 22.1.7

return new (__ngFactoryType__ || M)(i0.ɵɵinject(TOKEN));
return new (__ngFactoryType__ || M)(i0.ɵɵinject(Other));

Where

crates/oxc_angular_compiler/src/ng_module/decorator.rs, extract_param_dependency (tip ~L467, main ~L444): the decorator match has no "Inject" arm (it falls into _ => {}), and the token always comes from extract_param_token (the type annotation). Compare directive/decorator.rs (tip ~L357) or pipe/decorator.rs (tip ~L307), which read the @Inject argument first.

On main?

Yes.

Direction

Read the @Inject(...) argument as the token, like the pipe extractor does, and fall back to the type only when there is no @Inject. The five extract_param_dependency copies (component, directive, pipe, injectable, ng_module) could share one helper so they can't drift again.

主要言語
Rust
スター
232
フォーク
21
平均マージ
1日 18時間
マージ済み PR(30日)
59

環境構築

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