Repository navigation
fix(compiler): check ctor param decorators (arity + unexpected) like di.ts - #551
Merged
Merged
Conversation
…di.ts ngtsc's getConstructorDependencies rejects @Inject()/@Attribute() with other than one argument (DECORATOR_ARITY_WRONG) and any other @angular/core decorator on a ctor parameter (DECORATOR_UNEXPECTED), for every class a DI handler compiles. Add param_decorator_errors, reported after the io/query checks — getConstructorDependencies sits last inside extractDirectiveMetadata.
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
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.
Summary
Adds
param_decorator_errorsindirective/decorator.rs, mirroring ngtsc'sgetConstructorDependencies(di.ts):@Inject()/@Attribute()with anything but exactly one argument →Unexpected number of arguments to @Inject()./@Attribute().(DECORATOR_ARITY_WRONG)@angular/coredecorator on a constructor parameter →Unexpected decorator {name} on parameter.(DECORATOR_UNEXPECTED)dec.import.namesemantics); foreign decorators and non-ctor params are ignored.Wired into the class dispatch in
component/transform.rsafterdecorator_io_errors, suppressed when an io/query error already fired —getConstructorDependenciesruns last insideextractDirectiveMetadata, and upstream throws on first error. Applies to every DI-compiled class kind (@Component,@Directive,@Pipe,@NgModule,@Injectable), matching the handlers that all callgetValidConstructorDependencies.@Injectable()on a ctor param now reportsUnexpected decorator Injectable on parameter.— the pre-existingtest_class_metadata_lists_any_angular_core_decoratorwas updated to expect it (its own comment already acknowledged upstream rejects this shape).Test plan
cargo test -p oxc_angular_compiler— 41 binaries green.test_param_decorator_arity_is_diagnostic(7 cases incl. bare@Inject, aliases,@Attribute),test_param_decorator_checks_respect_import_and_kind(foreign decorators,core.Inject(), non-ctor params, undecorated classes).Fixes #550