Skip to content

Instantly share code, notes, and snippets.

@rahulbanerjee26
Created January 12, 2022 20:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rahulbanerjee26/8d915b9289132dc9be8d8f3e4952c8b1 to your computer and use it in GitHub Desktop.
Save rahulbanerjee26/8d915b9289132dc9be8d8f3e4952c8b1 to your computer and use it in GitHub Desktop.
// Declaring object with type Record<string,string>
let user:Record<string,string>={
name: 'Rahul',
email: 'a@g.com'
}
console.log(user.name)
// Rahul
console.log(user.number)
// undefined
user.age = 22
console.log(user.age)
// error TS2322: Type 'number' is not assignable to type 'string'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment