I think all these 3 overloads are very similar and doesn't help much. Also, why would you rename a function parameter from buffer
to data
? If it is different, then there should be 2 functions.
Isn't this interface enough?
update(buffer: number[] | number, offset?: number, length?: number): number
This one captures all overloads above. Then, regarding skipping the checks in your code, I don't understand the point. TypeScript provides types to your code but it doesn't prevent you from checking your function inputs, as you would with plain js.
I think you are trying to put too many "responsabilities" on the TS side.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…