In my system, there is a complex generic type called IsUnique<T>
that evaluates to either true
or false
based on the input type T
:
type IsUnique<T> = (/* ... */) ? true : false;
Now I am looking to develop a function that takes an unique value as the first argument, meaning a value with type U
which would result in IsUnique<U>
being true
. How can I achieve this task?
const processUniqueValue: WhichFunctionTypeShouldIGoFor = value => {
// ...
};
let x: T1; // Assuming `IsUnique<T1>` is evaluated as `true`
let y: T2; // Assuming `IsUnique<T2>` is evaluated as `false`
processUniqueValue(x); // Should work without any issues
processUniqueValue(y); // Must not work during compilation