What are your concerns about a future type system for Elixir?

Typescript can be a joy to work with, but in certain cases the extra effort spent trying to convince it what you’re doing is OK can be quite tedious and result in cluttering the code. A minimalist example (real world ones can be much messier and puzzling) would be:

const maybeNumbers = [1, 2, null, 4, undefined];

// Type '(number | null |undefined)[]' is not assignable to type 'number[]'.
const nok: number[] = maybeNumbers.filter(x => x != null);

const ok: number[] = maybeNumbers.filter((x): x is number => x != null);

I worry that we similarly need to jump through hoops to make the compiler happy even if the original code is perfectly clear and free of errors.

10 Likes