Skip to content

Commit

Permalink
fix(context): allow inject to be explicitly invoked for class ctor …
Browse files Browse the repository at this point in the history
…args

Signed-off-by: Miroslav Bajtoš <mbajtoss@gmail.com>
  • Loading branch information
bajtos committed Sep 5, 2019
1 parent 06d0967 commit 6a0d4f2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 10 additions & 0 deletions packages/context/src/__tests__/unit/inject.unit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,16 @@ describe('function argument injection', () => {
expect(meta.map(m => m.bindingSelector)).to.deepEqual(['foo']);
});

it('allows decorator to be explicitly invoked for class ctor args', () => {
class TestClass {
constructor(foo: string) {}
}
inject('foo')(TestClass, undefined, 0);

const meta = describeInjectedArguments(TestClass);
expect(meta.map(m => m.bindingSelector)).to.deepEqual(['foo']);
});

it('can retrieve information about injected method arguments', () => {
class TestClass {
test(@inject('foo') foo: string) {}
Expand Down
2 changes: 1 addition & 1 deletion packages/context/src/inject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export function inject(
}
return function markParameterOrPropertyAsInjected(
target: Object,
member: string,
member: string | undefined,
methodDescriptorOrParameterIndex?:
| TypedPropertyDescriptor<BoundValue>
| number,
Expand Down

0 comments on commit 6a0d4f2

Please sign in to comment.