Skip to content

Commit

Permalink
enh: Change hasProperty test to use new Util
Browse files Browse the repository at this point in the history
  • Loading branch information
eythaann committed Oct 2, 2023
1 parent 174d70b commit 5a09fcf
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/modules/objects/infrastructure.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ export type OptionalKeys<Type> = {
* type U = HasProperty<{ a?: 'a'; b?: 'b'; c: 'c' }, 'c'>
* // ^? true
*/
export type HasProperty<T, K extends KeyOfObject> = K extends KeysOfUnion<T> ? true : false;
export type HasProperty<T, K> = K extends KeysOfUnion<T> ? true : false;

/**
* Convert specific properties of an object `T` to readonly.
Expand Down
3 changes: 2 additions & 1 deletion lib/readable-test-types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
IsFalse,
AnyObject,
Opaque,
HasProperty,
} from '../modules/infrastructure';
import { FailMsgs } from './messages';

Expand Down Expand Up @@ -120,7 +121,7 @@ interface IValidationsPublic<T, I extends boolean = false> {
toBePromise: propertyCallableOnPass<IsPromise<T>, I, 'promise'>;

/** Type should has the property passed */
toHaveProperty: <U extends InvertIf<I, Not<IsUnknown<ForceExtract<T, U>>>> extends true ? Readonly<string> : FAIL<FailMsgs<I>['property']>>(v?: U) => void;
toHaveProperty: <U extends InvertIf<I, HasProperty<T, U>> extends true ? Readonly<string> : FAIL<FailMsgs<I>['property']>>(v?: U) => void;
}

type IValidationsInternal<T> = IValidationsPublic<T> & {
Expand Down

0 comments on commit 5a09fcf

Please sign in to comment.