UNPKG

363 BTypeScriptView Raw
1type StringLiteral<Type> = Type extends string ? (string extends Type ? never : Type) : never;
2declare const __OPAQUE_TYPE__: unique symbol;
3export type WithOpaque<Token extends string> = {
4 readonly [__OPAQUE_TYPE__]: Token;
5};
6export type Opaque<Type, Token extends string> = Token extends StringLiteral<Token> ? Type & WithOpaque<Token> : never;
7export {};