@total-typescript/shoehorn
Advanced tools
Comparing version 0.1.0 to 0.1.1
# @total-typescript/shoehorn | ||
## 0.1.1 | ||
### Patch Changes | ||
- aef7bc8: Fixed issue where passing functions would break fromPartial. | ||
## 0.1.0 | ||
@@ -4,0 +10,0 @@ |
@@ -5,3 +5,3 @@ type NoInfer<T> = [T][T extends any ? 0 : never]; | ||
*/ | ||
type PartialDeep<T> = T extends (...args: any[]) => unknown ? T | undefined : T extends object ? T extends ReadonlyArray<infer ItemType> ? ItemType[] extends T ? readonly ItemType[] extends T ? ReadonlyArray<PartialDeep<ItemType | undefined>> : Array<PartialDeep<ItemType | undefined>> : PartialDeepObject<T> : PartialDeepObject<T> : T; | ||
type PartialDeep<T> = T extends (...args: any[]) => any ? PartialDeepObject<T> | undefined : T extends object ? T extends ReadonlyArray<infer ItemType> ? ItemType[] extends T ? readonly ItemType[] extends T ? ReadonlyArray<PartialDeep<ItemType | undefined>> : Array<PartialDeep<ItemType | undefined>> : PartialDeepObject<T> : PartialDeepObject<T> : T; | ||
type PartialDeepObject<ObjectType extends object> = { | ||
@@ -8,0 +8,0 @@ [KeyType in keyof ObjectType]?: PartialDeep<ObjectType[KeyType]>; |
{ | ||
"name": "@total-typescript/shoehorn", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "Work seamlessly with partial mocks in TypeScript.", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
# `shoehorn` | ||
`shoehorn` lets you pass partial data in tests, while keeping TypeScript happy. | ||
`shoehorn` (meaning "to force something into a space") lets you **pass partial data in tests** while keeping TypeScript happy. | ||
### Problem | ||
Using 'as' in tests feels bad. | ||
```ts | ||
@@ -25,4 +29,2 @@ type Request = { | ||
'as' in tests feels bad. | ||
- You're trained not to use it | ||
@@ -32,2 +34,4 @@ - You need to _manually_ specify the type you want to assert to | ||
### Solution | ||
`shoehorn` gives you some first-class primitives for _safely_ providing incomplete data to tests. | ||
@@ -39,3 +43,3 @@ | ||
it("Should get the user", () => { | ||
getUserId( | ||
getUser( | ||
fromPartial({ | ||
@@ -119,3 +123,3 @@ body: { | ||
// All good! | ||
requiresRequest(fromPartial("1234123")); | ||
requiresRequest(fromAny("1234123")); | ||
``` | ||
@@ -122,0 +126,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7956
140