-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #171 from ahrjarrett/@ahrjarrett/v0.48.1
@ahrjarrett/v0.48.1
- Loading branch information
Showing
2 changed files
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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[] | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters