Implementation of newtypes in TypeScript (by gcanti)

Newtype-ts Alternatives

Similar projects and alternatives to newtype-ts

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

newtype-ts reviews and mentions

Posts with mentions or reviews of newtype-ts. We have used some of these posts to build our list of alternatives and similar projects. The last one was on 2022-08-18.
  • I too prefer no classes
    2 projects | /r/typescript | 18 Aug 2022
    You don't need classes for nominal types:
  • Please put units in names
    7 projects | /r/programming | 21 Mar 2022
    I haven't used this library in particular or this one, but bless the authors and all the others for trying to make it happen… the project I'm now leading uses strongly typed strings for different component addresses, and it saves me to constantly look up the documentation what the functions need – it's beautiful.
  • Type that's NOT another type?
    2 projects | /r/typescript | 29 Jan 2022
    A "nominal" solution with no runtime overhead can be provided by branded types, other words for this are "opaque types" or "newtypes". Some libraries like newtype-ts exist to help with the construction of these. That library README describes it as:
  • Is there a way to guarantee that a number variable can never be a non-finite value?
    3 projects | /r/typescript | 30 Nov 2021
    You can also look at the fp-ts ecosystem for inspiration. newtype-ts and io-ts's Branded type with io-ts-type's UUID as a good example
  • Branding & Flavoring
    2 projects | | 14 May 2021
    Alternatively we can use other more sophisticated techniques to achieve nominal typing or libraries such as: newtype-ts or io-ts.
  • Introduction
    3 projects | | 24 Mar 2021
    One using fp-ts and newtype-ts
  • Using fp-ts and newtype-ts: implementation
    2 projects | | 24 Mar 2021
    The newtype-ts library already provides a type guard to validate a single character: isChar. Sadly, there is no type predicate in the current version (v0.3.4) of this function, so we'll have to make a type assertion to tell TypeScript that it's indeed a Char if the function returns true, and not just a regular string.
  • A note from our sponsor - | 20 Feb 2024
    LearnThisRepo lets you learn 300+ open source repos including Postgres, Langchain, VS Code, and more by chatting with them using AI! Learn more →


Basic newtype-ts repo stats
over 1 year ago

gcanti/newtype-ts is an open source project licensed under MIT License which is an OSI approved license.

The primary programming language of newtype-ts is TypeScript.

Learn 300+ open source libraries for free using AI.
LearnThisRepo lets you learn 300+ open source repos including Postgres, Langchain, VS Code, and more by chatting with them using AI!