Design Meeting Notes, 2026-08-27
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Anfängerfreundlichkeit
- 25/100
- Issue-Typ
- Dokumentation
- Klarheit
- Muss geklärt werden
- Aktivitätsstatus
- Veraltet
- Tech-Stack
- typescript
- Bereich
- compilers, documentation
Rechercherichtung
Beginne damit, die Besprechungsnotizen und den verknüpften PR #63926 zu lesen, mit Schwerpunkt auf negierten Typen, der Kontrollflussverengung, Aliasen und optionalen Eigenschaften. Die Notizen enthalten offene Designfragen, nennen jedoch keine Dateien, Tests, Einstiegspunkte oder Abschlusskriterien, daher wären vor der Implementierung weitere Diskussionen und ein festgelegter Umfang erforderlich.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Negated Types (not T)
https://github.com/microsoft/TypeScript/pull/63926
- If you think about a venn diagram of
AandBoverlapping whereA & Bis the overlap,not Ais all the area outside ofA,not (A & B)is the inverse color of that original overlap. - Fresh object types are closed -
- Talked about this before, have a feeling it's more relevant today.
- Like what?
-
Something like a
--noUnusedReturnedValues-
Don't want to forget
-
People use
void, but this acceptsPromises that need to beawaited. -
Can have an
ignoreto help here.function ignore(value: not PromiseLike<unknown>): void {}
-
-
`foo${string & not "reserved-key"}`Record<`on${string & not keyof EventNames}`, unknown>
-
Can also do narrowing for carve outs of infinite sets.
function divide(a: number, b: number & not 0): number { return a / b; } function doStuff(someValue: number) { if (someValue !== 0) { divide(10, x); // Okay // (come back to this below) const x = someValue; divide(10, x); // ... } else { divide(10, someValue); // Should error! } }- Okay, but how does that work with aliases
- Currently an alias loses that information.
- That is super surprising.
- Okay, but how does that work with aliases
-
- What are the old issues that this avoids?
- We had a prototype that swapped out our fact-tracking system in control flow analysis and replaced it with negated type tracking.
- But this was computationally intensive.
- This PR introduces negations only for specific types of control flow narrowing in the false branch where we needed to track that info.
- Only requests negation when a use-site of a binding needs negation.
- Done based on the contextual type at that use-site.
- We actually have similar logic here for when we narrow generic parameters in the body of a function!
- Very similar precedent here.
- Do you want the most precise type to be inferred
- e.g. type narrowing conditionals (come back to this?)
- We also infer type predicates for you now.
- Negated types seem useful over the set of primitives, and often works well enough in the object hierarchy, but doesn't really make sense to have a provable negated object type.
- An
objectdoesn't necessarily exclude aPromiseor aFunction. - But all sorts of checks like this are all heuristics-based.
- An
- Could have a switch to check for negations?
- But is this a strictness thing?
- Feels like no - weird.
- Does this feel consistent?
- Should do this stuff everywhere.
- But if you have a switch case with 200 cases, you'll get 200
nots in the default, whether you cared or not. This PR avoids that unless you actually need the negation.
- Let's come back to use-cases.
not Promise- Control flow issues.
- With this PR, it is very nice that it's both faster and that you don't see the
nots in hover unless you need. - We do want to experiment a bit more with decomposing existing primitives here. There are some unknown unknowns here.
- Is
objectequivalent to{} & not number & not string & not boolean & not symbol? - Is
{}equivalent tonot null & not undefined? - Maybe
ExtractandExcludecan be defined in this way?- Or rather, have the compiler produce intersections of negations wherever we otherwise produce these.
- Aside: added a specific mechanism for reducing intersections in the presence of negations.
- Or rather, have the compiler produce intersections of negations wherever we otherwise produce these.
- Is
- What does negation mean in the presence of optional properties?
not { optionalProp?: Type }- Out of time!
- Vorherrschende Sprache
- Go
- Sterne
- 111k
- Forks
- 14.4k
- Ø Merge
- 1 T. 19 Std.
- Gemergte PRs (30 T.)
- 117
Beitragsleitfaden
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus microsoft/TypeScript
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 88/100
microsoft/TypeScript#64322 · 2 Kommentare · 1 Reaktion · 2 zugewiesene Personen ·
-
Possible Improvement
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
microsoft/TypeScript#64278 · 1 Kommentar · 1 Reaktion ·
-
Docs
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 70/100
microsoft/TypeScript#64118 · 1 Kommentar ·
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 88/100
microsoft/TypeScript#64094 ·
-
Docs
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
microsoft/TypeScript#63959 · 5 Kommentare ·
Alle Issues in microsoft/TypeScript
Ähnliche Issues
-
kind/bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 88/100
kubernetes-sigs/prow#953 · 1 Kommentar ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 88/100
caddyserver/caddy#8046 ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 86/100
-
L1 recommended for recruits
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 88/100
-
optimization optimization:agents-md-curator
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 86/100
githubnext/gh-aw-cao#13143 ·