Most mojave APIs are very generic by-design, which can lead to many situations where you have to cast the return of a mojave method to a more explicit/specific type, which is just unnecessary noise.
// before
let divElement = findOne(".my-div", this.container);
let inputElement = findOne(".my-input", this.container) as HTMLInputElement;
// after
let divElement = findOne(".my-div", this.container);
let inputElement = findOne<HTMLInputElement>(".my-input", this.container);
I've used the previously hardcoded types as default for the generic type parameters, which makes this change backwards compatible and allows us to omit the type parameters when they match the default.
Most mojave APIs are very generic by-design, which can lead to many situations where you have to cast the return of a mojave method to a more explicit/specific type, which is just unnecessary noise.
I've used the previously hardcoded types as default for the generic type parameters, which makes this change backwards compatible and allows us to omit the type parameters when they match the default.
This is the very first pass of making most methods generic and easier to work with. For
extend
,merge
anddebounce
I found the following article pretty helpful: https://spin.atomicobject.com/2018/05/14/type-safe-object-merging-2-8/ However, it lacks support for variadic parameters, which we currently need for all methods. So we'll probably have to wait until https://github.com/Microsoft/TypeScript/issues/5453 has been merged.