Skip to content

Typings for custom properties in AsyncHook Context #2083

Answered by Romakita
NachtRitter asked this question in Q&A
Discussion options

You must be logged in to vote

Hello @NachtRitter
You shouldn't do that :)

this exemple is wrong:

import { PlatformContext, Service } from '@tsed/common`;
import { InjectContext } from '@tsed/di';

@Service()
export class MyFooBarService {
  @InjectContext()
  context: PlatformContext;

  myMethod() {
    const bar = this.context.foo.bar();
  }
}

It should be:

import { PlatformContext, Service } from '@tsed/common`;
import { InjectContext } from '@tsed/di';

@Service()
export class MyFooBarService {
  @InjectContext()
  context: PlatformContext;

  myMethod() {
    const bar = this.context.get<MyFooBar>('foo').bar();
  }
}

Maybe my example answer you ;)

See you
Romain

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@NachtRitter
Comment options

Answer selected by NachtRitter
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants