Skip to content

Commit 7b4f7a4

Browse files
committed
Update/add utility types
1 parent 9b18400 commit 7b4f7a4

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

packages/core/src/types.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,11 @@ import type { UnpluginOptions } from 'unplugin';
2424

2525
import type { ALL_ENVS, FULL_NAME_BUNDLERS, SUPPORTED_BUNDLERS } from './constants';
2626

27+
// Re-assign B into A.
2728
export type Assign<A, B> = Omit<A, keyof B> & B;
28-
export type WithRequired<T, K extends keyof T> = T & { [P in K]-?: T[P] };
29+
// Type object with specified keys required.
30+
export type Ensure<T, K extends keyof T> = Assign<T, Required<Pick<T, K>>>;
31+
// Target one item from an iterable.
2932
export type IterableElement<IterableType extends Iterable<unknown>> =
3033
IterableType extends Iterable<infer ElementType> ? ElementType : never;
3134

0 commit comments

Comments
 (0)