Giter VIP home page Giter VIP logo

Comments (3)

CryogenicPlanet avatar CryogenicPlanet commented on June 15, 2024

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.

mochaaP avatar mochaaP commented on June 15, 2024

We actually have a bug here, will try to patch later tonight

@CryogenicPlanet any progress 😉?

from nominal.

CryogenicPlanet avatar CryogenicPlanet commented on June 15, 2024

@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 photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.