Skip to main content
Module

x/ts_toolbelt_unofficial/mod.ts>Object.Update

👷 TypeScript's largest type utility library, now on Deno
Latest
type alias Object.Update
import { type Object } from "https://deno.land/x/ts_toolbelt_unofficial@1.1.0/mod.ts";
const { Update } = Object;

Update in O the fields of key K with A. Use the [[x]] placeholder to get the current field type.

Examples

Example 1

import {A, O} from 'ts-toolbelt.ts'

type User = {
 info: {
     name: string
     age: number
     payment: {}
 }
 id: number
}

type test0 = Update<User, 'id' | 'info', A.x | null>
// {
//     info: {
//         name: string;
//         age: number;
//         payment: {};
//     } | null;
//     id: number | null;
// }

Type Parameters

O extends object
K extends Key
A extends any
definition: [P in keyof O]: P extends K ? Replace<A, x, O[P]> : O[P] & { }