Skip to content
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

deprecates Identity - use newtype instead #167

Merged
merged 2 commits into from
Jul 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/rotten-rules-appear.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"any-ts": patch
---

deprecate: `Identity` -- use `newtype` instead
4 changes: 2 additions & 2 deletions src/check/check.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ export {

import type { any } from "../any/exports.js"
import type { _ } from "../util.js"
import type { Identity as id } from "../identity.js"
import type { newtype } from "../newtype.js"

export type TypeErrorURI = "any-ts/TypeError"
export interface TypeError<type extends [string, unknown]> extends id<type> {
export interface TypeError<type extends [string, unknown]> extends newtype<type> {
[any.unit]: TypeErrorURI
}

Expand Down
6 changes: 5 additions & 1 deletion src/exports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,11 @@ export type {
} from "./mutable/exports.js"
export type { pathsof } from "./paths/exports.js"
export type { never } from "./never/exports.js"
export type { Identity } from "./identity.js"
export type {
newtype,
/** @deprecated use {@link newtype `newtype`} instead */
newtype as Identity,
} from "./newtype.js"
export type { id } from "./util.js"
export type {
char,
Expand Down
4 changes: 0 additions & 4 deletions src/identity.ts

This file was deleted.

4 changes: 4 additions & 0 deletions src/newtype.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import type { id } from "./util.js";

/** @ts-expect-error hush */
export interface newtype<nonunion extends {} = {}> extends id<nonunion> { }
11 changes: 11 additions & 0 deletions src/string/string.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import type * as Internal from "./_internal.js"
import type { Case } from "./_internal.js"
import type { /* join, */ startsWith, endsWith } from "./_internal.js"
import type { is } from "./_internal.js"
import { newtype } from "../newtype.js"

import type { char } from "./char.js"

Expand All @@ -24,6 +25,16 @@ declare namespace HKT {
}
}

////////////////
/// newtypes
declare namespace string {
interface literal<T extends string = string> extends newtype<string> { toString(): T, valueOf(): T }
interface decodedURI<T extends string = string> extends string.literal<T> { }
interface encodedURI<T extends string = string> extends string.literal<T> { }
interface decodedURIComponent<T extends string = string> extends string.literal<T> { }
interface encodedURIComponent<T extends string = string> extends string.literal<T> { }
}

declare namespace string {
/** namespace exports */
export {
Expand Down