gvergnaud / hotscript

A library of composable functions for the type-level! Transform your TypeScript types in any way you want using functions you already know.
3.38k stars 57 forks source link

[Feature Request]: `Not`, `NotIn`, and `NoIntersect` handlers for validation and duplicate checks #74

Closed brandonmcconnell closed 1 year ago

brandonmcconnell commented 1 year ago

There are several goals I am hoping to achieve here, with these type helpers:

I'm' not sure what the API for this would look like, likely not what I showed above but something more argument-based like this…

type SomeType = NoIntersect<typeof wordsB, keyof typeof wordsC>;

…if the base type can be inferred, otherwise passed explicitly as the first arg like this:

type SomeType = NoIntersect<string[], typeof wordsB, keyof typeof wordsC>;
ecyrbe commented 1 year ago

This is not possible in typescript. Feature request was rejected long time ago from TS team : https://github.com/microsoft/TypeScript/issues/47178