thrift-typescript icon indicating copy to clipboard operation
thrift-typescript copied to clipboard

fix type issue with map constants that reference other maps or sets

Open hayes opened this issue 5 years ago • 0 comments

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.

hayes avatar Feb 11 '20 22:02 hayes