Changelog - 2026-10-18
Injecting a class that shares its name with the bound one is an error
Bug FixIn one line. Two classes with one name derive one key, so @inject({ target: LibraryClass }) silently received the registered class; now it fails loudly.
What changed
- The bound class is checked. When
@inject({ target: X })resolves a key bound withtoClass(C),Cmust beXor a subclass ofX. Otherwise resolution throws... names 'X', but '<key>' is bound to a different class named 'X' | Two classes share one name and so one key - rename one, re-export the registered one, or inject by key. A value or provider binding is not checked. - A subclass override still resolves. Binding
OverrideStoreunderBaseStore's key and injectingBaseStoreworks as before.
Who is affected
- Applications with two decorated classes of one name (a library's own copy of a class the application registers). They used to get the registered class without a word; now boot (with
bootChecks.binding.doVerify) or the first resolution names the clash. Keep one class - a re-export of the registered one - or rename the other. - Everyone else. No change.
Files: packages/inversion/src/modules/container/container.ts