TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Programming with union, intersection, and negation types

35 pointsby pbowyeralmost 3 years ago

2 comments

quickthrower2almost 3 years ago
Not sure about negation, but humble Typescript lets you use union and intersection types.<p>I am hooked on intersection types in Typescript. It is like mixin heaven.<p>I have a WithId type I use alot that I can tack on to any Firebase record type.<p>If I had the motivation I could write a generic firebase getter that returns documents as a “T &amp; WithId” (means type T with an additional id:string field)<p>It decreases the number of types you need to define for one. And lets you lego up various interfaces.
评论 #32019757 未加载
评论 #32019854 未加载
galaxyLogicalmost 3 years ago
Isn&#x27;t Union Types just the same as &quot;Sum Types&quot; (as in Haskell etc.)?<p>But does Haskell have Intersection Types and Negation Types?
评论 #32018960 未加载
评论 #32018972 未加载