Skip to content

Commit

Permalink
docs: mark Opaque as deprecated
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanresnick committed Apr 25, 2024
1 parent c1d2e0a commit e087100
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 3 additions & 5 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,8 @@ Click the type names for complete docs.
- [`UndefinedOnPartialDeep`](source/undefined-on-partial-deep.d.ts) - Create a deep version of another type where all optional keys are set to also accept `undefined`.
- [`ReadonlyDeep`](source/readonly-deep.d.ts) - Create a deeply immutable version of an `object`/`Map`/`Set`/`Array` type. Use [`Readonly<T>`](https://www.typescriptlang.org/docs/handbook/utility-types.html#readonlytype) if you only need one level deep.
- [`LiteralUnion`](source/literal-union.d.ts) - Create a union type by combining primitive types and literal types without sacrificing auto-completion in IDEs for the literal type part of the union. Workaround for [Microsoft/TypeScript#29729](https://github.com/Microsoft/TypeScript/issues/29729).
- [`Tagged`](source/opaque.d.ts) - Create a [tagged type](https://medium.com/@KevinBGreene/surviving-the-typescript-ecosystem-branding-and-type-tagging-6cf6e516523d) that can support [multiple tags](https://github.com/sindresorhus/type-fest/issues/665) if needed.
- [`UnwrapTagged`](source/opaque.d.ts) - Get the untagged portion of a tagged type created with `Tagged`.
- [`Opaque`](source/opaque.d.ts) - Create a [tagged type](https://medium.com/@KevinBGreene/surviving-the-typescript-ecosystem-branding-and-type-tagging-6cf6e516523d). This implementation only supports a single tag.
- [`UnwrapOpaque`](source/opaque.d.ts) - Get the untagged portion of a tagged type created with `Opaque` or `Tagged`.
- [`Tagged`](source/opaque.d.ts) - Create a [tagged type](https://medium.com/@KevinBGreene/surviving-the-typescript-ecosystem-branding-and-type-tagging-6cf6e516523d) that can support [multiple tags](https://github.com/sindresorhus/type-fest/issues/665) and [per-tag metadata](https://medium.com/@ethanresnick/advanced-typescript-tagged-types-improved-with-type-level-metadata-5072fc125fcf). (This replaces the previous [`Opaque`](source/opaque.d.ts) type, which is now deprecated.)
- [`UnwrapTagged`](source/opaque.d.ts) - Get the untagged portion of a tagged type created with `Tagged`. (This replaces the previous [`UnwrapOpaque`](source/opaque.d.ts) type, which is now deprecated.)
- [`InvariantOf`](source/invariant-of.d.ts) - Create an [invariant type](https://basarat.gitbook.io/typescript/type-system/type-compatibility#footnote-invariance), which is a type that does not accept supertypes and subtypes.
- [`SetOptional`](source/set-optional.d.ts) - Create a type that makes the given keys optional.
- [`SetReadonly`](source/set-readonly.d.ts) - Create a type that makes the given keys readonly.
Expand Down Expand Up @@ -342,7 +340,7 @@ type ShouldBeNever = IfAny<'not any', 'not never', 'never'>;
- `RequireOnlyOne` - See [`RequireExactlyOne`](source/require-exactly-one.d.ts)
- `AtMostOne` - See [`RequireOneOrNone`](source/require-one-or-none.d.ts)
- `AllKeys` - See [`KeysOfUnion`](source/keys-of-union.d.ts)
- `Branded` - See [`Opaque`](source/opaque.d.ts)
- `Branded`, `Opaque` - See [`Tagged`](source/opaque.d.ts)

## Tips

Expand Down
2 changes: 2 additions & 0 deletions source/opaque.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ type Person = {
```
@category Type
@deprecated Use {@link Tagged} instead
*/
export type Opaque<Type, Token = unknown> = Type & TagContainer<Token>;

Expand Down Expand Up @@ -109,6 +110,7 @@ type WillWork = UnwrapOpaque<Tagged<number, 'AccountNumber'>>; // number
```
@category Type
@deprecated Use {@link UnwrapTagged} instead
*/
export type UnwrapOpaque<OpaqueType extends TagContainer<unknown>> =
OpaqueType extends Tag<PropertyKey, any>
Expand Down

0 comments on commit e087100

Please # to comment.