ngbracket / ngbracket/ngx-layout
Adopt inject() over constructor DI (deferred until after 22.0.0)
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 235
- Forks
- 16
- Avg merge
- 17m
- Merged PRs (30d)
- 1
Description
Summary
Migrate the library from constructor parameter injection to the inject() function, using Angular's schematic:
ng generate @angular/core:inject
This is deferred until after the 22.0.0 release — it's a purely internal/stylistic refactor with no consumer-facing behavior change, and folding it into the release would mix a large mechanical refactor with functional changes.
Scope in this codebase
- 23 directives extend the abstract
BaseDirective2, each callingsuper(elRef, styleBuilder, styler, marshal). - 32
@Inject(TOKEN)sites across 5 secondary entry points:core,flex,extended,grid,server. BaseDirective2(core/base/base2.ts) has aprotected constructorwith parameter-property deps and is exported from the public API (core/public-api.ts), so it's a consumer extension point.
Risks / caveats (why this needs care, not fire-and-forget)
- Inheritance +
super(...)— when the base drops constructor params, all 23super(...)calls must change in lockstep. The schematic can leave a partial migration across entry points that needs manual cleanup. BaseDirective2is public + abstract — removing its constructor params is a breaking change for any downstream app that subclasses it and callssuper(...). If migrating it, run the schematic in backwards-compatibility mode so a compatible protected constructor is retained (or treat it as an intentional, documented breaking change for the next major).
Acceptance
- Run
ng generate @angular/core:injectin a dedicated PR (not the release PR) - Manually reconcile the
BaseDirective2hierarchy /super()calls - Decide & document the public abstract base handling (backwards-compat vs. breaking)
- Full test suite green (currently 468 tests) to confirm no behavior change
🤖 Generated with Claude Code
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Read core/base/base2.ts and core/public-api.ts, then inspect the 23 directives and the core, flex, extended, grid, and server entry points before running the Angular inject schematic. Done means reconciling every super() call, deciding and documenting compatibility for the public abstract base, and keeping the full 468-test suite green.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- angular, typescript
- Domain
- api, frontend
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100