Created
July 20, 2022 04:52
-
-
Save susanahernandezd/b45049465c212c404b2a5e7fa50d0e13 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//--CASE 1 | |
const person = { | |
name: 'Tom', | |
age: 30, | |
country: 'Chile', | |
}; | |
// 👇️ type Keys = "name" | "age" | "country" | |
type Keys = keyof typeof person; | |
// 👇️ type Values = string | number | |
type Values = typeof person[Keys]; | |
//--CASE 2 | |
type Person = { | |
name: string; | |
age: number; | |
country: string; | |
}; | |
// 👇️ type Keys = "name" | "age" | "country" | |
type Keys = keyof Person; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment