JS Coercion Syndrome

type Mapish = { [k: string]: boolean };
type M = keyof Mapish;

Try to guess the type of M

type M = string | number

Surprised?

According to the Typescript documentation:

Note that in this example, M is string | number — this is because JavaScript object keys are always coerced to a string, so obj[0] is always the same as obj["0"].

See for yourself.

hashtag just-js-things