Skip to content

Plugin Tasks issue with response payload type inference #447

@elribonazo

Description

@elribonazo

Is this a regression?

Yes

Description

The tasks that use Payload.make, return a standard and Payload with data as any.
Instead of doing that, we need to be able to extract the type from whatever the user's entered as output and let typescript extract the type properly.

Before

export interface Payload {
  // Payload IDentifier
  pid: string;
  // any value
  data: any;
}

export namespace Payload {
  export const make = (pid: string, data: any): Payload => ({ pid, data });
}

After

export interface Payload<T> {
  // Payload IDentifier
  pid: string;
  // any value
  data: T;
}

export namespace Payload {
  export const make = <T>(pid: string, data: T): Payload<T> => ({ pid, data });
}

Now we know what type to expect from any plugin.task that we run

Please provide the exception or error you saw


Please provide the environment you discovered this bug in


Anything else?

No response

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions