Thanks to visit codestin.com
Credit goes to github.com

Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/core/src/reflection/reflection_capabilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ 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+[^{]+{[\s\S]*constructor\s*\(/;
export const INHERITED_CLASS_WITH_DELEGATE_CTOR =
/^class\s+[A-Za-z\d$_]*\s*extends\s+[^{]+{[\s\S]*constructor\s*\(\)\s*{\s+super\(\.\.\.arguments\)/;
/^class\s+[A-Za-z\d$_]*\s*extends\s+[^{]+{[\s\S]*constructor\s*\(\)\s*{\s*super\(\.\.\.arguments\)/;

/**
* Determine whether a stringified type is a class which delegates its constructor
Expand Down
12 changes: 12 additions & 0 deletions packages/core/test/reflection/reflector_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,18 @@ class TestObj {
expect(isDelegateCtor(ChildWithCtor.toString())).toBe(false);
});

it('should support ES2015 classes when minified', () => {
// These classes are ES2015 in minified form
const ChildNoCtorMinified = 'class ChildNoCtor extends Parent{}';
const ChildWithCtorMinified = 'class ChildWithCtor extends Parent{constructor(){super()}}';
const ChildNoCtorPrivatePropsMinified =
'class ChildNoCtorPrivateProps extends Parent{constructor(){super(...arguments);this.x=10}}';

expect(isDelegateCtor(ChildNoCtorMinified)).toBe(true);
expect(isDelegateCtor(ChildNoCtorPrivatePropsMinified)).toBe(true);
expect(isDelegateCtor(ChildWithCtorMinified)).toBe(false);
});

it('should not throw when no prototype on type', () => {
// Cannot test arrow function here due to the compilation
const dummyArrowFn = function() {};
Expand Down