TypeScript instanceof not working

前端 未结 3 2051
[愿得一人]
[愿得一人] 2020-12-17 22:01

I\'m having issues using the instanceof operator and it doesn\'t seem to work. Here is a part of my code:

        const results = _.map(items, function(item:         


        
3条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-17 22:32

    Try to instantiate the object with a constructor. It happened to me the same because I was manually mocking the object for testing purposes. If you create the item like following example, it should work:

    item: Goal = new Goal(*item values*)
    

提交回复
热议问题