I have this:
interface Obj {
foo: string,
bar: number,
baz: boolean
}
The desired type is this tuple:
[string, number, boolean]
How can I convert the interface to the tuple?
Update:
My original problem is: I make some opinionated library with a declarative spirit, where a user should describe parameters of a function in an object literal. Like this:
let paramsDeclaration = {
param1: {
value: REQUIRED<string>(),
shape: (v) => typeof v === 'string' && v.length < 10
},
param2: {
value: OPTIONAL<number>(),
...
},
}
Then the library takes this object and creates a function with parameters from it:
(param1: string, param2?: number) => ...
So, making such function is not a problem, the problem is to correctly type it, so that user gets good code-completion (IntelliSense).
P.S. I know it's not solvable, but it would be interesting to know what is the closest possible workaround/hack.