Skip to content

Commit 7666a6d

Browse files
authored
Merge pull request #171 from ahrjarrett/@ahrjarrett/v0.48.1
@ahrjarrett/v0.48.1
2 parents 9a90790 + 55769da commit 7666a6d

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

.changeset/mighty-yaks-compare.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
---
2+
"any-ts": patch
3+
---
4+
5+
feat: adds `inline` type utility
6+
7+
### new features
8+
9+
- new [inline](https://github.com/ahrjarrett/any-ts/compare/%40ahrjarrett/v0.48.1?expand=1#diff-8f609800e1fe1486238044764d22867704573f7319ac89246dfcedfe9b3d7b68R9) utility
10+
11+
`inline` is basically a type-level identity function.
12+
13+
like its runtime counterpart, it can be pretty useful.
14+
15+
the name `inline` refers to the particular use case that I personally usually use it for,
16+
which is for wrapping a type literal so that an interface can extend it.
17+
18+
```typescript
19+
import type { inline } from "any-ts"
20+
21+
//////////////
22+
/// example
23+
24+
/**
25+
* did you know you can make an interface out of an array?
26+
* this can be useful when you want to preserve the
27+
* identifier: vvvv */
28+
interface Numbers extends inline<number[]> {}
29+
30+
declare const numbers: Numbers
31+
// ^? const numbers: Numbers
32+
33+
// normal array behavior is preserved:
34+
const copy = [...ex_01.numbers]
35+
// ^? const copy: number[]
36+
```

src/exports.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ export {
66
expectToFail
77
} from "./test/exports.js"
88

9+
export type inline<T> = T
10+
911
export type { empty } from "./empty/exports.js"
1012
export type { nonempty } from "./nonempty/exports.js"
1113
export type { array, nonemptyArray, queue, tuple } from "./array/exports.js"

0 commit comments

Comments
 (0)