Skip to content

Commit

Permalink
fix: emit nominal tag in declaration
Browse files Browse the repository at this point in the history
The `Nominal` type has not been working (possibly for a long time)
because the tag was not being emitted by the typescript compiler. This
didn't show up in testing because the tests are not run against the
emitted definitions.

Instead of emitting:
```typescript
class Tagged<N extends string> { private __tagged__: N }
```
we were getting
```typescript
class Tagged<N extends string> { __tagged__ }
```
thus nothing was tagged any longer.

Switching from `private` to `protected` fixes the emit issue while still
hiding the tag from the end user.
  • Loading branch information
andnp committed Jul 22, 2019
1 parent 4c8b30e commit bb7ad72
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/types/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export type Nullable<T> = T | null | undefined;
/**
* no-doc - This is a helper for `Nominal` and is not useful on its own
*/
export declare class Tagged<N extends string> { private _nominal_: N; }
export declare class Tagged<N extends string> { protected _nominal_: N; }
/**
* Constructs a nominal type of type `T`.
* Useful to prevent any value of type `T` from being used or modified in places it shouldn't (think `id`s).
Expand Down

0 comments on commit bb7ad72

Please sign in to comment.