Octal!
Octal!11mo 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
AapoAlas11mo ago
Object.entries
Octal!
Octal!11mo 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!11mo 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!11mo ago
{owo: string, uwu: number} -> {owo: ["owo", string], uwu: ["uwu", number]} -> [["owo", string], ["uwu", number]] -> {owo: string, uwu: undefined} | {owo: undefined, uwu: number}