Skip to content

Commit

Permalink
chore: Upgrade prettier to v3.1.0 (#649)
Browse files Browse the repository at this point in the history
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Valentin Agachi <[email protected]>
  • Loading branch information
renovate[bot] and avaly authored Nov 16, 2023
1 parent 3f56778 commit 9fe42ae
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 74 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
"mongodb-memory-server": "9.0.1",
"mongoose": "7.5.2",
"pinst": "3.0.0",
"prettier": "3.0.3",
"prettier": "3.1.0",
"standard-version": "9.5.0",
"ts-expect": "1.3.0",
"ts-node": "10.9.1",
Expand Down
14 changes: 7 additions & 7 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/DeepPick.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ type Primitive = boolean | number | string | symbol | null | undefined;
export type DeepPick<Type, Paths extends string> = Type extends Binary | Date | ObjectId | Primitive
? Type
: Type extends (infer ArrayItem)[]
? DeepPick<ArrayItem, ArrayItemKeys<Paths>>[]
: Pick<InnerPick<Type, Paths>, HeadPaths<Paths> & UnionKeyOf<Type>>;
? DeepPick<ArrayItem, ArrayItemKeys<Paths>>[]
: Pick<InnerPick<Type, Paths>, HeadPaths<Paths> & UnionKeyOf<Type>>;
4 changes: 2 additions & 2 deletions src/TupleItems.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ type TupleSplit<
> = Result['length'] extends Position
? Result
: Items extends readonly [infer First, ...infer Rest]
? TupleSplit<readonly [...Rest], Position, [...Result, NonNullable<First>]>
: Result;
? TupleSplit<readonly [...Rest], Position, [...Result, NonNullable<First>]>
: Result;

export type TupleItems<
Type extends readonly unknown[],
Expand Down
124 changes: 62 additions & 62 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ type TimestampSchemaProperty<
? TOptions[TProperty]
: TProperty
: TOptions extends false
? never
: TProperty;
? never
: TProperty;

export type TimestampSchema<TOptions extends SchemaTimestampOptions | undefined> = {
[key in
Expand Down Expand Up @@ -95,39 +95,39 @@ export type Flatten<Type extends object> = Identity<{
export type NestedPaths<Type, Depth extends number[]> = Depth['length'] extends 6
? []
: Type extends
| Buffer
| Date
| RegExp
| Uint8Array
| boolean
| number
| string
// eslint-disable-next-line @typescript-eslint/no-explicit-any
| ((...args: any[]) => any)
| {
_bsontype: string;
}
? []
: Type extends readonly (infer ArrayType)[]
? // This returns the non-indexed dot-notation path: e.g. `foo.bar`
| [...NestedPaths<ArrayType, [...Depth, 1]>]
// This returns the array parent itself: e.g. `foo`
| []
// This returns the indexed dot-notation path: e.g. `foo.0.bar`
| [number, ...NestedPaths<ArrayType, [...Depth, 1]>]
// This returns the indexed element path: e.g. `foo.0`
| [number]
: // eslint-disable-next-line @typescript-eslint/no-explicit-any
Type extends Map<string, any>
? [string]
: Type extends object
? {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
[Key in Extract<keyof Type, string>]: Type[Key] extends readonly any[]
? [Key, ...NestedPaths<Type[Key], [...Depth, 1]>] // child is not structured the same as the parent
: [Key, ...NestedPaths<Type[Key], [...Depth, 1]>] | [Key];
}[Extract<keyof Type, string>]
: [];
| Buffer
| Date
| RegExp
| Uint8Array
| boolean
| number
| string
// eslint-disable-next-line @typescript-eslint/no-explicit-any
| ((...args: any[]) => any)
| {
_bsontype: string;
}
? []
: Type extends readonly (infer ArrayType)[]
? // This returns the non-indexed dot-notation path: e.g. `foo.bar`
| [...NestedPaths<ArrayType, [...Depth, 1]>]
// This returns the array parent itself: e.g. `foo`
| []
// This returns the indexed dot-notation path: e.g. `foo.0.bar`
| [number, ...NestedPaths<ArrayType, [...Depth, 1]>]
// This returns the indexed element path: e.g. `foo.0`
| [number]
: // eslint-disable-next-line @typescript-eslint/no-explicit-any
Type extends Map<string, any>
? [string]
: Type extends object
? {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
[Key in Extract<keyof Type, string>]: Type[Key] extends readonly any[]
? [Key, ...NestedPaths<Type[Key], [...Depth, 1]>] // child is not structured the same as the parent
: [Key, ...NestedPaths<Type[Key], [...Depth, 1]>] | [Key];
}[Extract<keyof Type, string>]
: [];

type FilterProperties<TObject, TValue> = Pick<TObject, KeysOfAType<TObject, TValue>>;

Expand All @@ -139,13 +139,13 @@ export type ProjectionType<
> = undefined extends Projection
? WithId<TSchema>
: keyof FilterProperties<Projection, 0 | 1> extends never
? WithId<DeepPick<TSchema, '_id' | (string & keyof Projection)>>
: keyof FilterProperties<Projection, 1> extends never
? Omit<WithId<TSchema>, keyof FilterProperties<Projection, 0>>
: Omit<
WithId<DeepPick<TSchema, '_id' | (string & keyof Projection)>>,
keyof FilterProperties<Projection, 0>
>;
? WithId<DeepPick<TSchema, '_id' | (string & keyof Projection)>>
: keyof FilterProperties<Projection, 1> extends never
? Omit<WithId<TSchema>, keyof FilterProperties<Projection, 0>>
: Omit<
WithId<DeepPick<TSchema, '_id' | (string & keyof Projection)>>,
keyof FilterProperties<Projection, 0>
>;

export type Projection<TSchema> = Partial<
Record<Join<NestedPaths<WithId<TSchema>, []>, '.'>, number>
Expand All @@ -161,32 +161,32 @@ export type PropertyNestedType<
? PropertyType<ArrayType, Rest>
: unknown
: // object nested properties & non-indexed array nested properties
Key extends keyof Type
? Type[Key] extends Map<string, infer MapType>
? MapType
: PropertyType<NonNullable<Type[Key]>, Rest>
: unknown
Key extends keyof Type
? Type[Key] extends Map<string, infer MapType>
? MapType
: PropertyType<NonNullable<Type[Key]>, Rest>
: unknown
: unknown;

export type PropertyType<Type, Property extends string> = string extends Property
? unknown
: // object properties
Property extends keyof Type
? // eslint-disable-next-line @typescript-eslint/no-explicit-any
Type extends Record<string, any>
? Property extends `${string}.${string}`
? PropertyNestedType<NonNullable<Type>, Property>
Property extends keyof Type
? // eslint-disable-next-line @typescript-eslint/no-explicit-any
Type extends Record<string, any>
? Property extends `${string}.${string}`
? PropertyNestedType<NonNullable<Type>, Property>
: Type[Property]
: Type[Property]
: Type[Property]
: Type extends readonly (infer ArrayType)[]
? // indexed array properties
Property extends `${number}`
? ArrayType
: // non-indexed array properties
Property extends keyof ArrayType
? PropertyType<ArrayType, Property>
: PropertyNestedType<NonNullable<Type>, Property>
: PropertyNestedType<NonNullable<Type>, Property>;
: Type extends readonly (infer ArrayType)[]
? // indexed array properties
Property extends `${number}`
? ArrayType
: // non-indexed array properties
Property extends keyof ArrayType
? PropertyType<ArrayType, Property>
: PropertyNestedType<NonNullable<Type>, Property>
: PropertyNestedType<NonNullable<Type>, Property>;

export type RequireAtLeastOne<TObj, Keys extends keyof TObj = keyof TObj> = {
[Key in Keys]-?: Partial<Pick<TObj, Exclude<Keys, Key>>> & Required<Pick<TObj, Key>>;
Expand Down

0 comments on commit 9fe42ae

Please sign in to comment.