Skip to content

Commit

Permalink
Merge pull request #171 from ahrjarrett/@ahrjarrett/v0.48.1
Browse files Browse the repository at this point in the history
@ahrjarrett/v0.48.1
  • Loading branch information
ahrjarrett authored Nov 16, 2024
2 parents 9a90790 + 55769da commit 7666a6d
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
36 changes: 36 additions & 0 deletions .changeset/mighty-yaks-compare.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---
"any-ts": patch
---

feat: adds `inline` type utility

### new features

- new [inline](https://github.com/ahrjarrett/any-ts/compare/%40ahrjarrett/v0.48.1?expand=1#diff-8f609800e1fe1486238044764d22867704573f7319ac89246dfcedfe9b3d7b68R9) utility

`inline` is basically a type-level identity function.

like its runtime counterpart, it can be pretty useful.

the name `inline` refers to the particular use case that I personally usually use it for,
which is for wrapping a type literal so that an interface can extend it.

```typescript
import type { inline } from "any-ts"

//////////////
/// example

/**
* did you know you can make an interface out of an array?
* this can be useful when you want to preserve the
* identifier: vvvv */
interface Numbers extends inline<number[]> {}

declare const numbers: Numbers
// ^? const numbers: Numbers

// normal array behavior is preserved:
const copy = [...ex_01.numbers]
// ^? const copy: number[]
```
2 changes: 2 additions & 0 deletions src/exports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ export {
expectToFail
} from "./test/exports.js"

export type inline<T> = T

export type { empty } from "./empty/exports.js"
export type { nonempty } from "./nonempty/exports.js"
export type { array, nonemptyArray, queue, tuple } from "./array/exports.js"
Expand Down

0 comments on commit 7666a6d

Please sign in to comment.