Typecheck doesn't pass on the library init. Cannot start running the app
ERROR in node_modules/getstream/src/utils.ts:103:15
TS2769: No overload matches this call.
Overload 1 of 2, '(o: {}): string[]', gave the following error.
Argument of type 'T' is not assignable to parameter of type '{}'.
Overload 2 of 2, '(o: object): string[]', gave the following error.
Argument of type 'T' is not assignable to parameter of type 'object'.
101 | const cloned = {};
102 |
> 103 | Object.keys(obj).forEach((k) => {
| ^^^
104 | // @ts-expect-error
105 | cloned[k] = replaceStreamObjects(obj[k]);
106 | });
**To Reproduce**
Version of React and TS
"react": "^18.0.0",
"typescript": "^4.9.4",
"@typescript-eslint/eslint-plugin": "^5.48.0",
"@typescript-eslint/parser": "^5.40.0",
Simple fix solution:
In getstream/src/utils.ts
// TODO: refactor and add proper types
function replaceStreamObjects<T, V>(obj: T): V {
// @ts-expect-error
if (Array.isArray(obj)) return obj.map((v) => replaceStreamObjects(v));
// @ts-expect-error
if (Object.prototype.toString.call(obj) !== '[object Object]') return obj;
// @ts-expect-error
if (typeof obj.ref === 'function') return obj.ref();
const cloned = {};
// @ts-expect-error <--------- ADDITIONAL COMMENT TO FIX THE ERROR
Object.keys(obj).forEach((k) => {
// @ts-expect-error
cloned[k] = replaceStreamObjects(obj[k]);
});
// @ts-expect-error
return cloned;
}
Typecheck doesn't pass on the library init. Cannot start running the app
Version of React and TS "react": "^18.0.0", "typescript": "^4.9.4", "@typescript-eslint/eslint-plugin": "^5.48.0", "@typescript-eslint/parser": "^5.40.0",
Simple fix solution: In getstream/src/utils.ts