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
functiongetAllValuesUnsorted(m: ReadonlyArray<ReadonlyArray<string>>): ReadonlyArray<string>{// OKreturnArray.from(flatten(m.values()))}functiongetAllValuesSorted(m: ReadonlyArray<ReadonlyArray<string>>): ReadonlyArray<string>{// Type 'unknown[]' is not assignable to type 'readonly string[]'.returnArray.from(flatten(m.values())).sort()}function*flatten<T>(a: Iterable<Iterable<T>>): Iterable<T>{for(constxsofa)for(constxofxs)yieldx}
Expected behavior:
No error.
Actual behavior:
a.ts:6:2 - error TS2322: Type 'unknown[]' is not assignable to type 'readonly string[]'.
Type 'unknown' is not assignable to type 'string'.
Reacted by Bruce Pascoe and Titian Cernicova-Dragomir
Activity
RyanCavanaugh commentedon Oct 30, 2019
Presumably generic inference isn't lining up the
thisthrough the return type ofsortto produce an inference candidate forflatten