Within my code, I have a function that offers different results based on specified options. These options dictate the type of return value. The function is currently written in plain JavaScript and I am looking to provide it with types using an index.d.ts file.
Let's explore some sample calls along with their corresponding outcomes:
func(): Results
func({key: 'str'}): DifferentResults
func({keys: ['a', 'b']}): EvenMoredifferentResults
I am wondering how I can define these different scenarios within the index.d.ts file. It is also important to note that key
and keys
should be mutually exclusive.