https://github.com/tae100k/TS_BlockChain
"start": "tsc-watch --onSuccess \\\\" node dist/index.js\\\\" ",
interface PersonType {
name:string;
age:number;
gender:string;
}
const person = {
name:"김지환",
age:20,
gender:"male",
}
const sayHi = (person:PersonType):string =>{
return `Hello ${person.name}, you are ${person.age}, you are a ${person.gender}`;
}
Class
class Human {
public name:string;
public age: number;
constructor(name:string, age:number, gender:string) {
this.name = name;
this.age = age;
this.gender = gender;
}
}
const JH = new Human(
"Jihwan", 20, "male"
);
public : 권한 설정(자스는 신경쓰지 않음) constructor : 클래스로 객체를 만들때마다 호출되는 method
"compilerOptions": {
"module":"commonjs", //node.js를 평범하게 사용하고 다양한 걸 import하거나 export할 수 있게 만든다.
"target" : "ES2015", //어떤 버전의 자바스크립트로 컴파일 되고 싶은 지 적는다.
"sourceMap": true,
"outDir":"dist" //sourcemap을 하고 싶은 지
},
outDir : 모든 타입스크립트는 src, 컴파일된 것은 dist에 들어간다.
import
import * as 이름 from "라이브러리"