Skip to content

Commit 80ccd6c

Browse files
alan-agius4alxhub
authored andcommittedJul 1, 2019
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 to https://github.com/angular/angular/blob/c6b29f4c6d23b1510db3434cb030203d5bdea119/packages/core/src/di/injector_compatibility.ts#L162 and will crash https://github.com/angular/angular/blob/c6b29f4c6d23b1510db3434cb030203d5bdea119/packages/core/src/di/injector_compatibility.ts#L174-L186 Fixes angular/angular-cli#14888 PR Close #31333
·
8.1.38.1.0
1 parent b7e3d80 commit 80ccd6c

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed
 

‎packages/core/src/reflection/reflection_capabilities.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ export class ReflectionCapabilities implements PlatformReflectionCapabilities {
6464
// migration, but this can be revisited.
6565
if (typeof paramTypes === 'undefined') {
6666
result[i] = [];
67-
} else if (paramTypes[i] != Object) {
67+
} else if (paramTypes[i] && paramTypes[i] != Object) {
6868
result[i] = [paramTypes[i]];
6969
} else {
7070
result[i] = [];

‎packages/core/test/reflection/reflector_spec.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,16 @@ class TestObj {
109109
class ForwardDep {}
110110
expect(reflector.parameters(Forward)).toEqual([[ForwardDep]]);
111111
});
112+
113+
it('should not return undefined types for downleveled types', () => {
114+
class Dep {}
115+
116+
class TestService {
117+
constructor() {}
118+
static ctorParameters = () => [{type: undefined, decorators: []}, {type: Dep}];
119+
}
120+
expect(reflector.parameters(TestService)).toEqual([[], [Dep]]);
121+
});
112122
});
113123

114124
describe('propMetadata', () => {

0 commit comments

Comments
 (0)
Please sign in to comment.