static hello() {
return "hello";
}
...
class Word {
constructor(
public readonly term: string,
public readonly def : string,
){}
}
const kimchi = new Word("kimchi", "한국의 음식")
console.log(kimchi.def);
type Team = "red" | "blue" | "yellow "
type Health = 1 | 5 | 10
type Player = {
nickname: string,
team: Team,
health: Health,
}
interface Person {
nickname: string,
team: Team,
health: Health,
}
const player1: Player = {
nickname: "sol",
team: "red",
health: 1
}
interface User {
name: string
}
interface Player extends User {
// 하지만 인터페이스를 쓰면 좀 더 객체지향 프로그래밍처럼 표현 o
}
// type Player = User & { // 헉;;; super cool~~~;;;
// // type은 종류에 관계 없이 어떠한 타입을 만들 때 다 쓸 수 있음
// }
const nick: Player = {
name: "nico"
}
interface User {
name: string
}
interface User {
lastName: string
}
interface User {
health: number
}
const nico: User = {
name: "",
lastName: "",
health: 0
}