Skip to content

Commit

Permalink
fix(core): support computed base class in metadata inheritance (angul…
Browse files Browse the repository at this point in the history
  • Loading branch information
trotyl authored and sculove committed Nov 2, 2018
1 parent 0130408 commit 58add0a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/core/src/reflection/reflection_capabilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 6 additions & 0 deletions packages/core/test/reflection/reflector_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`;
Expand All @@ -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', () => {
Expand Down

0 comments on commit 58add0a

Please sign in to comment.