Wrong typescript declaration for errorConstructors
See original GitHub issueArgument of type '(string | SystemError | AssertionError | EvalErrorConstructor | { new (message?: string | undefined, name?: string | undefined): DOMException; ... 25 more ...; readonly WRONG_DOCUMENT_ERR: number; })[][]' is not assignable to parameter of type 'Iterable<readonly [string, ErrorConstructor]>'.
The types returned by '[Symbol.iterator]().next(...)' are incompatible between these types.
Type 'IteratorResult<(string | SystemError | AssertionError | EvalErrorConstructor | { new (message?: string | undefined, name?: string | undefined): DOMException; ... 25 more ...; readonly WRONG_DOCUMENT_ERR: number; })[], any>' is not assignable to type 'IteratorResult<readonly [string, ErrorConstructor], any>'.
Type 'IteratorYieldResult<(string | SystemError | AssertionError | EvalErrorConstructor | { new (message?: string | undefined, name?: string | undefined): DOMException; ... 25 more ...; readonly WRONG_DOCUMENT_ERR: number; })[]>' is not assignable to type 'IteratorResult<readonly [string, ErrorConstructor], any>'.
Type 'IteratorYieldResult<(string | SystemError | AssertionError | EvalErrorConstructor | { new (message?: string | undefined, name?: string | undefined): DOMException; ... 25 more ...; readonly WRONG_DOCUMENT_ERR: number; })[]>' is not assignable to type 'IteratorYieldResult<readonly [string, ErrorConstructor]>'.
Type '(string | SystemError | AssertionError | EvalErrorConstructor | { new (message?: string | undefined, name?: string | undefined): DOMException; ... 25 more ...; readonly WRONG_DOCUMENT_ERR: number; })[]' is not assignable to type 'readonly [string, ErrorConstructor]'.
Target requires 2 element(s) but source may have fewer.
Overload 2 of 4, '(entries?: readonly (readonly [string, ErrorConstructor])[] | null | undefined): Map<string, ErrorConstructor>', gave the following error.
Argument of type '(string | SystemError | AssertionError | EvalErrorConstructor | { new (message?: string | undefined, name?: string | undefined): DOMException; ... 25 more ...; readonly WRONG_DOCUMENT_ERR: number; })[][]' is not assignable to parameter of type 'readonly (readonly [string, ErrorConstructor])[]'.
Type '(string | SystemError | AssertionError | EvalErrorConstructor | { new (message?: string | undefined, name?: string | undefined): DOMException; ... 25 more ...; readonly WRONG_DOCUMENT_ERR: number; })[]' is not assignable to type 'readonly [string, ErrorConstructor]'.
This message is shown when the code is converted to Typescript.
Issue Analytics
- State:
- Created a year ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
TypeScript errors and how to fix them
Common Errors Below you find a list of common TypeScript errors along with the buggy code and its fixed version.
Read more >Typescript: Work around type definition error for javascript builtin
I want to use FormData in typescript. Unfortunately, the generated typescript definition files doesn't support a FormData constructor with a Form Element as ......
Read more >Incorrect types for native errors subtypes · Issue #29943 - GitHub
According to the spec, the constructor functions for the native errors ( RangeError , SyntaxError , etc) have the base Error constructor as ......
Read more >TypeScript Done Wrong - OpenReplay Blog
I'm declaring it as a function that accepts 2 parameters, the first one potentially being null since I'm going with the “Error-first” pattern ......
Read more >Error() constructor - JavaScript - MDN Web Docs
When Error is used like a function, that is without new , it will return an Error object. Therefore, a mere call to...
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
I’m also having trouble adding my own constructor to this. It seems that:
@types/node
instead oflib.es5
MessengerError extends Error
, andError
is reported asErrorConstructor
, I still get:Seen in https://github.com/pixiebrix/webext-messenger/blob/0ccfd3b008f5cb4d77bd993361022d041b66dcd8/source/shared.ts#L29-L34
Note: The line seems to work, it’s just that the types seem incorrect.
That’s unrelated. You’ll just have to use Babel or keep using the older version.