Repository navigation
Conversation
An `@Injectable` `deps` entry like `[new Optional(), new Self(), Dep]` was passed whole as the DI token. Port ngtsc's `getDep`: `Inject`, `Optional`, `SkipSelf` and `Self` from `@angular/core` set the flags (or the token, for `new Inject(T)`), and any other element is the token. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #629.
Problem
An
@Injectable({ useFactory | useClass, deps })entry written as flags plus a token, such as[new Optional(), new Self(), Dep], was converted to a token as a whole. The output wasɵɵinject([new Optional(), new Self(), Dep]), which fails at runtime. ngc emitsɵɵinject(Dep, 10).Fix
extract_dependency(injectable/decorator.rs) now ports ngtsc'sgetDep(packages/compiler-cli/src/ngtsc/annotations/src/injectable.ts). For an array entry, each element is read in turn:Optional,SelforSkipSelf, bare or asnew X(), sets that flag.new Inject(T)sets the token toT.Like ngtsc, a flag only counts when the identifier is imported from
@angular/core(under any alias). To check this, the file'sconstsare passed down to theuseClass/useFactorydeps extraction. That import check moved out ofangular_core_decoratorinto a new helper,angular_core_identifier, which both now use. LikegetDep,HostandAttributeare not handled indepsarrays.Checks
tests/injectable_provider_deps_test.rs:use_factory_deps_with_array_literal_tokens: port of the ngtsc spec "should compile Injectables with providedIn and factory with deps with array literal tokens".use_class_deps_with_bare_flag_identifiersinject_entry_sets_the_tokenflags_not_imported_from_angular_core_are_tokensmainand pass with this change.cargo test -p oxc_angular_compiler --all-features: 3520 passed, 0 failed, 1 ignored.🤖 Generated with Claude Code