Making instance via constructor property of another instance (TS2351: This expression is not constructable)

I need to instantiate some class which I have no access to. What I have is another instance of that class. In other words: the library does not export class, but its instance only, and I want to have another instance. The following code does solve the issue:

const myInstance = new importedInstance.constructor(params);

It works fine as pure javascript, but not as typescript. Typescript throws an error:

TS2351: This expression is not constructable. Type ‘Function’ has no construct signatures.

Is there any solution for typescript other than any-cast like new (importedInstance as any).constructor(params)?

181 thoughts on “Making instance via constructor property of another instance (TS2351: This expression is not constructable)”

  1. Hello there! This is my first visit to your blog! We are
    a group of volunteers and starting a new project in a community in the same niche.

    Your blog provided us useful information to work on. You have done a marvellous job!

    Reply
  2. Pingback: keto advanced
  3. Hey there! Someone in my Facebook group shared this website with
    us so I came to give it a look. I’m definitely loving the information. I’m book-marking and will be tweeting this to my followers!
    Great blog and superb design and style.

    Reply
  4. It’s perfect time to make some plans for the future and it’s time to be happy.
    I have read this post and if I could I wish to suggest you some interesting things or suggestions.
    Maybe you can write next articles referring to this article.
    I desire to read more things about it!

    Reply
  5. I think this is among the most significant information for me.

    And i’m glad reading your article. But should remark on some general things, The web
    site style is wonderful, the articles is really nice : D.

    Good job, cheers

    Reply
  6. Do you have a spam issue on this blog; I also am a blogger, and I was wondering your situation; many of
    us have created some nice methods and we are looking to trade techniques with others, please shoot
    me an email if interested.

    Reply
  7. It’s the best time to make some plans for the future and it
    is time to be happy. I’ve read this post and if I could I desire
    to suggest you few interesting things or advice.
    Maybe you can write next articles referring to this article.
    I desire to read even more things about it!

    ps4 https://bit.ly/3z5HwTp ps4 games

    Reply
  8. Thanks on your marvelous posting! I actually
    enjoyed reading it, you’re a great author.I will make sure to bookmark your blog
    and may come back down the road. I want to encourage continue your great posts, have a nice morning!

    Reply
  9. Hey There. I found your blog using msn. This is
    a very well written article. I will be sure to bookmark it and come back to read
    more of your useful information. Thanks for the post. I will certainly return.

    Reply
  10. Wow, superb blog layout! How long have you been blogging for?
    you made blogging look easy. The overall look of your web site is wonderful, let alone
    the content!

    Reply
  11. My programmer is trying to convince me to move to .net from PHP.
    I have always disliked the idea because of the expenses.
    But he’s tryiong none the less. I’ve been using WordPress on several websites for about a year and am anxious about switching to another platform.
    I have heard fantastic things about blogengine.net.
    Is there a way I can transfer all my wordpress content into it?
    Any kind of help would be really appreciated!

    Reply
  12. Nice post. I was checking constantly this blog and I’m impressed!
    Extremely useful information specifically the last
    part 🙂 I care for such info a lot. I was looking for this certain info
    for a long time. Thank you and good luck.

    Reply
  13. I’m truly enjoying the design and layout of your site.
    It’s a very easy on the eyes which makes it much more pleasant for me
    to come here and visit more often. Did you hire out a designer to create your theme?
    Great work!

    Reply
  14. I’m not that much of a online reader to be honest but your blogs really nice, keep it up!
    I’ll go ahead and bookmark your site to come back down the road.
    Cheers

    Reply
  15. I got this site from my pal who told me on the topic of this website and
    now this time I am visiting this site and reading very informative articles or reviews at this time.

    Reply
  16. It’s the best time to make some plans for the future and
    it’s time to be happy. I have read this post and if I could I want to suggest
    you few interesting things or suggestions. Perhaps you could write next articles referring
    to this article. I want to read even more things about
    it!

    Reply
  17. I’m curious to find out what blog platform you have been working with?
    I’m experiencing some small security problems with my latest blog and I’d like to
    find something more secure. Do you have any solutions?

    Reply
  18. Heya i am for the first time here. I found this board and I find It truly useful & it helped me
    out a lot. I hope to give something back and aid others like you helped me.

    Reply
  19. What’s Happening i’m new to this, I stumbled upon this
    I’ve found It absolutely helpful and it has helped me out loads.

    I’m hoping to contribute & aid other customers like its aided
    me. Great job.

    Reply
  20. It is appropriate time to make some plans for the future and it
    is time to be happy. I’ve read this post and if
    I could I want to suggest you some interesting things or advice.
    Maybe you could write next articles referring to this article.
    I want to read more things about it!

    Reply
  21. We’re a bunch of volunteers and opening a new scheme in our community.
    Your website provided us with valuable info to work on. You have performed a formidable job and our entire neighborhood
    will be thankful to you.

    Reply
  22. Good day! I know this is somewhat off topic but I was wondering which blog platform are you using for this website?

    I’m getting fed up of WordPress because I’ve had issues with hackers and I’m looking
    at options for another platform. I would be awesome if you could point
    me in the direction of a good platform.

    Reply
  23. Hi there! This is kind of off topic but I need
    some guidance from an established blog. Is it tough to set up your own blog?
    I’m not very techincal but I can figure things out pretty fast.
    I’m thinking about making my own but I’m not sure where to begin. Do you have any ideas or suggestions?
    Many thanks

    Reply
  24. Hello There. I found your blog the usage of msn. That is a really smartly written article.
    I will make sure to bookmark it and come back to learn more of your useful info.

    Thank you for the post. I will certainly return.

    Reply
  25. Fantastic items from you, man. I have have in mind your stuff prior to and you’re simply too excellent.
    I really like what you have got here, certainly like what you’re stating
    and the best way wherein you say it. You are making it entertaining and you still care for to stay it sensible.
    I can not wait to learn far more from you. That is actually a wonderful web site.

    Reply
  26. Woah! I’m really loving the template/theme of this website.
    It’s simple, yet effective. A lot of times it’s very difficult to
    get that “perfect balance” between superb
    usability and visual appeal. I must say that you’ve done a very
    good job with this. Additionally, the blog loads extremely quick
    for me on Firefox. Superb Blog!

    Reply

Leave a Comment