1.0.1 • Published 3 years ago

@tomysmith/deep-partial v1.0.1

Weekly downloads
-
License
ISC
Repository
github
Last release
3 years ago

deep-partial

This package builds upon TypeScript's built-in Partial<T> type by allowing deep partials to be created.

The current behavior of TypeScript's Partial<T> type means that nested objects will not have the optional status applied to their fields. For example:

type Person = {
    name: string;
    age: number;
    address: {
        number: number;
        street: string;
    };
};

const myHouseNumber: Partial<Person> = { address: { number: 52 } };

// The above is invalid, and results in error: Property 'street' is missing in
// type '{ number: number; }' but required in type '{ number: number; street: string; }'.

Using DeepPartial<T> instead makes this assignment possible:

const myHouseNumber: DeepPartial<Person> = { address: { number: 52 } };

Installation

Just a quick npm install --save-dev @tomysmith/deep-partial@latest, or the Yarn equivalent.

1.0.1

3 years ago

1.0.0

3 years ago

0.4.0-0

3 years ago

0.3.0

3 years ago

0.1.0

3 years ago

0.2.0

3 years ago

0.0.0

3 years ago