Update LKG to enable improved narrowing in 4.4.#44842
Update LKG to enable improved narrowing in 4.4.#44842DanielRosenwasser merged 2 commits intomainfrom
Conversation
| ); | ||
| const expr = some(pendingExpressions) ? | ||
| factory.inlineExpressions(compact([...pendingExpressions!, node])) : | ||
| factory.inlineExpressions(compact([...pendingExpressions, node])) : |
There was a problem hiding this comment.
This one is actually unfortunate - pendingExpressions is actually typed as never because we have an earlier assignment of undefined followed by a check for some(...) which is a type predicate on readonly T[]. Since you can't narrow down a readonly T[] from an undefined, it leaves us with never.
The real culprit is #9998, but it is also strange that we just allow a spread of type never.
|
I did notice one opportunity for a new narrowing: accessing a property on a non-null value. When you write if (foo!.bar) {
// ...
}You shouldn't have to repeat the if (foo!.bar) {
foo.bar.baz()
}I think the only downside is that it's sometimes nice to ensure all uses of a variable look similar. |
sandersn
left a comment
There was a problem hiding this comment.
How did you find all the places to remove !? Did the linter point them out for you?
|
At first it was manual just to get a sense of some patterns it would/wouldn't catch, but then yes, I ran |
| "hashchange": HashChangeEvent; | ||
| "gamepadconnected": Event; | ||
| "gamepaddisconnected": Event; | ||
| "hashchange": Event; |
There was a problem hiding this comment.
Why this is changed to Evnet from HashChangeEvent?
There was a problem hiding this comment.
These are auto-generated, so they might need to be fixed up. Maybe @saschanaz or @orta have more context here.
There was a problem hiding this comment.
This got added back: microsoft/TypeScript-DOM-lib-generator#1104
| interface SVGElementInstance extends EventTarget { | ||
| readonly correspondingElement: SVGElement; | ||
| readonly correspondingUseElement: SVGUseElement; | ||
| } |
There was a problem hiding this comment.
These properties used to be available on SVGElement, which used to extend SVGElementInstance in LOC 12903. They disappeared during the upgrade from v4.3.5 to v4.4.2.
Reported here: microsoft/TypeScript-DOM-lib-generator#1023 (comment)
There was a problem hiding this comment.
Removal was intentional, as per microsoft/TypeScript-DOM-lib-generator#1023 (comment):
Those are not available on any modern browser nor MDN, and thus are probably IE-specific properties. The removal is intended since the types library intends to only include things that exist in modern browsers.
Fixes #44841.