BohdanQQ

Typescript Will Not Save You

What do you thing this function does? Excuse the imperfect usage of value destruction.

function encodeLocationCoords(value: {x: number, y: number, z: number}): string {
  return [value.x, value.y, value.z].map(toString).join(COORD_NUM_SEP);
}

If you thought that it just encodes the numbers into a string separated by COORD_NUM_SEP then I am sorry.

What you get is '[object Undefined]_[object Undefined]_[object Undefined]'.

Because why would typescript linter or compiler tell you that toString is not a string (as join expects)?

The more I use Typescript, the less I think it makes Javascript "bearable".

In Haskell, you're allowed to do that. Other features of truly "functinoal" languages I miss are for example Enums with attached data or newtype thing without creating empty classes - wordy and visually just weird...

Last update

29th November 2024