0kku / destiny

A reactive UI library for JavaScript and TypeScript
Open Software License 3.0
53 stars 6 forks source link

Build fails on TS3.9+ #1

Closed 0kku closed 3 years ago

0kku commented 4 years ago

Building project fails on TypeScript 3.9 and up. Culprit is ReactiveArray#flat().

Workaround (courtesy of @b-fuze):

    const newArr = new this.species(...this.#value.flat(<1> <unknown> depth));
    this.#callbacks.add(() => {
      newArr.value = this.#value.flat(<1> <unknown> depth);
    });

Let's keep using 3.8 for now, but resort to using the workaround if we need features from newer versions of TS before the compiler bug is fixed.

Depends on https://github.com/microsoft/TypeScript/issues/38298

b-fuze commented 4 years ago

LGTM, merged 😄

0kku commented 4 years ago

I was looking over the method, and realized ReactiveArray::flat() was poorly implemented, and decided to remove it entirely for now. So, upgrading to a newer version of TS should be fine now. I'll implement the method (properly this time) once the compiler bug is resolved.

The issue with the old implementation was, that it didn't take into account that nested arrays are now implicitly made reactive recursively, which wasn't the case when it was first implemented (who would've thought that writing some tests for this lib might be useful? 🤦‍♂️). This change means that implementing ReactiveArray::flat() and ReactiveArray::flatMap() might be a little tricky. But I won't investigate it until MS fixes their compiler.