Repository navigation
Conversation
…verload Like ngtsc's TypeScriptReflectionHost.getConstructorParameters, factories, setClassMetadata, JIT ctorParameters and param-decorator removal now use the constructor with a body, so overload signatures no longer drop dependencies. 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 #630.
Problem
With constructor overloads, every constructor lookup took the first
constructormember, which is an overload signature. The factory then injected only that signature's parameters, so the implementation's extra dependencies wereundefinedat runtime.setClassMetadata's ctor params were wrong in the same way. The implementation's@Optional()was never compiled, so it stayed in the output and a downstream TS transform lowered it to__param. This applies to@Injectable,@Component,@Directive,@Pipeand@NgModule, and to JITctorParameters.Fix
A new helper,
util::find_constructor, returns the constructor that has a body. This mirrors ngtsc'sTypeScriptReflectionHost.getConstructorParameters(packages/compiler-cli/src/ngtsc/reflection/src/typescript.ts) for non-declaration files, and the JITdownlevel_decorators_transform.ts, which skips constructors without a body. These lookups now use it:extract_constructor_deps)setClassMetadatactor params (build_ctor_params_metadata) and the import-elision pass that mirrors their typesfor_each_constructor_param_decorator)ctorParameters, the own-ctor-params check and the param identifiers it keeps imports forChecks
ctor_overloads_test.rsis new and ports the ngtsc_spec case "should compile @Injectable with constructor overloads". It covers the factory for all five decorator kinds,setClassMetadatactor params, removal of the parameter decorator, and JITctorParameters. All three tests fail onmain.cargo test -p oxc_angular_compiler --all-features: 3519 passed, 0 failed.cargo fmt --checkpasses.cargo clippy -p oxc_angular_compiler --all-featuresreports no warnings on the changed lines.🤖 Generated with Claude Code