Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@total-typescript/shoehorn

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@total-typescript/shoehorn - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1

6

CHANGELOG.md
# @total-typescript/shoehorn
## 0.1.1
### Patch Changes
- aef7bc8: Fixed issue where passing functions would break fromPartial.
## 0.1.0

@@ -4,0 +10,0 @@

2

dist/index.d.ts

@@ -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 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc