https://github.com/ksxnodemodules/typescript-miscellaneous
Miscellaneous TypeScript utilities
https://github.com/ksxnodemodules/typescript-miscellaneous
library miscellaneous types typescript utility
Last synced: 11 months ago
JSON representation
Miscellaneous TypeScript utilities
- Host: GitHub
- URL: https://github.com/ksxnodemodules/typescript-miscellaneous
- Owner: ksxnodemodules
- License: mit
- Created: 2018-10-03T10:02:47.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2023-03-17T03:14:31.000Z (over 3 years ago)
- Last Synced: 2024-11-27T19:05:14.778Z (over 1 year ago)
- Topics: library, miscellaneous, types, typescript, utility
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/typescript-miscellaneous
- Size: 126 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# TypeScript Miscellaneous
## Requirements
* TypeScript ≥ 3.0.0
## Usage
### `Dict`
**Without TypeScript Miscellaneous:**
```typescript
type MyObj = {
a: number
b: number
c: number
0: number
1: number
}
```
**With TypeScript Miscellaneous:**
```typescript
import { Dict } from 'typescript-miscellaneous'
type MyObj = Dict<
'a' | 'b' | 'c' | 0 | 1,
number
>
```
### `UnionToIntersection`
```typescript
import { UnionToIntersection } from 'typescript-miscellaneous'
type Intersection = UnionToIntersection<0 | 1 | 2> // Expect: 0 & 1 & 2
```
### `ElementOf`
```typescript
import { ElementOf } from 'typescript-miscellaneous'
type Element = ElementOf<[0, 1, 2, 3]> // Expect: 0 | 1 | 2 | 3
```
### `ParametersOf`
```typescript
import { ParametersOf } from 'typescript-miscellaneous'
type Parameters = ParametersOf<(a: 0, b: 1) => void> // Expect: [0, 1]
```
### `ReturnOf`
```typescript
import { ReturnOf } from 'typescript-miscellaneous'
type Return = ReturnOf<() => 123> // Expect: 123
```
## License
[MIT](https://git.io/fxIAz) © [Hoàng Văn Khải](https://github.com/KSXGitHub)