-
-
Notifications
You must be signed in to change notification settings - Fork 521
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Proposal: InvariantOf
#288
Comments
Update: use function signature to transform type into a invariant type declare const tag: unique symbol;
declare type InvariantProp<Type> = (arg: Type) => Type;
declare type InvariantTagged<Type> = {
readonly [tag]: InvariantProp<Type>;
};
/**
* Transfrom type to Invariant type
*/
export declare type InvariantOf<Base> = Base & InvariantSignature<Base>; |
What's the practical use-case? I'm not sure when I would need this. |
In structural typing, Object can have more properties at run-time, so microsoft/TypeScript#12253 (comment) If use This has a tricky side, but there are rare use cases to accurately distinguish the type according to the structure. |
This is accepted. For anyone submitting a pull request for this, it should come with a clear description, use-cases, and a practical example. |
Inspired by InvariantOf.
It could be useful to make object invariant. It is similar
opaque
type without brand or tag.I published this utility type as package, but I wish to add it to this project.
Here are some test cases.
I'm willing to do PR. 😃
The text was updated successfully, but these errors were encountered: