fix(core): support computed base class in metadata inheritance (#24014)

PR Close #24014
This commit is contained in:
Trotyl 2018-05-20 19:32:15 +08:00 committed by Matias Niemelä
parent 9ad54d74d2
commit 95743e3a64
2 changed files with 8 additions and 2 deletions

View File

@ -18,9 +18,9 @@ import {GetterFn, MethodFn, SetterFn} from './types';
* Attention: These regex has to hold even if the code is minified!
*/
export const DELEGATE_CTOR = /^function\s+\S+\(\)\s*{[\s\S]+\.apply\(this,\s*arguments\)/;
export const INHERITED_CLASS = /^class\s+[A-Za-z\d$_]*\s*extends\s+[A-Za-z\d$_]+\s*{/;
export const INHERITED_CLASS = /^class\s+[A-Za-z\d$_]*\s*extends\s+[^{]+{/;
export const INHERITED_CLASS_WITH_CTOR =
/^class\s+[A-Za-z\d$_]*\s*extends\s+[A-Za-z\d$_]+\s*{[\s\S]*constructor\s*\(/;
/^class\s+[A-Za-z\d$_]*\s*extends\s+[^{]+{[\s\S]*constructor\s*\(/;
export class ReflectionCapabilities implements PlatformReflectionCapabilities {
private _reflect: any;

View File

@ -194,6 +194,10 @@ class TestObj {
const ChildWithCtor = `class ChildWithCtor extends Parent {\n` +
` constructor() { super(); }` +
`}\n`;
const ChildNoCtorComplexBase = `class ChildNoCtor extends Parent['foo'].bar(baz) {}\n`;
const ChildWithCtorComplexBase = `class ChildWithCtor extends Parent['foo'].bar(baz) {\n` +
` constructor() { super(); }` +
`}\n`;
const ChildNoCtorPrivateProps = `class ChildNoCtorPrivateProps extends Parent {\n` +
` private x = 10;\n` +
`}\n`;
@ -204,6 +208,8 @@ class TestObj {
expect(checkNoOwnMetadata(ChildNoCtor)).toBeTruthy();
expect(checkNoOwnMetadata(ChildNoCtorPrivateProps)).toBeTruthy();
expect(checkNoOwnMetadata(ChildWithCtor)).toBeFalsy();
expect(checkNoOwnMetadata(ChildNoCtorComplexBase)).toBeTruthy();
expect(checkNoOwnMetadata(ChildWithCtorComplexBase)).toBeFalsy();
});
it('should properly handle all class forms', () => {