Not all interfaces should be marked as constructable
See original GitHub issueE.g. trying to call AbortSignal
with new throws Illegal constructor
error.
> new AbortSignal()
Uncaught TypeError: Illegal constructor.
This is not currently handled by the declaration:
declare var AbortSignal: {
prototype: AbortSignal;
new(): AbortSignal;
};
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
Cannot use new with expression typescript - Stack Overflow
The problem is that the compiler treats the contextClass variable as an instance of AudioContext while in fact it's merely a constructor ...
Read more >Generic class decorator does not typecheck #23049 - GitHub
Basically what I'm trying to achieve is that the extended class is "class extends ctor implements Interface". that is the instance side of...
Read more >How To Use Classes in TypeScript | DigitalOcean
Interfaces are useful to specify a set of behaviors that all implementations of that interface must possess. Interfaces are created by using ...
Read more >Interface with NSRR and Flaggers | FTA
Availability of eight flagmen was shown in RBT contract, but the detail of how many and the timing of the flaggers were not...
Read more >A simple guide to “interface” data type in TypeScript - Medium
JavaScript object keys in almost all the cases are strings and their values ... Not only the shape of a plain object, but...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This is because
instanceof
check requires a constructor member. Butnever
seemingly works:@orta does
new(): never
make sense to fix this?This also affects
NodeList
(which could have prevented a bug: https://github.com/mermaid-js/mermaid/pull/3396)Maybe it’s worth putting in a
/** @deprecated */
JSDoc tag to constructors that throwIllegal constructor
, so some tools (like ESLint/VS Code) will warn about using them.