thrift-typescript
thrift-typescript copied to clipboard
fix type issue with map constants that reference other maps or sets
The initializer arrays for generated map constants don't always type check correctly.
Basically the issue happens when the inferred type of 2 map entries are different
const map: Map<string, Set<Enum> = new Map<[
['abc', new Set([Enum.One], // [string, Set<1>]
['abc', new Set([Enum.Two], // [string, Set<2>]
]) // error with something like (['abc', new Set([Enum.Two] || [string, Set<2>])[] is not assignable to [string, Set<Set<Enum>][]
Adding explicit type to the map fixes this.