Skip to content

fix: setClassMetadata ctor params use namespace-prefixed types for imported deps#9

Merged
Brooooooklyn merged 1 commit into
mainfrom
02-04-fix_setclassmetadata_namespace_imports
Feb 4, 2026
Merged

fix: setClassMetadata ctor params use namespace-prefixed types for imported deps#9
Brooooooklyn merged 1 commit into
mainfrom
02-04-fix_setclassmetadata_namespace_imports

Conversation

@Brooooooklyn
Copy link
Copy Markdown
Member

@Brooooooklyn Brooooooklyn commented Feb 4, 2026

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 setClassMetadata ctor 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 @Inject edge cases.

Overview
build_ctor_params_metadata now accepts constructor dependency metadata plus a NamespaceRegistry and emits namespace-prefixed type references 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, exports NamespaceRegistry from 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., DOCUMENT vs Document).

Written by Cursor Bugbot for commit efe376a. This will update automatically on new commits. Configure here.

…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>
@Brooooooklyn Brooooooklyn merged commit 9e2d565 into main Feb 4, 2026
3 checks passed
@Brooooooklyn Brooooooklyn deleted the 02-04-fix_setclassmetadata_namespace_imports branch February 4, 2026 10:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant