-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix type issues with additional strict options (#82)
* fix type issues with additional strict options * Release 4.0.1-beta.0 * remove unnecessary `include`, which may be causing warning spam * Release 4.0.1-beta.1 * centralize all types in types-only file, and simplify `index.d.ts` consumption * Release 4.0.1-beta.2 * flip to have `index.d.ts` be the complete types definition, and import from that file into `src`, to prevent imports in the definitions file * Release 4.0.1-beta.3 * loosen type for `BaseCircularMeta.set`, since the return type is irrelevant and it may cause unexpected extension issues * update CHANGELOG * code cleanup * update size
- Loading branch information
1 parent
ba370bd
commit 54b9cb0
Showing
17 changed files
with
139 additions
and
139 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,58 @@ | ||
import type { | ||
circularDeepEqual as CircularDeepEqual, | ||
circularShallowEqual as CircularShallowEqual, | ||
createCustomEqual as CreateCustomEqual, | ||
createCustomCircularEqual as CreateCustomCircularEqual, | ||
deepEqual as DeepEqual, | ||
shallowEqual as ShallowEqual, | ||
sameValueZeroEqual as SameValueZeroEqual, | ||
} from './src/index'; | ||
|
||
export type { BaseCircularMeta, GetComparatorOptions } from './src/index'; | ||
export type { CreateComparatorCreatorOptions } from './src/comparator'; | ||
export type { | ||
EqualityComparator, | ||
EqualityComparatorCreator, | ||
InternalEqualityComparator, | ||
NativeEqualityComparator, | ||
TypeEqualityComparator, | ||
} from './src/utils'; | ||
|
||
export const circularDeepEqual: typeof CircularDeepEqual; | ||
export const circularShallowEqual: typeof CircularShallowEqual; | ||
export const createCustomEqual: typeof CreateCustomEqual; | ||
export const createCustomCircularEqual: typeof CreateCustomCircularEqual; | ||
export const deepEqual: typeof DeepEqual; | ||
export const shallowEqual: typeof ShallowEqual; | ||
export const sameValueZeroEqual: typeof SameValueZeroEqual; | ||
export interface BaseCircularMeta | ||
extends Pick<WeakMap<any, any>, 'delete' | 'get'> { | ||
set(key: object, value: any): any; | ||
} | ||
|
||
export interface CreateComparatorCreatorOptions<Meta> { | ||
areArraysEqual: TypeEqualityComparator<any, Meta>; | ||
areDatesEqual: TypeEqualityComparator<any, Meta>; | ||
areMapsEqual: TypeEqualityComparator<any, Meta>; | ||
areObjectsEqual: TypeEqualityComparator<any, Meta>; | ||
areRegExpsEqual: TypeEqualityComparator<any, Meta>; | ||
areSetsEqual: TypeEqualityComparator<any, Meta>; | ||
createIsNestedEqual: EqualityComparatorCreator<Meta>; | ||
} | ||
|
||
export type GetComparatorOptions<Meta> = ( | ||
defaultOptions: CreateComparatorCreatorOptions<Meta>, | ||
) => Partial<CreateComparatorCreatorOptions<Meta>>; | ||
|
||
export type InternalEqualityComparator<Meta> = ( | ||
a: any, | ||
b: any, | ||
indexOrKeyA: any, | ||
indexOrKeyB: any, | ||
parentA: any, | ||
parentB: any, | ||
meta: Meta, | ||
) => boolean; | ||
|
||
export type EqualityComparator<Meta> = Meta extends undefined | ||
? <A, B>(a: A, b: B, meta?: Meta) => boolean | ||
: <A, B>(a: A, b: B, meta: Meta) => boolean; | ||
|
||
export type EqualityComparatorCreator<Meta> = ( | ||
fn: EqualityComparator<Meta>, | ||
) => InternalEqualityComparator<Meta>; | ||
|
||
export type NativeEqualityComparator = <A, B>(a: A, b: B) => boolean; | ||
|
||
export type TypeEqualityComparator<Type, Meta> = ( | ||
a: Type, | ||
b: Type, | ||
isEqual: InternalEqualityComparator<Meta>, | ||
meta: Meta, | ||
) => boolean; | ||
|
||
export function circularDeepEqual<A, B>(a: A, b: B): boolean; | ||
export function circularShallowEqual<A, B>(a: A, b: B): boolean; | ||
export function deepEqual<A, B>(a: A, b: B): boolean; | ||
export function shallowEqual<A, B>(a: A, b: B): boolean; | ||
export function sameValueZeroEqual<A, B>(a: A, b: B): boolean; | ||
|
||
export function createCustomEqual<Meta = undefined>( | ||
getComparatorOptions: GetComparatorOptions<Meta>, | ||
): EqualityComparator<Meta>; | ||
export function createCustomEqual<Meta = WeakMap<any, any>>( | ||
getComparatorOptions: GetComparatorOptions<Meta>, | ||
): EqualityComparator<Meta>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -85,5 +85,5 @@ | |
}, | ||
"sideEffects": false, | ||
"types": "index.d.ts", | ||
"version": "4.0.0" | ||
"version": "4.0.1-beta.3" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.