Closed demetris-manikas closed 1 month ago
Can we do the unbreaking part of this work now and save the breaking part for a future 2.0 release?
I removed the breaking changes.
Sorry about this.
I got carried away because all tests and linting were passing;
This must be dropped and the changes in a previous PR about reducing any
usage that changed
<T extends any[]> func ( ...args T>
to func (...args: unknown[])
and
<C extends UserDatabaseClient> func (TransactionContext<C>)
to func (TransactionContext<UserDatabaseClient>)
were a mistake and have to be reverted.
This declaration
type Func<T extends unknown[]> = (a: string, ...args: T) => void;
allows to define an implementation like the following which declares more than it should
const FuncImpl: Func<[number]> = (a: string, b: number) =>{}
BUT
type Func2 = (a:string ...args: unknown[]) => void;
does not allow do declare
const Func2Impl: Func2 = (a: string, b: number) => {}
BUT only
const Func2Impl: Func2 = (a: string, b: unknown) => {}
which is terrible.
As I realize now the proper way to define a function that takes any number of arguments is
type Func = (a: string ...any[]) => void
and it is safe since as it only declares that this is a function that must have a string argument and can take any number of additional arguments.
I will prepare a PR later that reverts all the affected code by #448.
Sorry again. Typescript is a pain sometimes ....
Resolves #459 Unfortunately this PR introduces a breaking change since the httpServer/middleware had to be adjusted as well.