UNPKG

@loopback/docs

Version:

Documentation files rendered at [https://loopback.io](https://loopback.io)

42 lines (28 loc) 1.12 kB
--- lang: en title: 'API docs: repository-json-schema.optional' keywords: LoopBack 4.0, LoopBack 4, Node.js, TypeScript, OpenAPI sidebar: lb4_sidebar editurl: https://github.com/loopbackio/loopback-next/tree/master/packages/repository-json-schema permalink: /doc/en/lb4/apidocs.repository-json-schema.optional.html --- <!-- Do not edit this file. It is automatically generated by API Documenter. --> [Home](./index.md) &gt; [@loopback/repository-json-schema](./repository-json-schema.md) &gt; [Optional](./repository-json-schema.optional.md) ## Optional type Optional: From `T` make a set of properties by key `K` become optional <b>Signature:</b> ```typescript export declare type Optional<T extends object, K extends keyof T = keyof T> = Omit<T, K> & Partial<Pick<T, K>>; ``` ## Example ```ts type Props = { name: string; age: number; visible: boolean; }; // Expect: { name?: string; age?: number; visible?: boolean; } type Props = Optional<Props>; // Expect: { name: string; age?: number; visible?: boolean; } type Props = Optional<Props, 'age' | 'visible'>; ```