intesys / ytestbook

Manage test planning, execution and report
1 stars 0 forks source link

Use hooks types inside implementations #96

Closed kino90 closed 1 hour ago

kino90 commented 1 week ago

Every hook has its own type (e.g TTest) but in the implementation every function uses their own local type, this causes a possible misalignment inside the code, it's error prone and does not give any advantage


Quick example (code is random, this applies to each and every hook)

The hook has its own type:

type TUseMyHook { 
  someFunction: (someValue: ValueType ) => TSomeType
}

but inside the hook every function is declared like this

function someFunction(someValue: ValueType ): TSomeType { ... }
// or
const someFunction = (someValue: ValueType ): TSomeType => { ... }

so if I change for example ValueType to ValueType | AnotherType the change is not applied to the TUseMyHook type!

We could solve it easily by removing local types in the implementations, and using something like

const someFunction: TUseMyHook["someFunction"] = someValue => { ... }