HerringtonDarkholme / av-ts

A modern, type-safe, idiomatic Vue binding library
MIT License
216 stars 11 forks source link

TS3.0 introduced generic rest parameters #77

Closed whitetrefoil closed 6 years ago

whitetrefoil commented 6 years ago

I just saw TS3.0 introduced generic rest parameters, will this bring the possibility of a better Mixin?

HerringtonDarkholme commented 6 years ago

Thanks! I'll update it when I have time!

HerringtonDarkholme commented 6 years ago

I think there is an inherent problem in TypeScript to support this: we cannot manipulate tuples in TS3.0.

Think about this: given a tuple type T, return a intersection type of which the components are elements in the tuple type T.

Naively we would write something like:

type TupleToIntersection<T extends any[]> = T extends [any] ? T[0] : T[0] & TupleToIntersection<Tail<T>>

Sadly, TS3.0 doesn't allow recursive conditional type, such construction will trigger a compiler error.

The same rule applies to Mixin function.

whitetrefoil commented 6 years ago

So sad... I feel this will not be a soon coming feature in the next TS releases...