type-plus
Version:
Provides additional types for TypeScript.
37 lines (23 loc) • 760 B
Markdown
General type utilities.
`Failed<Msg>` is a type to describe a failure.
Use the same concept to create your own failure types.
```ts
import { type Failed } from 'type-plus'
type YourComplexType<A,B,C> = A extends B ?
... // and many more hard work later...
: Failed<'you are doing something wrong!'>
```
[![Just Code: I failed][failed-type]][failed-type-url]
`NoInfer<T>` is a type to prevent type inference.
```ts
import { type NoInfer } from 'type-plus'
function assertEqual<T>(a: T, b: NoInfer<T>) {
return a === b
}
function stub<T>(v: RecursivePartial<NoInfer<T>>): T { return v }
```
[]: https://img.youtube.com/vi/3pEXVe6KJO4/0.jpg
[]: https://www.youtube.com/live/3pEXVe6KJO4