fix(compiler): ignore errors when evaluating base classes (#15560)
Fixes #15536
This commit is contained in:
parent
8e03f65645
commit
d438b88f19
|
@ -118,7 +118,7 @@ export class StaticReflector implements ɵReflectorReader {
|
||||||
const classMetadata = this.getTypeMetadata(type);
|
const classMetadata = this.getTypeMetadata(type);
|
||||||
propMetadata = {};
|
propMetadata = {};
|
||||||
if (classMetadata['extends']) {
|
if (classMetadata['extends']) {
|
||||||
const parentType = this.simplify(type, classMetadata['extends']);
|
const parentType = this.trySimplify(type, classMetadata['extends']);
|
||||||
if (parentType instanceof StaticSymbol) {
|
if (parentType instanceof StaticSymbol) {
|
||||||
const parentPropMetadata = this.propMetadata(parentType);
|
const parentPropMetadata = this.propMetadata(parentType);
|
||||||
Object.keys(parentPropMetadata).forEach((parentProp) => {
|
Object.keys(parentPropMetadata).forEach((parentProp) => {
|
||||||
|
@ -176,7 +176,7 @@ export class StaticReflector implements ɵReflectorReader {
|
||||||
parameters.push(nestedResult);
|
parameters.push(nestedResult);
|
||||||
});
|
});
|
||||||
} else if (classMetadata['extends']) {
|
} else if (classMetadata['extends']) {
|
||||||
const parentType = this.simplify(type, classMetadata['extends']);
|
const parentType = this.trySimplify(type, classMetadata['extends']);
|
||||||
if (parentType instanceof StaticSymbol) {
|
if (parentType instanceof StaticSymbol) {
|
||||||
parameters = this.parameters(parentType);
|
parameters = this.parameters(parentType);
|
||||||
}
|
}
|
||||||
|
@ -199,7 +199,7 @@ export class StaticReflector implements ɵReflectorReader {
|
||||||
const classMetadata = this.getTypeMetadata(type);
|
const classMetadata = this.getTypeMetadata(type);
|
||||||
methodNames = {};
|
methodNames = {};
|
||||||
if (classMetadata['extends']) {
|
if (classMetadata['extends']) {
|
||||||
const parentType = this.simplify(type, classMetadata['extends']);
|
const parentType = this.trySimplify(type, classMetadata['extends']);
|
||||||
if (parentType instanceof StaticSymbol) {
|
if (parentType instanceof StaticSymbol) {
|
||||||
const parentMethodNames = this._methodNames(parentType);
|
const parentMethodNames = this._methodNames(parentType);
|
||||||
Object.keys(parentMethodNames).forEach((parentProp) => {
|
Object.keys(parentMethodNames).forEach((parentProp) => {
|
||||||
|
|
|
@ -495,6 +495,31 @@ describe('StaticReflector', () => {
|
||||||
expect(() => reflector.propMetadata(appComponent)).not.toThrow();
|
expect(() => reflector.propMetadata(appComponent)).not.toThrow();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should not throw with an invalid extends', () => {
|
||||||
|
const data = Object.create(DEFAULT_TEST_DATA);
|
||||||
|
const file = '/tmp/src/invalid-component.ts';
|
||||||
|
data[file] = `
|
||||||
|
import {Component} from '@angular/core';
|
||||||
|
|
||||||
|
function InvalidParent() {
|
||||||
|
return InvalidParent;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'tmp',
|
||||||
|
template: '',
|
||||||
|
})
|
||||||
|
export class BadComponent extends InvalidParent() {
|
||||||
|
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
init(data);
|
||||||
|
const badComponent = reflector.getStaticSymbol(file, 'BadComponent');
|
||||||
|
expect(reflector.propMetadata(badComponent)).toEqual({});
|
||||||
|
expect(reflector.parameters(badComponent)).toEqual([]);
|
||||||
|
expect(reflector.hasLifecycleHook(badComponent, 'onDestroy')).toEqual(false);
|
||||||
|
});
|
||||||
|
|
||||||
it('should produce a annotation even if it contains errors', () => {
|
it('should produce a annotation even if it contains errors', () => {
|
||||||
const data = Object.create(DEFAULT_TEST_DATA);
|
const data = Object.create(DEFAULT_TEST_DATA);
|
||||||
const file = '/tmp/src/invalid-component.ts';
|
const file = '/tmp/src/invalid-component.ts';
|
||||||
|
|
Loading…
Reference in New Issue