question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Issue a more useful error when attempting to construct non-newable type

See original GitHub issue

Inspired from http://stackoverflow.com/questions/24923772/raphael-with-typescript-call-signatures-used-in-a-new-expression-must-have-a

interface NotNewable {
    (n: number): string;
}

var n: NotNewable;
var t = new n(10);

New compiler says

Only a void function can be called with the ‘new’ keyword

Old compiler says

Call signatures used in a ‘new’ expression must have a ‘void’ return type.

This error is written as if it’s the .d.ts author’s fault, not the calling code’s fault. A more useful error would be something like “Specified type does not have a signature that can be called with ‘new’”

Issue Analytics

  • State:open
  • Created 9 years ago
  • Comments:11 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
Andaristcommented, Dec 16, 2022

The current error for this kind of thing is:

‘new’ expression, whose target lacks a construct signature, implicitly has an ‘any’ type.(7009)

which seems to satisfy the specified goal of this ticket:

This error is written as if it’s the .d.ts author’s fault, not the calling code’s fault. A more useful error would be something like “Specified type does not have a signature that can be called with ‘new’”

cc @RyanCavanaugh

1reaction
Spongmancommented, Jul 11, 2017

I’m running into this error a lot when checking legacy javascript code. The obscurity of this message might have made sense back when --noImplicitAny was a hidden compiler flag. howadays, not so much…

Read more comments on GitHub >

github_iconTop Results From Across the Web

R.E.A.C.T. - Renewable Energy Activities - NREL
These include sun, wind, geothermal, water, and biomass. The renewable energy resources are important in long range energy planning because they will not...
Read more >
Special Report on Renewable Energy Sources and Climate ...
The IPCC Special Report on Renewable Energy Sources and Climate Change Mitigation (SRREN) provides a comprehensive review concerning these sources ...
Read more >
Renewable Energy 101 | National Geographic - YouTube
There are many benefits to using renewable energy resources, but what is it exactly? From solar to wind, find out more about alternative ......
Read more >
Renewable-energy development in a net-zero world - McKinsey
Global decarbonization will require a massive build-out of wind and solar farms. But can developers find enough land, secure the supply ...
Read more >
Breaking barriers in deployment of renewable energy - NCBI
Loss of other/alternative income : A major issue with renewable plants (especially solar and wind farms) is the vast area of land required...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found