Skip to content

Commit

Permalink
chore: format for 1.21.1 (denoland#2385)
Browse files Browse the repository at this point in the history
  • Loading branch information
dsherret committed Jun 24, 2022
1 parent 67981a5 commit d4485a2
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 41 deletions.
10 changes: 5 additions & 5 deletions _util/assert_type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ export function assertType<T extends true | false>(_expectTrue: T) {}
*/
export type IsExact<T, U> = TupleMatches<AnyToBrand<T>, AnyToBrand<U>> extends
true ? TupleMatches<
DeepMakeRequiredForIsExact<T>,
DeepMakeRequiredForIsExact<U>
> extends true // catch optional properties
? true
: false
DeepMakeRequiredForIsExact<T>,
DeepMakeRequiredForIsExact<U>
> extends true // catch optional properties
? true
: false
: false;

type DeepMakeRequiredForIsExact<T> = {
Expand Down
66 changes: 33 additions & 33 deletions flags/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,16 @@ type Values<
D extends Record<string, unknown> | undefined,
A extends Aliases | undefined,
> = UseTypes<B, S, C> extends true ?
& Record<string, unknown>
& AddAliases<
SpreadDefaults<
& CollectValues<S, string, C, N>
& RecursiveRequired<CollectValues<B, boolean, C>>
& CollectUnknownValues<B, S, C, N>,
DedotRecord<D>
>,
A
>
& Record<string, unknown>
& AddAliases<
SpreadDefaults<
& CollectValues<S, string, C, N>
& RecursiveRequired<CollectValues<B, boolean, C>>
& CollectUnknownValues<B, S, C, N>,
DedotRecord<D>
>,
A
>
: // deno-lint-ignore no-explicit-any
Record<string, any>;

Expand Down Expand Up @@ -89,14 +89,14 @@ type AliasName<
*/
type SpreadDefaults<A, D> = D extends undefined ? A
: A extends Record<string, unknown> ?
& Omit<A, keyof D>
& {
[K in keyof D]: K extends keyof A
? (A[K] & D[K] | D[K]) extends Record<string, unknown>
? NonNullable<SpreadDefaults<A[K], D[K]>>
: D[K] | NonNullable<A[K]>
: unknown;
}
& Omit<A, keyof D>
& {
[K in keyof D]: K extends keyof A
? (A[K] & D[K] | D[K]) extends Record<string, unknown>
? NonNullable<SpreadDefaults<A[K], D[K]>>
: D[K] | NonNullable<A[K]>
: unknown;
}
: never;

/**
Expand All @@ -120,8 +120,8 @@ type MapDefaults<T extends ArgType> = Partial<
>;

type RecursiveRequired<T> = T extends Record<string, unknown> ? {
[K in keyof T]-?: RecursiveRequired<T[K]>;
}
[K in keyof T]-?: RecursiveRequired<T[K]>;
}
: T;

/** Same as `MapTypes` but also supports collectable options. */
Expand All @@ -132,23 +132,23 @@ type CollectValues<
N extends Negatable = undefined,
> = UnionToIntersection<
C extends string ?
& MapTypes<Exclude<T, C>, V, N>
& (T extends undefined ? Record<never, never> : RecursiveRequired<
MapTypes<Extract<C, T>, Array<V>, N>
>)
& MapTypes<Exclude<T, C>, V, N>
& (T extends undefined ? Record<never, never> : RecursiveRequired<
MapTypes<Extract<C, T>, Array<V>, N>
>)
: MapTypes<T, V, N>
>;

/** Same as `Record` but also supports dotted and negatable options. */
type MapTypes<T extends ArgType, V, N extends Negatable = undefined> =
undefined extends T ? Record<never, never>
: T extends `${infer Name}.${infer Rest}` ? {
[K in Name]?: MapTypes<
Rest,
V,
N extends `${Name}.${infer Negate}` ? Negate : undefined
>;
}
[K in Name]?: MapTypes<
Rest,
V,
N extends `${Name}.${infer Negate}` ? Negate : undefined
>;
}
: T extends string ? Partial<Record<T, N extends T ? V | false : V>>
: Record<never, never>;

Expand Down Expand Up @@ -180,10 +180,10 @@ type CollectUnknownValues<
/** Converts `{ "foo.bar.baz": unknown }` into `{ foo: { bar: { baz: unknown } } }`. */
type DedotRecord<T> = Record<string, unknown> extends T ? T
: T extends Record<string, unknown> ? UnionToIntersection<
ValueOf<
{ [K in keyof T]: K extends string ? Dedot<K, T[K]> : never }
ValueOf<
{ [K in keyof T]: K extends string ? Dedot<K, T[K]> : never }
>
>
>
: T;

type Dedot<T extends string, V> = T extends `${infer Name}.${infer Rest}`
Expand Down
6 changes: 3 additions & 3 deletions node/_stream.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1157,9 +1157,9 @@ type PipelineDestinationPromiseFunction<T, P> = (
) => Promise<P>;
type PipelineDestination<S extends PipelineTransformSource<any>, P> = S extends
PipelineTransformSource<infer ST> ?
| WritableStream
| PipelineDestinationIterableFunction<ST>
| PipelineDestinationPromiseFunction<ST, P>
| WritableStream
| PipelineDestinationIterableFunction<ST>
| PipelineDestinationPromiseFunction<ST, P>
: never;
type PipelineCallback<S extends PipelineDestination<any, any>> = S extends
PipelineDestinationPromiseFunction<any, infer P>
Expand Down

0 comments on commit d4485a2

Please sign in to comment.