πΒ Reference
πΒ Chapter
Literal types
typeof, keyof
any, unknown, never, void
type-coverage
interface
- μΈν°νμ΄μ€
- μΈν°νμ΄μ€λ μνΈ κ°μ μ μν μ½μ νΉμ κ·μΉμ μλ―Ένλ€.
- TypeScriptμμμ μΈν°νμ΄μ€λ λ³΄ν΅ λ€μκ³Ό κ°μ λ²μ£Όμ λν΄ μ½μμ μ μν μ μλ€.
- κ°μ²΄μ μ€ν(μμ±κ³Ό μμ±μ νμ
)
- ν¨μμ νλΌλ―Έν°
- ν¨μμ μ€ν(νλΌλ―Έν°, λ°ν νμ
λ±)
- λ°°μ΄κ³Ό κ°μ²΄λ₯Ό μ κ·Όνλ λ°©μ
- ν΄λμ€
- μΈν°νμ΄μ€λ₯Ό μΈμλ‘ λ°μ μ¬μ©ν λ νμ μΈν°νμ΄μ€μ μμ± κ°―μμ μΈμλ‘ λ°λ κ°μ²΄μ μμ± κ°―μλ₯Ό μΌμΉμν€μ§ μμλ λλ€.
- λ€μ λ§ν΄, μΈν°νμ΄μ€μ μ μλ μμ±, νμ
μ μ‘°κ±΄λ§ λ§μ‘±νλ€λ©΄ κ°μ²΄μ μμ± κ°―μκ° λ λ§μλ μκ΄ μλ€λ μλ―Έμ΄λ€.
- λν, μΈν°νμ΄μ€μ μ μΈλ μμ± μμλ₯Ό μ§ν€μ§ μμλ λλ€.
interface T {
}
interface μΈν°νμ΄μ€_μ΄λ¦ {
μμ±?: νμ
;
}
let person = { name: "Capt", age: 28 };
function logAge(obj: { age: number }) {
console.log(obj.age); // 28
}
logAge(person); // 28
- μμ²λΌ ν¨μμ paramμ κ°μ²΄μ μμ± νμ
μ μ μ ν μ μλ€.
interface personAge {
age: number;
}
function logAge(obj: personAge) {
console.log(obj.age);
}
let person = { name: "Capt", age: 28 };
logAge(person);