If you has enable "noUncheckedIndexedAccess": true, in your project you can't compile Next.js projects because the package produce types error.
It can be fixed checking the index.
export function shuffle<TData>(array: TData[]): TData[] {
const shuffledArray = array;
for (let c = array.length - 1; c > 0; c--) {
const b = Math.floor(Math.random() * (c + 1));
const a = array[c];
// Added the ifs
if (array[b]) shuffledArray[c] = array[b];
if (a) shuffledArray[b] = a;
}
return shuffledArray;
}
Client
All
Version
5.8.1
Relevant log output
node_modules/@algolia/client-common/src/transporter/helpers.ts:11:5 - error TS2322: Type 'TData | undefined' is not assignable to type 'TData'.
'TData' could be instantiated with an arbitrary type which could be unrelated to 'TData | undefined'.
11 shuffledArray[c] = array[b];
~~~~~~~~~~~~~~~~
node_modules/@algolia/client-common/src/transporter/helpers.ts:12:5 - error TS2322: Type 'TData | undefined' is not assignable to type 'TData'.
'TData' could be instantiated with an arbitrary type which could be unrelated to 'TData | undefined'.
12 shuffledArray[b] = a;
~~~~~~~~~~~~~~~~
node_modules/@algolia/client-common/src/transporter/helpers.ts:71:5 - error TS2322: Type 'string | undefined' is not assignable to type 'string'.
Type 'undefined' is not assignable to type 'string'.
71 serializedHeaders[header.toLowerCase()] = value;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Found 3 errors in the same file, starting at: node_modules/@algolia/client-common/src/transporter/helpers.ts:11
Hey, thanks for reporting the issue! We shouldn't provide the typescript files in order to prevent those kind of issues, next release will contain the fix :)
Description
If you has enable
"noUncheckedIndexedAccess": true,
in your project you can't compile Next.js projects because the package produce types error.It can be fixed checking the index.
Client
All
Version
5.8.1
Relevant log output