글

라벨이 type error인 게시물 표시

TS2345: Argument of type is not assignable to parameter of type - 10 Causes and Fixes

이미지
TS2345: Argument of type is not assignable to parameter of type is the TypeScript compiler telling you that a value you passed to a function does not satisfy the type that function expects. This is one of the most common TypeScript errors — and one of the most varied, because it fires everywhere a function call touches a mismatched type. The error message itself always fills in two blanks: the type you actually gave, and the type the parameter demands. Reading those two types carefully is half the battle. The gap between them tells you exactly which property is missing, which union member is wrong, or which generic got inferred incorrectly. This guide covers 10 concrete causes ranked by frequency, a diagnostic checklist for cases that do not match any single cause, and the type-theory reason this error exists at all. Error TS2345: Argument of type '{A}' is not assignable to parameter of type '{B}'. Where it happens TypeScript compiler (tsc) — any version from ...