Skip to content

Commit

Permalink
Branded types now compatible with declaration option of TS (#196)
Browse files Browse the repository at this point in the history
  • Loading branch information
yuhr committed Mar 22, 2021
1 parent b0c25df commit 146d8f6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ export * from './types/function';
export { InstanceOf } from './types/instanceof';
export * from './types/lazy';
export * from './types/constraint';
export { Brand } from './types/brand';
export * from './types/brand';
export * from './decorator';
8 changes: 6 additions & 2 deletions src/types/brand.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
import { Runtype, Static, create } from '../runtype';

declare const RuntypeName: unique symbol;
export declare const RuntypeName: unique symbol;

export interface RuntypeBrand<B extends string> {
[RuntypeName]: B;
}

export interface Brand<B extends string, A extends Runtype>
extends Runtype<
// TODO: replace it by nominal type when it has been released
// https://github.com/microsoft/TypeScript/pull/33038
Static<A> & { [RuntypeName]: B }
Static<A> & RuntypeBrand<B>
> {
tag: 'brand';
brand: B;
Expand Down

0 comments on commit 146d8f6

Please sign in to comment.