Octal!
Octal!2y ago

Object to tuple of tuple of keys and type?

Example:
type SomeType = {
owo: string
uwu: number
}
type SomeType = {
owo: string
uwu: number
}
Into
type SomeType = [
["owo", string],
["uwu", number]
]
type SomeType = [
["owo", string],
["uwu", number]
]
4 Replies
AapoAlas
AapoAlas2y ago
Object.entries
Octal!
Octal!OP2y ago
I wanna do it on the type level Aha I figured it out I converted the object to and object of it's keys to a tuple of the current key and it's type, then converted it to a tuple of it's types
Octal!
Octal!OP2y ago
(picture of my screen because I'm waiting on a new router) It's formatted in such a way that a rust serde serialized enum will match the type
Octal!
Octal!OP2y ago
{owo: string, uwu: number} -> {owo: ["owo", string], uwu: ["uwu", number]} -> [["owo", string], ["uwu", number]] -> {owo: string, uwu: undefined} | {owo: undefined, uwu: number}

Did you find this page helpful?