Skip to content

Instantly share code, notes, and snippets.

Last active Aug 5, 2022
What would you like to do?
simple example of how re-shape an object definition in typescript
example of how to re-shape an object definition redefined the required and optional attributes
using the utilities types
interface IPerson {
id: string;
name: string;
age: number;
nationality: string;
type IPersonRequiredFields = Required<Pick<IPerson, 'id' | 'name'>> & Partial<Omit<IPerson, 'id' | 'name'>>;
const me: IPersonRequiredFields = {
id: "123",
name: "It's Me Mario",
age: 30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment