You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Passing false to serialize gives typescript error #465
// Whether to serialize to JSON before/after persisting. Defaults to true.
serialize?: boolean,
but on trying to pass false, I get the tsc error:
(property) ApolloPersistOptions<NormalizedCacheObject, true>.serialize?: true | undefined
Type 'false' is not assignable to type 'true'.ts(2322)
index.d.ts(20, 5): The expected type comes from property 'serialize' which is declared here on type 'ApolloPersistOptions<NormalizedCacheObject, true>'
To get by this, I'm ignoring the error via a tsc annotation, but that definitely feels hacky and there didn't seem an obvious way to let tsc accept false.
I'll look into this, but not sooner than by the end of the week. @MasterOdin if you by any chance try working on #464, could you check whether the change above fixes the issue?
where TS is not smart enough to see that I'm passing it false in usage and bubble that upwards appropriately, rather it's forcing true | undefined from top down. I'm not sure what the best way to resolve this would be.
👋 I made a PR over in #471 to address this, TS does need to have the explicit link downward through generics typically, otherwise it'll use the default parameter (it's like calling a function with optional params, if you don't pass in a generic, you'll always get the default).
Activity
wodCZ commentedon Jul 26, 2022
Hi, thanks for the report.
I guess I messed something up in the
StorageTypeinference here:apollo-cache-persist/src/types/index.ts
Lines 21 to 23 in eded0ff
Maybe providing a
falsebranch is required:I'll look into this, but not sooner than by the end of the week. @MasterOdin if you by any chance try working on #464, could you check whether the change above fixes the issue?
Thanks!
MasterOdin commentedon Jul 26, 2022
I tried, and it did not resolve the problem. I think the problem lies with:
apollo-cache-persist/src/types/index.ts
Line 27 in eded0ff
where TS is not smart enough to see that I'm passing it
falsein usage and bubble that upwards appropriately, rather it's forcingtrue | undefinedfrom top down. I'm not sure what the best way to resolve this would be.pzuraq commentedon Sep 25, 2022
👋 I made a PR over in #471 to address this, TS does need to have the explicit link downward through generics typically, otherwise it'll use the default parameter (it's like calling a function with optional params, if you don't pass in a generic, you'll always get the default).