fast-equals: TypeScript errors with v4
The latest version results in a bunch of errors when TypeScript is configured with the following settings:
tsconfig.json
{
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "./",
"outDir": "./dist/out-tsc",
"forceConsistentCasingInFileNames": true,
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noImplicitOverride": true,
"noPropertyAccessFromIndexSignature": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"sourceMap": true,
"declaration": false,
"downlevelIteration": true,
"experimentalDecorators": true,
"moduleResolution": "node",
"importHelpers": true,
"target": "es2020",
"module": "es2020",
"lib": ["es2020", "dom"],
"types": ["node"]
}
}
Errors when trying to compile:
Error: node_modules/fast-equals/src/index.ts:48:7 - error TS2322: Type 'Readonly<CreateComparatorCreatorOptions<undefined> & { areArraysEqual: (a: any[], b: any[], isEqual: InternalEqualityComparator<any>, meta: any) => boolean; areMapsEqual: (a: Map<...>, b: Map<...>, isEqual: InternalEqualityComparator<...>, meta: any) => boolean; areObjectsEqual: (a: Dictionary<...>, b: Dictionary<.....' is not assignable to type 'CreateComparatorCreatorOptions<WeakMap<object, any>>'.
Types of property 'areDatesEqual' are incompatible.
Type 'TypeEqualityComparator<Date, undefined>' is not assignable to type 'TypeEqualityComparator<Date, WeakMap<object, any>>'.
Types of parameters 'isEqual' and 'isEqual' are incompatible.
Types of parameters 'meta' and 'meta' are incompatible.
Type 'undefined' is not assignable to type 'WeakMap<object, any>'.
48 const DEFAULT_CIRCULAR_CONFIG: CreateComparatorCreatorOptions<
~~~~~~~~~~~~~~~~~~~~~~~
Error: node_modules/fast-equals/src/index.ts:113:48 - error TS2345: Argument of type 'CreateComparatorCreatorOptions<undefined>' is not assignable to parameter of type 'CreateComparatorCreatorOptions<Meta>'.
Types of property 'areArraysEqual' are incompatible.
Type 'TypeEqualityComparator<any[], undefined>' is not assignable to type 'TypeEqualityComparator<any[], Meta>'.
Types of parameters 'isEqual' and 'isEqual' are incompatible.
Types of parameters 'meta' and 'meta' are incompatible.
Type 'undefined' is not assignable to type 'Meta'.
'Meta' could be instantiated with an arbitrary type which could be unrelated to 'undefined'.
113 merge(DEFAULT_CONFIG, getComparatorOptions(DEFAULT_CONFIG)),
~~~~~~~~~~~~~~
Error: node_modules/fast-equals/src/objects.ts:39:33 - error TS4111: Property '$$typeof' comes from an index signature, so it must be accessed with ['$$typeof'].
39 const reactElementA = !!a.$$typeof;
~~~~~~~~
Error: node_modules/fast-equals/src/objects.ts:40:33 - error TS4111: Property '$$typeof' comes from an index signature, so it must be accessed with ['$$typeof'].
40 const reactElementB = !!b.$$typeof;
~~~~~~~~
Error: node_modules/fast-equals/src/utils.ts:38:5 - error TS6133: 'indexOrKeyA' is declared but its value is never read.
38 indexOrKeyA: any,
~~~~~~~~~~~
Error: node_modules/fast-equals/src/utils.ts:39:5 - error TS6133: 'indexOrKeyB' is declared but its value is never read.
39 indexOrKeyB: any,
~~~~~~~~~~~
Error: node_modules/fast-equals/src/utils.ts:40:5 - error TS6133: 'parentA' is declared but its value is never read.
40 parentA: any,
~~~~~~~
Error: node_modules/fast-equals/src/utils.ts:41:5 - error TS6133: 'parentB' is declared but its value is never read.
41 parentB: any,
~~~~~~~
I already tried adding "skipLibCheck": true to compilerOptions but it did not fix it.
Downgrading to version v3.0.3 fixes this issue.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 17 (7 by maintainers)
@HitomiTenshi - your help was greatly appreciated, and at a very late hour for you on top of that! Well, the fruits of our labor are available in
4.0.1, which I just published. If you have any more issues, let me know!@HitoriSensei - I believe it may be related to the fact that the
fast-equalstsconfig.jsonhad anincludesdefinition pointing tosrc, which was not necessary. I’ve published an update to the beta patch (4.0.1-beta.1), and consuming it as a dependency with the same options you have above does not give me any errors. Give that a try and let me know if the warnings stop.Similar issues with TypeScript
4.8.0-dev.20220605(NPM release tagnext)(same errors with
skipLibCheckintsconfig.json)