Cause 1 of 6
The value genuinely is the wrong type.
Convert it at the boundary where it enters your code: Number(input.value), then check the result with Number.isNaN before using it. Reading the full message matters — the part after 'is not assignable' names the exact incompatible piece, which for object types is a specific property.
Cause 2 of 6
The value may be undefined or null.
string | undefined is not assignable to string. Narrow it first with a guard — if (value === undefined) return; — and TypeScript will accept it for the rest of the block. Under strictNullChecks this is the most common form of TS2345.
Cause 3 of 6
The argument is wider than the parameter's union.
string is not assignable to 'small' | 'large'. Narrow with a check, or keep the source narrow: as const on a literal or an object literal preserves the literal types instead of widening them to string.
Cause 4 of 6
An object literal has a missing or excess property.
The message points at the property name. Add the missing one; for an excess one, either widen the parameter type or drop the property — excess property checking only fires on fresh object literals, which is why assigning through a variable first appears to 'fix' it without fixing anything.
Cause 5 of 6
Two structurally identical types that are not the same type.
A message reading 'Type X is not assignable to type X' means there are two copies of the declaration — usually duplicate installs of the same @types package. npm ls @types/<name> shows the duplicates; deduping or aligning versions removes it.
Cause 6 of 6
You are about to reach for a cast.
value as number silences the compiler without changing the value, so the failure just moves to runtime. Use it only for something you know and the compiler cannot, and prefer a type guard function that actually checks.