Git Product home page Git Product logo

Comments (4)

woutervh- avatar woutervh- commented on May 29, 2024

Hi @watson28

Thanks for reporting the issue.

Validating classes (which also includes Date) is not supported. In issue #16 a similar request came in for the RegExp class. The solution I'm looking at right now is to add an option to ignore classes and methods rather than throw an error.

Would that be an acceptable alternative?

from typescript-is.

watson28 avatar watson28 commented on May 29, 2024

@woutervh- thanks for your quick response. I think that's a good workaround.
its really bad the library doesn't support classes. is there any plan for supporting classes in the future?

from typescript-is.

woutervh- avatar woutervh- commented on May 29, 2024

hi @watson28

The workaround has been released (see my comment in #16 for details).

Supporting classes is not something that I see as a high priority for this library because it's focused on type guarding serializable data. RegExp, Date, etc. are all created at runtime, so somewhere in your code where you are creating an instance of these classes you should already have the type available and be type safe. Reading files or fetching data from an HTTP server are examples where you can't be sure you have the right type, and that's what this library is mainly for.

Adding support for classes is something that could be done in the long run, but I think it would be tricky, because I'd have to make sure that the class you are validating is in fact imported, and I'd have to figure out the name of the class in your runtime. I'm not sure this possible.

If you have a solution to this problem, feel free to contribute 👍

from typescript-is.

woutervh- avatar woutervh- commented on May 29, 2024

Closing for house keeping.

from typescript-is.

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.