옵셔널

function example(a: string, b?: number, c = false) {}

나머지 매개변수 문법

function example(a: string, **...b: number[]**) {}

example('a', 1, 2, 3, 45); // 여기서 a는 'a', b는 [1, 2, 3, 45] 가 된다.

중첩된 매개변수를 제대로 타이핑 하기

function destructuring({ props: { nested } }) {} // Binding element 'nested' implicitly has an 'any' type.

함수 내부에서 this 를 사용하는 경우?

<aside> 📌 함수 내부에서 this 를 사용하는 경우, 매개변수 첫 번째 자리에 this 의 타입을 표기하자. 메서드의 경우 this 가 객체 자신으로 추론되지만, this 가 바뀔 수 있다면 명시적으로 타이핑 하자.

</aside>

function example(this: Window, a: string, b: 'this') {}
type Animal = {
	age: number,
	type: 'dog',
}

const person = {
	name: 'eunji',
	age: 28,
	sayName() {
		this;
		this.name;
	},
	sayDog(this: Animal) {
		this;
		this.type;
	}
}