@loopback/docs
Version:
Documentation for LoopBack 4
33 lines (20 loc) • 1.11 kB
Markdown
---
lang: en
title: 'API docs: repository-json-schema.optional'
keywords: LoopBack 4.0, LoopBack 4
sidebar: lb4_sidebar
editurl: https://github.com/strongloop/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) > [@loopback/repository-json-schema](./repository-json-schema.md) > [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
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'<!-- -->><!-- -->;