nominal

🔒 The new way to do types in typescript. (by scalarhq)

Nominal Alternatives

Similar projects and alternatives to nominal based on common topics and language

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a better nominal alternative or higher similarity.

nominal reviews and mentions

Posts with mentions or reviews of nominal. We have used some of these posts to build our list of alternatives and similar projects. The last one was on 2022-07-22.
  • Unlocking type-safety superpowers in TypeScript with nominal and refinement typ
    1 project | news.ycombinator.com | 3 Aug 2022
  • Unlocking type-safety superpowers in Typescript with nominal and refinement types
    7 projects | /r/typescript | 22 Jul 2022
    Hey OP here, Wanted to share something we recently discovered in typescript. This is a way to to create haskell style Newtype using the lesser known \`symbols\` ```ts type Minutes = number type Seconds = number const minutesToSeconds = (minutes: Minutes) => minutes * 60 const seconds: Seconds = 420 // uh-oh, we can use Minutes and Seconds interchangeably minutesToSeconds(seconds) ``` Nominal types solve this problem ```ts import { Nominal, nominal } from 'nominal-types'; type Minutes = Nominal<'Minutes', number>; type Seconds = Nominal<'Seconds', number>; const minutesToSeconds = (minutes: Minutes) => minutes * 60 // You can directly type cast or use nominal.make const seconds = nominal.make(420) const minutes = 1337 as Minutes // doesn't work, yay type safety minutesToSeconds(seconds) // does work! minutesToSeconds(minutes) ``` We have some lot cooler examples https://github.com/modfy/nominal#examples You can also read more about it here: https://zackoverflow.dev/writing/nominal-and-refinement-types-typescript

Stats

Basic nominal repo stats
3
259
0.9
about 1 year ago

Sponsored
Power Real-Time Data Analytics at Scale
Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.
www.influxdata.com