Skip to content

Instantly share code, notes, and snippets.

@elvisciotti
Last active March 6, 2019 12:57
Show Gist options
  • Save elvisciotti/639c44a39a89db2fec0f5e3c9ec17548 to your computer and use it in GitHub Desktop.
Save elvisciotti/639c44a39a89db2fec0f5e3c9ec17548 to your computer and use it in GitHub Desktop.
typscript class and interface compile example
class Student {
fullName: string;
constructor(public firstName: string, public middleInitial: string, public lastName: string) {
this.fullName = firstName + " " + middleInitial + " " + lastName;
}
}
interface Person {
firstName: string;
lastName: string;
}
function greeter(person : Person) {
return "Hello, " + person.firstName + " " + person.lastName;
}
let user = new Student("Jane", "M.", "User");
document.body.innerHTML = greeter(user);
var Student = /** @class */ (function () {
function Student(firstName, middleInitial, lastName) {
this.firstName = firstName;
this.middleInitial = middleInitial;
this.lastName = lastName;
this.fullName = firstName + " " + middleInitial + " " + lastName;
}
return Student;
}());
function greeter(person) {
return "Hello, " + person.firstName + " " + person.lastName;
}
var user = new Student("Jane", "M.", "User");
document.body.innerHTML = greeter(user);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment