Skip to content

Instantly share code, notes, and snippets.

@rahulbanerjee26
Created January 12, 2022 19:55
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/c3ea411e9cf6aa0ead55b6943f4580ef to your computer and use it in GitHub Desktop.
Save rahulbanerjee26/c3ea411e9cf6aa0ead55b6943f4580ef to your computer and use it in GitHub Desktop.
//Declaring object with no types
let user = {
id: 10,
name: 'Rahul',
email: 'a@g.com'
}
console.log(user.name)
// Rahul
console.log(user.email)
// a@g.com
console.log(user.number)
// error TS2339: Property 'number' does not exist on type '{ id: number; name: string; email: string; }'
user.age = 20
// 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