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
When using Object/_api Paths with an object that contains an Array the output type will union with List<string | number | symbol>
Reproduce the bug
import{}from'ts-toolbelt'import{Paths}from'Object/_api'// Using Array<T> notationinterfacesimpleObj1{'prop': Array<number>}typeout1=Paths<simpleObj1>// type out1 = List<string | number | symbol> | ["prop"?, number?]// Using T[] notationinterfacesimpleObj2{'prop': number[]}typeout2=Paths<simpleObj2>// type out2 = List<string | number | symbol> | ["prop"?, number?]// Inferring types using typeofconstvalue={'props': [1,2,3,4,5]}typesimpleObj3=typeofvalue// type simpleObj3 = {// props: number[];// }typeout3=PathsO<simpleObj3>// type out3 = List<string | number | symbol> | ["props"?, number?]
Expected behavior
Expected the output type to be ['prop': number?] when using default Arrays without List<string | number | symbol>
// Expectation when inferring with typeof V or using T[] or Array<T> notationinterfacesimpleObj2{'prop': number[]}typeout2=Paths<simpleObj2>// type out2 = ["prop"?, number?]
Temporary Solution
// Using an interface arrayinterfacenumberArray{[key: number]: number}interfacesimpleObj4{'prop': numberArray}typeout4=Paths<simpleObj3>// type out4 = ['prop'?, number?]
馃悶 Bug Report
Describe the bug
When using Object/_api Paths with an object that contains an Array the output type will union with
List<string | number | symbol>
Reproduce the bug
Expected behavior
Expected the output type to be
['prop': number?]
when using default Arrays withoutList<string | number | symbol>
Temporary Solution
Additional context
Versions:
"ts-toolbelt": "8.0.7"
"typescript": "4.1.3"
Tools:
The text was updated successfully, but these errors were encountered: