Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Module

x/actionify/src/deps/types.ts>HasOptionalKeys

Create and manage your GitHub workflows with TypeScript and Deno.
Latest
type alias HasOptionalKeys
import { type HasOptionalKeys } from "https://deno.land/x/actionify@0.3.0/src/deps/types.ts";

Creates a type that represents true or false depending on whether the given type has any optional fields.

This is useful when you want to create an API whose behavior depends on the presence or absence of optional fields.

Examples

Example 1

import type {HasOptionalKeys, OptionalKeysOf} from 'type-fest';

type UpdateService<Entity extends object> = {
	removeField: HasOptionalKeys<Entity> extends true
		? (field: OptionalKeysOf<Entity>) => Promise<void>
		: never
}

Type Parameters

BaseType extends object
definition: OptionalKeysOf<BaseType> extends never ? false : true