Comments (3)
Copying over the response from reddit https://www.reddit.com/r/typescript/comments/w5rebv/comment/ihbgoy3/?utm_source=share&utm_medium=web2x&context=3
We actually have a bug here, will try to patch later tonight
The reason we did the class thing was to try to get this to work
Mins = Nominal<"Mins", number>
Minutes = Nominal<"Mins", number>
const funcMins = (x:Mins) => {}
funcMins(10 as Mins) // works
funcMins(10 as Minutes) // should not work
To be clear, this is not actually working in our code rn. We screwed it up somewhere along the way
But the idea of using the function is NewSymbol
is a different Symbol on each function "call" so typescript should ideally see them as different unique
symbols. Two unique
symbols with the same name will not match. The class is just a mechanism to pass a generic to a function, not doing much else
A basic example of the desired behaviours is here
Actually not super sure how to make an ergonomic way to achieve this off the top of my head, happy to brainstorm
from nominal.
We actually have a bug here, will try to patch later tonight
@CryogenicPlanet any progress 😉?
from nominal.
@mochaaP Unfortunately not, don't have a great way in mind to do this without making the UX of the tool much worse. And haven't had the time to spend too much time thinking about it
from nominal.
Related Issues (3)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nominal.