Skip to content
ZOLO / TE008 Type · error

array element type mismatch

An array literal mixes incompatible element types; arrays are homogeneous.

Why this fires

An array literal is being checked against an expected element type — usually because it's assigned to a let/const with an explicit array type, or passed as an argument to a parameter typed [T] — and one of its elements doesn't match T.

let names: [str] = ["Ana", "Bo", 3]
//                          ^ error[TE008]: array element type mismatch: expected str, found int

Fix it

Make every element match the declared element type:

let names: [str] = ["Ana", "Bo", "Cid"]   // ok

If the array is genuinely meant to hold mixed types, drop the specific element type and use [any], or don't annotate the type at all and let the array's own inferred (possibly union) type stand.

See also

Global index

Find your way through Zolo

Try an idea

Start here

9 results

9 results

enespt-br