Skip to content

Severity: error
Category: type-check
Stage: Stage 0 (prototype)

Description

The inferred or declared type of an expression does not match the expected type at an assignment, return statement, function call, or similar site.

Example

// ✗ error — string assigned where number expected
let count: number = "five"         // SJS-E002

function double(n: number): number {
  return "two times " + n          // SJS-E002: string, not number
}

Fix

Correct the expression to produce the expected type, or update the declared type if the intent changed:

// ✓ correct
let count: number = 5

function double(n: number): number {
  return n * 2
}
  • SJS-E001 — null/undefined assigned to non-nullable type
  • SJS-W001 — implicit dynamic (unannotated parameter in strict mode)
Documentation