tsc TS2322: Type 'X' is not assignable to type 'Y' in CI
TS2322 is an assignment-compatibility error: the type on the right of an assignment (or a property value, or a returned value) is not a subtype of the declared target type, so tsc rejects it.
What this error means
tsc fails with "error TS2322: Type 'string' is not assignable to type 'number'" (or similar), often with a follow-on note about which property or member caused the mismatch.
src/config.ts:4:3 - error TS2322: Type 'string' is not assignable to type 'number'.
4 port: '8080',
~~~~Common causes
The value type does not match the declared type
A string is assigned where a number is declared, or a wider union is assigned to a narrower one. tsc enforces structural assignability and rejects it.
A widened literal or a missing property in an object literal
Object literals are checked exactly; an extra or wrongly typed property makes the literal not assignable to the target interface.
How to fix it
Make the value match the target type
- Read the "Type X is not assignable to type Y" pair to see the exact mismatch.
- Convert or correct the value so its type is a subtype of the target.
- Re-run tsc to confirm the assignment now type-checks.
// '8080' is a string; the field expects a number
const config = { port: 8080 };Widen the target type if the broader type is intended
If both values are legitimately allowed, declare the target as a union rather than forcing a cast.
type Port = number | `${number}`;How to prevent it
- Type config and API shapes explicitly so mismatches surface at the source.
- Avoid
ascasts that paper over real assignability errors. - Run tsc locally before pushing so TS2322 is caught before CI.