ν¨μ type alias
ν¨μ νμ λ type aliasλ‘ μ μ₯ν΄μ μΈ μ μλ€.
type NumOut = (x : number, y : number ) => number
let ABC :NumOut = function(x,y){
return x + y
}
function ν€μλμλ νλΌλ―Έν° λ΄λΆλ {} λ°λ‘ μΌμͺ½μλ§ νμ μ§μ μ΄ κ°λ₯νκΈ° λλ¬Έμ function ν¨μμ΄λ¦ :NumOut (){} ννλ μ¬μ©ν μ μμ΄μ μ μ½λμ²λΌ μ¬μ©νλ€.
*** μ£Όμμ¬ν : ν¨μ type aliasλ₯Ό λΆμ°©νλ €λ©΄ ν¨μννμμΌλ‘ μ¨μΌ νλ€.
object λ©μλ type alias
type Member = {
name : string,
age : number,
plusOne : ( x :number ) => number,
changeName : () => void
}
let memberData :Member = {
name : 'kim',
age : 30,
plusOne (x){
return x + 1;
},
changeName : () => {
console.log('μλ
');
}
}
memberData.plusOne(1);
memberData.changeName();
μΆμ² : μ½λ©μ ν https://codingapple.com/ / TypeScript Documentation https://www.typescriptlang.org/docs/handbook/2/objects.html