Repository navigation
Negated Types: Make conditional type produce substitutions with negated constraints in (some) false branches - #65034
Wesley Wigham (weswigham) wants to merge 24 commits into
Conversation
…t literal handling
Deduplicate fresh negations against their regular counterparts during union collection and intersection insertion. Preserve the first intersection position and ordered-set membership when replacing a fresh member, while leaving standalone fresh negations eligible for widening. Add compiler coverage for explicit exclusions, generic array narrowing, both union operand orders, and fresh-only widening.
…ntial structures, broaden negation reduction applicability
|
TypeScript Bot (@typescript-bot) test this |
|
Hey Wesley Wigham (@weswigham), the results of running the DT tests are ready. There were interesting changes: Branch only errors:
|
|
Wesley Wigham (@weswigham) Here are the results of running the user tests with tsc comparing Something interesting changed - please have a look. Details
|
|
Wesley Wigham (@weswigham) Here they are:
tscComparison Report - baseline..pr
System info unknown
Hosts
Scenarios
Developer Information: |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Wesley Wigham (@weswigham) Here are the results of running the top 400 repos with tsc comparing Something interesting changed - please have a look. Details
|
83e39e8 to
bd55784
Compare
|
TypeScript Bot (@typescript-bot) test this |
|
Hey Wesley Wigham (@weswigham), the results of running the DT tests are ready. There were interesting changes: Branch only errors:
|
|
Wesley Wigham (@weswigham) Here are the results of running the user tests with tsc comparing Something interesting changed - please have a look. Details
|
|
Wesley Wigham (@weswigham) Here are the results of running the top 400 repos with tsc comparing Something interesting changed - please have a look. Details
|
|
Wesley Wigham (@weswigham), the perf run you requested failed. You can check the log here. |
|
TypeScript Bot (@typescript-bot) pack this |
|
Hey, Wesley Wigham (@weswigham)! I've packed bd55784 into an installable package. You can install it for testing by referencing it in your {
"devDependencies": {
"typescript": "npm:@typescript-deploys/pr-build@7.1.0-pr.65034.6"
}
}and then running There is also a playground for this build. |
|
Experiment done, work will continue in #64375 - this one's on the fence - it's kinda breaky in the same way #65286 is, and it's unsound at the core concept, but the limited version here is somewhat passable if complex and makes some desired uses work. We might take it after #64984 merges to lower the break-factor. I'm inclined to keep it as a possible followup. |
This is... not really sound.
A -> Bbeing false does not implyA -> not Bis true. Still, for some comparisons, theextendscheck does effectively bifrucate the type-space like that, and there's a desire to have patterns likeT extends "A" ? SomethingNeedsA<T> : SomethingDefinitelyNotA<T>"just work".This PR introduces substitutions in conditionals whose check type are constrained to type parameters whose constraints are primitives that are always exactly in the
truebranch or thefalsebranch (basically, over lists of primitives that, in intersection-logic, are considered "closed enough to make never" - in the above example, a constraint onTlikeT extends "A" | "B" | "C"would be a sufficient constraint onTbecause that constraint can be precisely partitioned into the true and false sets for thatextendsclause without any overlap (you can't make an"A" & "B"that isn'tnever), making it safe to assume the negated constraint in the false branch).With that restriction, I think this hits a pretty good middleground between "wildly unsound but logically helpful" and "valid but unhelpful".