Skip to content

Commit

Permalink
Revert "Update DeepBrand to improve type checking capabilities (#18)"
Browse files Browse the repository at this point in the history
This reverts commit 304a54b.
  • Loading branch information
trevorade committed Oct 31, 2022
1 parent 304a54b commit a6d1f99
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 251 deletions.
19 changes: 2 additions & 17 deletions src/index.ts
Expand Up @@ -36,41 +36,26 @@ export type DeepBrand<T> = IsNever<T> extends true
type: 'constructor'
params: ConstructorParams<T>
instance: DeepBrand<InstanceType<Extract<T, new (...args: any) => any>>>
readonly: ReadonlyKeys<T>
required: RequiredKeys<T>
optional: OptionalKeys<T>
value: T
properties: {[K in keyof T]: DeepBrand<T[K]>}
}
: T extends (...args: infer P) => infer R // avoid functions with different params/return values matching
? {
type: 'function'
params: DeepBrand<P>
return: DeepBrand<R>
this: DeepBrand<ThisParameterType<T>>
readonly: ReadonlyKeys<T>
required: RequiredKeys<T>
optional: OptionalKeys<T>
value: T
properties: {[K in keyof T]: DeepBrand<T[K]>}
}
: T extends any[]
? {
type: 'array'
readonly: ReadonlyKeys<T>
required: RequiredKeys<T>
optional: OptionalKeys<T>
value: T
properties: {[K in keyof T]: DeepBrand<T[K]>}
items: {[K in keyof T]: T[K]}
}
: {
type: 'object'
properties: {[K in keyof T]: DeepBrand<T[K]>}
readonly: ReadonlyKeys<T>
required: RequiredKeys<T>
optional: OptionalKeys<T>
constructorParams: DeepBrand<ConstructorParams<T>>
value: T
properties: {[K in keyof T]: DeepBrand<T[K]>}
}

export type RequiredKeys<T> = Extract<
Expand Down

0 comments on commit a6d1f99

Please sign in to comment.