Git Product home page Git Product logo

Comments (5)

SteMab avatar SteMab commented on May 29, 2024 1

The new option ignoreFunctions has solved my problem. Thanks so much

from typescript-is.

woutervh- avatar woutervh- commented on May 29, 2024

Hi @SteMab

There are two things going on that are causing the issue:

  1. When you write type MappedType = { [P in keyof MyClass]: MyClass[P]; }, TypeScript does not keep method as an actual method. Instead, it becomes a regular object property with a function type. You can see this if you inspect the type MappedType, it will have the property method as a function: method: () => string.

  2. Because of this, ignoreMethods will not be checked to decide to ignore this property. typescript-is is now working with a regular function, and because these are not supported, its behavior is undefined.

To solve this:

  1. I can add a new option ignoreFunctions with similar behavior as ignoreMethods but will work for any function.

  2. You can avoid using assertType on classes/functions/methods. Since you have a class instance, why not use instanceof?

from typescript-is.

SteMab avatar SteMab commented on May 29, 2024

@woutervh- Thank you for your kind reply which clarified the point.
I can't use instanceof because I'm writing an http firebase function and the object to check was been serialized.

An option ignoreFunctions would be useful, in my opinion (but I'm not familiar with typescript and prototype-based programming).

from typescript-is.

woutervh- avatar woutervh- commented on May 29, 2024

Hi @SteMab

I've added the option ignoreFunctions:
https://github.com/woutervh-/typescript-is/releases/tag/v0.14.3
https://github.com/woutervh-/typescript-is#options

Let me know if this helps :)

from typescript-is.

ivarne avatar ivarne commented on May 29, 2024

Found this from the link in the error message and want to leave a note that ignoreFunctions is deprecated and you can now declare functionBehavior: "basic" instead.

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.