��체에 as const를 붙이면 리터럴 타입이 되어서 함수 인자로 넘길 때 타입 에러가 발생합니다.
const config = { mode: 'production' } as const
function init(opts: { mode: string }) { ... }
init(config) // Error: 'production' is not assignable to string��체에 as const를 붙이면 리터럴 타입이 되어서 함수 인자로 넘길 때 타입 에러가 발생합니다.
const config = { mode: 'production' } as const
function init(opts: { mode: string }) { ... }
init(config) // Error: 'production' is not assignable to string
댓글 0