Testy / TestyTs

✔️ Modern TypeScript testing framework.
http://testy.github.io
ISC License
123 stars 8 forks source link

Made array arguments `readonly`. #78

Closed geon closed 3 years ago

geon commented 3 years ago

The array arguments have no business being mutable.

Purpose

The assertion functions can't be called with ReadonlyArray. That is bad.

Approach

Make the arguments readonly.

Learnings

https://www.typescriptlang.org/docs/handbook/interfaces.html#readonly-properties

geon commented 3 years ago

@Aboisier

I don't know how I could add tests for this. The change affects only the typing. It has no runtime impact.

A test of this would have to involve running the compiler on invalid code and see if it gives the correct error. Probably outside the scope of this project.

Aboisier commented 3 years ago

@geon

Indeed, the test I had in mind was a happy-path scenario (calling the methods with a readonly array) and would simply prevent accidental changes to the interface.

Aboisier commented 3 years ago

This has now been published in the latest version,1.5.0. Thanks for your contribution, it is really appreciated, @geon !