Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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