Created
January 12, 2022 20:02
-
-
Save rahulbanerjee26/1d75e5a710aedce2f55294bce78fa4ad 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
// 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