Skip to content

Instantly share code, notes, and snippets.

@clemderome
Last active November 11, 2020 20:29
Show Gist options
  • Save clemderome/ff7ad7e5dfc08ff49cd652af0bf371e0 to your computer and use it in GitHub Desktop.
Save clemderome/ff7ad7e5dfc08ff49cd652af0bf371e0 to your computer and use it in GitHub Desktop.
TypeScript Basics
// Typage proposé par typescript:
// users: any[]
interface User {
name: string;
age?: number;
birthday?: string;
}
const prettyPrintWilder = (users: User[]): void => {
console.log("########################");
users.map((el) => {
console.log(`${el.name} is ${el.age} years old`);
});
console.log("########################");
};
const wilders = [];
const user1 = { name: "Pierre", age: 23 };
const user2 = { name: "Paul", birthday: "10/02/1990" };
const user3 = { name: "Jacques", age: 25 };
wilders.push(user1);
wilders.push(user2);
wilders.push(user3);
prettyPrintWilder(wilders);
console.log(wilders)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment