Skip to content

Convert a schema (@sinclair/typebox) that is in a decorator to type #1024

Answered by L2jLiga
RealDragonMA asked this question in Q&A
Discussion options

You must be logged in to vote

Hi there, if I understand correctly - what are you asking for is currently not possible with typescript because decorators are unable to change method signature somehow
Please check this issue and let us know if it what are you asking for

microsoft/TypeScript#49229


P.S. it could be possible to simplify things a bit if you are using request handlers. Abstract class RequestHandler was designed just to avoid misusage, you are free to define your own constructor and play with types, for example:

@GET()
export class MyRequestHandler {
  constructor(private request: FastifyRequest<BodyType>, private reply: FastifyReply) {}

  async handle() {}
}

Replies: 2 comments 2 replies

Comment options

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

Comment options

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

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