Compiler & Linter Errors
TypeScript TS errors, ESLint rules, Go compiler messages, mypy — understanding static analysis output
Key error patterns
- TS: "not assignable to" → type mismatch between what you pass and what is expected
- ESLint: no-unused-vars → remove or prefix with underscore if intentionally unused
- Go: "undefined: X" → not imported or not declared in scope
- no-explicit-any → using
anybypasses TypeScript's type safety; useunknowninstead - mypy: incompatible return → a code path returns None but the annotation says otherwise
Question 0 of 5
TypeScript shows: error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'.
In plain English, what does this mean?
A number is passed where the function expects a string. Reading TypeScript error messages:
Argument of type 'X'— what you are passingis not assignable to parameter of type 'Y'— what the function expects- The error code
TS2345identifies this as an argument type mismatch
String(myNumber) or myNumber.toString(), or change the function signature. TypeScript error codes reference: TS2345 (arg type), TS2322 (assignment type), TS2339 (property does not exist), TS2304 (name not found).ESLint reports: 'userName' is assigned a value but never used. (no-unused-vars)
What should you do about this?
Remove the variable or prefix with underscore if intentionally unused. ESLint rules vocabulary:
- no-unused-vars — variable declared but never read
- no-undef — using a variable that was never declared
- no-implicit-any — TypeScript variable inferred as
any - eqeqeq — using
==instead of===
_unusedParam tells ESLint (and readers) this is intentionally unused — common in function signatures where you must match a callback shape but do not need all parameters.Go compiler outputs: undefined: UserService. What does this error mean?
UserService is not declared in the current scope. Go compiler errors:
- undefined: X — X is used but not declared or not imported
- cannot use X (variable of type Y) as type Z — type mismatch (Go is strictly typed)
- declared and not used: x — Go forbids unused variables (compile error, not warning)
- imported and not used: "fmt" — Go forbids unused imports
A linter reports: Unexpected any. Specify a different type. (@typescript-eslint/no-explicit-any). Why is this a problem?
Using
any bypasses type checking — TypeScript cannot catch type errors for any-typed values. Why it matters: - TypeScript's value is catching type errors at compile time, before runtime
anyopts out of type checking entirely for that value- A variable typed as
anycan be used as any type without error — errors only appear at runtime
any with a specific type, unknown (safer than any — requires a type check before use), or a generic type parameter. Use // eslint-disable-next-line @typescript-eslint/no-explicit-any only when truly unavoidable, and document why.Python's mypy type checker reports: error: Incompatible return value type (got "None", expected "str"). What caused this?
A code path returns None but the annotation says str. Python mypy errors:
Fix: either return a default string (
- If a function has a branch that returns nothing (falls off the end), Python implicitly returns None
- The annotation
def get_name() -> strpromises a str is always returned
def get_name(user) -> str:
if user.name:
return user.name
# missing else → returns None implicitlyFix: either return a default string (
return "") or change the return type to Optional[str] (returns str | None).