Fooling around with typescript
This commit is contained in:
parent
d0911e7039
commit
d6fb2dd11c
1
tsfun/.gitignore
vendored
Normal file
1
tsfun/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
node_modules/
|
14
tsfun/greeter.js
Normal file
14
tsfun/greeter.js
Normal 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
23
tsfun/greeter.ts
Normal 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
6
tsfun/package.json
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"devDependencies": {
|
||||
"typescript": "^3.7.2"
|
||||
},
|
||||
"license": "MIT"
|
||||
}
|
8
tsfun/yarn.lock
Normal file
8
tsfun/yarn.lock
Normal 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==
|
Loading…
Reference in New Issue
Block a user