The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning. Learn more →
Newtype-ts Alternatives
Similar projects and alternatives to newtype-ts
-
SurveyJS
Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App. With SurveyJS form UI libraries, you can build and style forms in a fully-integrated drag & drop form builder, render them in your JS app, and store form submission data in any backend, inc. PHP, ASP.NET Core, and Node.js.
-
F#
Discontinued Please file issues or pull requests here: https://github.com/dotnet/fsharp (by fsharp)
-
InfluxDB
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.
-
WorkOS
The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.
newtype-ts reviews and mentions
-
Type-Safe Printf() in TypeScript
Curious what your issue was with duck-typing. Were you effectively looking to create ADTs that are required to go through a specific step-by-step process, not simply 'look like' the thing that was expected?
If so, you might be interested in [newtype-ts].
[newtype-ts]: https://github.com/gcanti/newtype-ts
-
Is there a language with custom type support (value objects)?
this one https://github.com/gcanti/newtype-ts ?
-
I too prefer no classes
You don't need classes for nominal types: https://github.com/gcanti/newtype-ts
-
When do you find Branding to be useful?
Creating newtypes (via newtype-ts) for fractions and percentages is worthwhile if you're very concerned about correctness, though it's unfortunate that absent typeclasses they're not terribly ergonomic.
-
Please put units in names
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?
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?
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
Alternatively we can use other more sophisticated techniques to achieve nominal typing or libraries such as: newtype-ts or io-ts.
-
Introduction
One using fp-ts and newtype-ts
-
Using fp-ts and newtype-ts: types
We are going to use newtype-ts to build a branded type:
-
A note from our sponsor - WorkOS
workos.com | 25 Apr 2024
Stats
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.
Sponsored