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
This union is bugged because it is in the wrong order (i.e. not sorted). This is because TypeDoc is just mirroring how TypeScript internally prints out the union.
Nathan Sanders explains that TypeScript does this internally because it builds the union data structure based on when the original types are first used. In other words, the type of 3 gets used first in the stdlib before the type of 1, so then are printed out in the order that the types are first added to the set.
Nathan also suggests that in principle this could be fixed in the TypeScript repo upstream by adding all of the types type A = 1; type B = 2; and so on in the first file of the stdlib so that they all get created in memory in order.
But for now, I propose that TypeDoc automatically sorts unions of numbers.
Steps to reproduce
Something like:
typeTest=[1,2,3][number]// ^? - type Test = 1 | 2 | 3
(it works on twoslash but not on the playground because they use different stdlibs)
The text was updated successfully, but these errors were encountered:
to start with, i would only sort number literals, as it would be the least arbitrary/contentious sorting. (i think doing baby steps and iterating later is good!)
i don't have strong opinions about the sorting algorithm for the other things you specified.
Expected Behavior
Typedoc produces a webpage like this:
This union is bugged because it is in the wrong order (i.e. not sorted). This is because TypeDoc is just mirroring how TypeScript internally prints out the union.
Nathan Sanders explains that TypeScript does this internally because it builds the union data structure based on when the original types are first used. In other words, the type of
3
gets used first in the stdlib before the type of1
, so then are printed out in the order that the types are first added to the set.Nathan also suggests that in principle this could be fixed in the TypeScript repo upstream by adding all of the types
type A = 1; type B = 2;
and so on in the first file of the stdlib so that they all get created in memory in order.But for now, I propose that TypeDoc automatically sorts unions of numbers.
Steps to reproduce
Something like:
(it works on twoslash but not on the playground because they use different stdlibs)
The text was updated successfully, but these errors were encountered: