Skip to content

Latest commit

 

History

History
27 lines (20 loc) · 613 Bytes

required-x.md

File metadata and controls

27 lines (20 loc) · 613 Bytes
category alias
X Series
RequiredByKeys

PartialX

Constructs a type by setting the properties specified by K(string literal or union of string literals) to required from T.

Usage

import type { RequiredX } from '@utype/core'

type Props = {
  name?: string;
  age?: number;
  visible?: boolean;
}

// Expect: { name: string; age: number; visible?: boolean; } // [!code highlight]
type RequiredXProps = RequiredX<Props, 'name' | 'age'>
// @ts-expect-error
type Error = RequiredX<Props, "sports"> // [!code error]