fix(core): handle `undefined` meta in `injectArgs` (#31333)
In the recent versions of the CLI we introduced a ctor downleveler tranformer for VE JIT builds based on the one found in tsickle, to fix the TDZ issue of `forwardRef`. However this caused a regression as the injector is not handling that a position `paramType` can be undefined. Which is bubbled down toc6b29f4c6d/packages/core/src/di/injector_compatibility.ts (L162)
and will crashc6b29f4c6d/packages/core/src/di/injector_compatibility.ts (L174-L186)
Fixes https://github.com/angular/angular-cli/issues/14888 PR Close #31333
This commit is contained in:
parent
dd36f3ac99
commit
f83dfd6f5a
|
@ -64,7 +64,7 @@ export class ReflectionCapabilities implements PlatformReflectionCapabilities {
|
||||||
// migration, but this can be revisited.
|
// migration, but this can be revisited.
|
||||||
if (typeof paramTypes === 'undefined') {
|
if (typeof paramTypes === 'undefined') {
|
||||||
result[i] = [];
|
result[i] = [];
|
||||||
} else if (paramTypes[i] != Object) {
|
} else if (paramTypes[i] && paramTypes[i] != Object) {
|
||||||
result[i] = [paramTypes[i]];
|
result[i] = [paramTypes[i]];
|
||||||
} else {
|
} else {
|
||||||
result[i] = [];
|
result[i] = [];
|
||||||
|
|
|
@ -109,6 +109,16 @@ class TestObj {
|
||||||
class ForwardDep {}
|
class ForwardDep {}
|
||||||
expect(reflector.parameters(Forward)).toEqual([[ForwardDep]]);
|
expect(reflector.parameters(Forward)).toEqual([[ForwardDep]]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should not return undefined types for downleveled types', () => {
|
||||||
|
class Dep {}
|
||||||
|
|
||||||
|
class TestService {
|
||||||
|
constructor() {}
|
||||||
|
static ctorParameters = () => [{type: undefined, decorators: []}, {type: Dep}];
|
||||||
|
}
|
||||||
|
expect(reflector.parameters(TestService)).toEqual([[], [Dep]]);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('propMetadata', () => {
|
describe('propMetadata', () => {
|
||||||
|
|
Loading…
Reference in New Issue