// Object type ******************************
type objectType = {
name: String;
city: String;
email: String;
isLoading: Boolean;
age: Number;
};
const Person: objectType = {
name: 'Saten Chauhan',
city: 'Kanpur',
email: 'saten@demo.com',
isLoading: true,
age: 35,
};
console.log(Person.name);
//Example==================
const person: {
name: string;
mobile: number;
job: string;
address: {
city: string;
state: string;
country: string;
};
} = {
name: 'saten',
mobile: 92343243223,
job: 'React Native Developer',
address: {
city: 'Kanpur',
state: 'UP',
country: 'India',
},
};
type User = {
name: string;
mobile: number;
job: string;
address: {
city: string;
state: string;
country: string;
};
};
const user: User = {
name: 'saten',
mobile: 92343243223,
job: 'React Native Developer',
address: {
city: 'Kanpur',
state: 'UP',
country: 'India',
},
};
person.mobile = 99888453453400;
// user.mobile = 46565656;
// console.log(user.mobile);
type Student = {
name: string;
age: number;
gender?: string;
greet: (country: string) => string; // Call Signature
};
const student1: Student = {
name: 'saten',
age: 36,
greet: (country): string =>
`I am ${student1.name}, and I am ${student1.age} years old, from ${country}`,
};
/* const show: (student1: Student) => string = (student1: Student): string => {
const { name, age } = student1;
return `I am ${name} and ${age} old`;
}; */
console.log(student1.greet('India'));