fix: setClassMetadata ctor params use namespace-prefixed types for imported deps#9
Merged
Conversation
…ported deps Constructor parameter types in ɵsetClassMetadata were using bare names (e.g., SomeService) instead of namespace-prefixed references (e.g., i1.SomeService) for imported types. TypeScript erases type annotations at runtime, so imported types need namespace imports to remain available. The fix passes constructor dependency metadata and the namespace registry into build_ctor_params_metadata, and adds build_param_type_expression which uses namespace prefixes when the type annotation name matches the dep token name and the dep has a source module. When they differ (e.g., @Inject(DOCUMENT) doc: Document), falls back to bare name. Co-Authored-By: Claude Opus 4.5 <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.
Constructor parameter types in ɵsetClassMetadata were using bare names (e.g., SomeService) instead of namespace-prefixed references (e.g., i1.SomeService) for imported types. TypeScript erases type annotations at runtime, so imported types need namespace imports to remain available.
The fix passes constructor dependency metadata and the namespace registry into build_ctor_params_metadata, and adds build_param_type_expression which uses namespace prefixes when the type annotation name matches the dep token name and the dep has a source module. When they differ (e.g., @Inject(DOCUMENT) doc: Document), falls back to bare name.
Note
Medium Risk
Changes codegen for
setClassMetadatactor parameter metadata and relies on constructor dependency metadata/namespace assignment, which could affect emitted JS and import generation. Scope is limited and covered by new integration tests for common@Injectedge cases.Overview
build_ctor_params_metadatanow accepts constructor dependency metadata plus aNamespaceRegistryand emits namespace-prefixedtypereferences for imported constructor param types (e.g.,i1.SomeService) to match Angular when TS types are erased at runtime.The transform pipeline now passes
constructor_deps/registry into class metadata emission, exportsNamespaceRegistryfrom the crate API, and updates the NAPI class-metadata helper to provide a registry (without deps, so it won’t prefix in that standalone path). New integration tests assert correct prefixing, including@Inject(SomeService)and a fallback when the inject token differs from the type (e.g.,DOCUMENTvsDocument).Written by Cursor Bugbot for commit efe376a. This will update automatically on new commits. Configure here.