Skip to content

v4.0.0

Choose a tag to compare

@github-actions github-actions released this 19 Nov 13:42
· 63 commits to main since this release

4.0.0 (2023-11-19)

BREAKING CHANGES

  • types: change any[] to unknown[], if creating a matrix of dynamic size (#21)

    const createDynamicMatrix = (dimensions: number[]) => makeMatrix(dimensions, 0); // now returns unknown[]

    This is a breaking change to how the library handles cases where a primitive, instead of a literal type, is used for the number of dimensions. Previously, the resulting Matrix would resolve to any[], as the complier is unable to infer how it should be typed (other than that it must be an array). This allowed to compiler to avoid throwing a type instantiation is excessively deep error, but also introduced an implicit any into the user's codebase, which is less than ideal.

    Now, the library will return a type of unknown[] in these cases. This achieves the same basic amount of type safety, but also means that users will not be able to use the resulting matrix in as many places as any[] would have allowed. The resulting matrix must now be typed by the caller. If you are able to provide more information than the compiler can infer. If not, then an explicit typing of any[] will provide the most 'relaxed' experience.