Skip to content

Instantly share code, notes, and snippets.

@rahulbanerjee26
Created January 12, 2022 20:02
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/1d75e5a710aedce2f55294bce78fa4ad to your computer and use it in GitHub Desktop.
Save rahulbanerjee26/1d75e5a710aedce2f55294bce78fa4ad to your computer and use it in GitHub Desktop.
// Declaring object with custom type
let user:{id:number,name:string,email:string} = {
id:10,
name:'Rahul',
email:'a@g.com'
}
console.log(user.id)
// 10
console.log(user.number)
// error TS2339: Property 'number' does not exist on type '{ id: number; name: string; email: string; }'.
user.age = 10
console.log(user.age)
// error TS2339: Property 'age' does not exist on type '{ id: number; name: string; email: string; }'.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment