Currently, I am developing an API that utilizes tuples and I'm working on inferring the function arguments within these tuples.
To make things easier to understand, I have created a simple example showcasing what I am attempting to accomplish.
type InitializeType = ['initialize', (arg: string) => void]
type TerminateType = ['terminate', (arg: number) => void]
type RetrieveType = ['retrieve', () => void]
type ExpectedOutput = InitializeType | TerminateType | RetrieveType
// Expecting argument to be a string
const sampleTest: ExpectedOutput = ['initialize', (arg) => {
console.log(arg)
}]
// Expecting argument to be a number?
const sampleTest1: ExpectedOutput = ['terminate', (arg) => {
console.log(arg)
}]
// This is validated though..
const sampleTest2: ExpectedOutput = ['retrieve', () => {
console.log(arg)
}]