Description
Consistent Union Type Sorting
(sometimes referred to as "deterministic")
- Tools depend on type print-back, but union types are ordered by internal IDs assigned to types.
- Sometimes, the union
1 | 2
gets printed back as2 | 1
because the numeric literal type2
gets created first! - Should we just sort them?
- Efficient way, inefficient way.
- Efficient: Could find a reasonable sorting strategy
- Inefficient: Print them individually, sort by string representation.
- Conclusion:
- Wow, we actually are okay with committing to trying this???
- Congrats community!
What goes in lib.dom.d.ts, exactly?
- We want to have an up-to-date
lib.dom.d.ts
, but we want to limitlib.dom.d.ts
to features that are broadly implemented and stable. - WHATWG keeps adding features in their spec, but no other browser adds those features - how do you determine what is "spec" vs. "immediate web reality" (or even "eventual web reality")?
- W3C takes a bit of time to adopt certain features, so that isn't enough for
lib.dom.d.ts
consumers. - Today, 20-30 IDL files downloaded from WHATWG/W3C
- What if the strategy was to just give the corresponding
.d.ts
file from each of these. - Maybe separately concat like today to create
lib.dom.d.ts
, but let people opt in individually?- Can take
lib.dom.d.ts
, or grab the individual declarations from@types
.
- Can take
- What if the strategy was to just give the corresponding
- You can have TypeScript itself depend on
@types/dom
- But how do you depend on differing dependencies, one package relies on v1, TS relies on v2.
- Safe strategy is to break apart first, then consider
@types
. - Then maybe could have
lib.dom.actuallyhtml5.d.ts
(exaggerated name),lib.dom.stable.d.ts
, and then loop them all together inlib.dom.d.ts
. - Seems strange to make
lib.dom.d.ts
to have all the stuff - lots of web developers need to be careful to be maximally compatible. Want to know when browser X implements stuff, browser Y doesn't. Testing only in browser X reinforces this.- New features can be opt in if you need something.
- Bleeding edge users may be okay with that.
- Making default opt-out for footguns has been bad with
@types
, consider the same here.
- Making default opt-out for footguns has been bad with
- Can we even split? The generator is very complicated.
- Speculative right now.
- But have to see.
- Conclusion:
- Need to investigate whether the DOM generation code can actually generate multiple files.
Getting TSServer Working in WebWorkers
- Have an alternate
sys
for these files. - Currently only working in partial semantic mode.
- Logger: goes to the console, but need to have something less noisy.
- Otherwise, works!
- PR has instructions for getting it working.
void
Properties are Optional
-
Not type-safe to make
value
optional onIteratorResult<T>
. -
Tried to add a conditional that checked if
T
wasvoid
, then made it optional.- Broke fp-ts, other stuff.
-
Tried something else, broke almost nothing:
void
makes properties optional. -
void
means "I won't witness this." -
Some argue this should be illegal.
function f(): number | void { // ... }
-
void
in a return type only allowsundefined
or no explicit return value. -
Otherwise,
void
is "I will not witness this value" -
void
needs to have consistent behavior between generators yield values and return values. -
But is consistency on this point more important than usefulness?
- People keep messing up how void works.
-
What's the difference between
void
andunknown
?- At runtime, every function returns something.
-
void | Promise<void>
- kind of like hacky negated types- Either a
Promise
or something you should really never look at, but is not aPromise
.
- Either a
-
We need a consistent viewpoint on what
void
is.- "We keep twerking it around".
- [[I know they meant "tweaking", but I'm going to keep this in the notes because I thought it was funny.]]
- "We keep twerking it around".
-
Another option:
undefined
makes things optionalvoid
should be switched out withundefined
in implementations.unknown
in declarations for callback return position- Something along these lines - Ryan is willing to experiment.
-
Relevant:
missing
-
Conclusion:
- Experiment with variations so we can make an informed comparison between both options.