Typescript doesn't provide types to argument generics

Viewed 32

I need to describe such a signature so that all types of arguments(before options) are provide into generic of the last argument. Now it looks like this:

public error<Messages extends any[], FormatReturn>(
  ...messages: [...Messages, LoggerOptions<Messages, FormatReturn>]
): void;

In the signature of the method itself, you can see that the types are provided

enter image description here

But in the parameter of the LoggerOptions themselves the type is unknown

enter image description here

At the same time, if you change the signature a little and explicitly provide the type, then everything works:

public error<Messages extends any[], FormatReturn>(
  options: LoggerOptions<string | number, FormatReturn>,
  ...messages: Messages
): void;

enter image description here

0 Answers
Related