Coder Social home page Coder Social logo

Symbol type about runtypes HOT 6 CLOSED

yuhr avatar yuhr commented on May 18, 2024
Symbol type

from runtypes.

Comments (6)

pelotom avatar pelotom commented on May 18, 2024 1

Ah, looks like Symbol is treated as a special case (which isn't too surprising). A custom runtype for Symbol is probably in order.

from runtypes.

pelotom avatar pelotom commented on May 18, 2024 1

Is there any way to "merge" the original methods into custom runtype? Is it possible?

I'm not thrilled about that idea... the runtype object serves a very different purpose and shouldn't be conflated. Using import * as rt for example is the right way to disambiguate where needed.

from runtypes.

pelotom avatar pelotom commented on May 18, 2024

Would InstanceOf(Symbol) do the job?

from runtypes.

yuhr avatar yuhr commented on May 18, 2024

TS says:

Argument of type 'SymbolConstructor' is not assignable to parameter of type 'Constructor<{}>'.
  Type 'SymbolConstructor' provides no match for the signature 'new (...args: any[]): {}'.

And cannot compile 😢 Please describe how to use it

from runtypes.

yuhr avatar yuhr commented on May 18, 2024

Btw without as import it'll shadow the original Symbol identifier and disable static methods such as Symbol.for and Symbol.keyFor ... this is not specific to Symbol. Is there any way to "merge" the original methods into custom runtype? Is it possible?

from runtypes.

yuhr avatar yuhr commented on May 18, 2024

That's right indeed, sorry for the rough question. Thanks a lot 🌟

from runtypes.

Related Issues (20)

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.