Fooling around with typescript

This commit is contained in:
Dan Buch 2019-11-06 11:37:16 -05:00
parent d0911e7039
commit d6fb2dd11c
Signed by: meatballhat
GPG Key ID: 9685130D8B763EA7
5 changed files with 52 additions and 0 deletions

1
tsfun/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
node_modules/

14
tsfun/greeter.js Normal file
View File

@ -0,0 +1,14 @@
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");
console.log(greeter(user));

23
tsfun/greeter.ts Normal file
View File

@ -0,0 +1,23 @@
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");
console.log(greeter(user));

6
tsfun/package.json Normal file
View File

@ -0,0 +1,6 @@
{
"devDependencies": {
"typescript": "^3.7.2"
},
"license": "MIT"
}

8
tsfun/yarn.lock Normal file
View File

@ -0,0 +1,8 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1
typescript@^3.7.2:
version "3.7.2"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.7.2.tgz#27e489b95fa5909445e9fef5ee48d81697ad18fb"
integrity sha512-ml7V7JfiN2Xwvcer+XAf2csGO1bPBdRbFCkYBczNZggrBZ9c7G3riSUeJmqEU5uOtXNPMhE3n+R4FA/3YOAWOQ==