There is a specific type with its own unique property (method)
type Functions = {
method: "connect",
request: number,
response: number,
} | {
method: "remove",
request: string,
response: string,
}
I aim to create a function that can handle input and output values of the specified type based on the distinct field.
type Func = <T extends Functions>(input: Pick<T, 'method' | 'request'>) => Pick<T, 'method' | 'response'>;
However, when I use this implementation, for example:
const result = func({ method: "connect", request: 10 })
result.response
The resulting type for the response field shows as:
string || number
Is there a way to refine the type without additional verification of the method property? (Possibly by altering the Func type)