mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Add Error.prototype.cause (#47020)
* Add `Error.prototype.cause` Fixes #47019 * Update test baselines
This commit is contained in:
@@ -627,7 +627,8 @@ namespace ts {
|
||||
Float64Array: ["at"],
|
||||
BigInt64Array: ["at"],
|
||||
BigUint64Array: ["at"],
|
||||
ObjectConstructor: ["hasOwn"]
|
||||
ObjectConstructor: ["hasOwn"],
|
||||
Error: ["cause"]
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Vendored
+50
-3
@@ -1,8 +1,55 @@
|
||||
interface ErrorOptions {
|
||||
cause?: Error;
|
||||
cause?: Error;
|
||||
}
|
||||
|
||||
interface Error {
|
||||
cause?: Error;
|
||||
}
|
||||
|
||||
interface ErrorConstructor {
|
||||
new(message?: string, options?: ErrorOptions): Error;
|
||||
(message?: string, options?: ErrorOptions): Error;
|
||||
new (message?: string, options?: ErrorOptions): Error;
|
||||
(message?: string, options?: ErrorOptions): Error;
|
||||
}
|
||||
|
||||
interface EvalErrorConstructor {
|
||||
new (message?: string, options?: ErrorOptions): EvalError;
|
||||
(message?: string, options?: ErrorOptions): EvalError;
|
||||
}
|
||||
|
||||
interface RangeErrorConstructor {
|
||||
new (message?: string, options?: ErrorOptions): RangeError;
|
||||
(message?: string, options?: ErrorOptions): RangeError;
|
||||
}
|
||||
|
||||
interface ReferenceErrorConstructor {
|
||||
new (message?: string, options?: ErrorOptions): ReferenceError;
|
||||
(message?: string, options?: ErrorOptions): ReferenceError;
|
||||
}
|
||||
|
||||
interface SyntaxErrorConstructor {
|
||||
new (message?: string, options?: ErrorOptions): SyntaxError;
|
||||
(message?: string, options?: ErrorOptions): SyntaxError;
|
||||
}
|
||||
|
||||
interface TypeErrorConstructor {
|
||||
new (message?: string, options?: ErrorOptions): TypeError;
|
||||
(message?: string, options?: ErrorOptions): TypeError;
|
||||
}
|
||||
|
||||
interface URIErrorConstructor {
|
||||
new (message?: string, options?: ErrorOptions): URIError;
|
||||
(message?: string, options?: ErrorOptions): URIError;
|
||||
}
|
||||
|
||||
interface AggregateErrorConstructor {
|
||||
new (
|
||||
errors: Iterable<any>,
|
||||
message?: string,
|
||||
options?: ErrorOptions
|
||||
): AggregateError;
|
||||
(
|
||||
errors: Iterable<any>,
|
||||
message?: string,
|
||||
options?: ErrorOptions
|
||||
): AggregateError;
|
||||
}
|
||||
|
||||
@@ -190,7 +190,7 @@ class Api<D = {}> {
|
||||
>D : Symbol(D, Decl(awaitedTypeStrictNull.ts, 47, 15))
|
||||
>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2018.promise.d.ts, --, --))
|
||||
>D : Symbol(D, Decl(awaitedTypeStrictNull.ts, 47, 15))
|
||||
>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
||||
>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2022.error.d.ts, --, --))
|
||||
}
|
||||
|
||||
declare const api: Api;
|
||||
|
||||
@@ -23,7 +23,7 @@ class ConstantIterator<T> implements AsyncIterator<T, undefined, T | undefined>
|
||||
>value : Symbol(value, Decl(customAsyncIterator.ts, 4, 15))
|
||||
|
||||
throw new Error("ConstantIterator.prototype.next may not take any values");
|
||||
>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
||||
>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2022.error.d.ts, --, --))
|
||||
}
|
||||
return { value: this.constant, done: false };
|
||||
>value : Symbol(value, Decl(customAsyncIterator.ts, 8, 16))
|
||||
|
||||
@@ -1,8 +1,41 @@
|
||||
tests/cases/compiler/errorCause.ts(1,18): error TS2554: Expected 0-1 arguments, but got 2.
|
||||
tests/cases/compiler/errorCause.ts(1,28): error TS2554: Expected 0-1 arguments, but got 2.
|
||||
tests/cases/compiler/errorCause.ts(2,5): error TS2550: Property 'cause' does not exist on type 'Error'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2022' or later.
|
||||
tests/cases/compiler/errorCause.ts(4,22): error TS2554: Expected 0-1 arguments, but got 2.
|
||||
tests/cases/compiler/errorCause.ts(5,23): error TS2554: Expected 0-1 arguments, but got 2.
|
||||
tests/cases/compiler/errorCause.ts(6,27): error TS2554: Expected 0-1 arguments, but got 2.
|
||||
tests/cases/compiler/errorCause.ts(7,24): error TS2554: Expected 0-1 arguments, but got 2.
|
||||
tests/cases/compiler/errorCause.ts(8,22): error TS2554: Expected 0-1 arguments, but got 2.
|
||||
tests/cases/compiler/errorCause.ts(9,21): error TS2554: Expected 0-1 arguments, but got 2.
|
||||
tests/cases/compiler/errorCause.ts(10,31): error TS2554: Expected 1-2 arguments, but got 3.
|
||||
|
||||
|
||||
==== tests/cases/compiler/errorCause.ts (1 errors) ====
|
||||
new Error("foo", { cause: new Error("bar") });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
==== tests/cases/compiler/errorCause.ts (9 errors) ====
|
||||
let err = new Error("foo", { cause: new Error("bar") });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2554: Expected 0-1 arguments, but got 2.
|
||||
err.cause;
|
||||
~~~~~
|
||||
!!! error TS2550: Property 'cause' does not exist on type 'Error'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2022' or later.
|
||||
|
||||
new EvalError("foo", { cause: new Error("bar") });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2554: Expected 0-1 arguments, but got 2.
|
||||
new RangeError("foo", { cause: new Error("bar") });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2554: Expected 0-1 arguments, but got 2.
|
||||
new ReferenceError("foo", { cause: new Error("bar") });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2554: Expected 0-1 arguments, but got 2.
|
||||
new SyntaxError("foo", { cause: new Error("bar") });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2554: Expected 0-1 arguments, but got 2.
|
||||
new TypeError("foo", { cause: new Error("bar") });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2554: Expected 0-1 arguments, but got 2.
|
||||
new URIError("foo", { cause: new Error("bar") });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2554: Expected 0-1 arguments, but got 2.
|
||||
new AggregateError([], "foo", { cause: new Error("bar") });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2554: Expected 1-2 arguments, but got 3.
|
||||
|
||||
@@ -1,6 +1,23 @@
|
||||
//// [errorCause.ts]
|
||||
new Error("foo", { cause: new Error("bar") });
|
||||
let err = new Error("foo", { cause: new Error("bar") });
|
||||
err.cause;
|
||||
|
||||
new EvalError("foo", { cause: new Error("bar") });
|
||||
new RangeError("foo", { cause: new Error("bar") });
|
||||
new ReferenceError("foo", { cause: new Error("bar") });
|
||||
new SyntaxError("foo", { cause: new Error("bar") });
|
||||
new TypeError("foo", { cause: new Error("bar") });
|
||||
new URIError("foo", { cause: new Error("bar") });
|
||||
new AggregateError([], "foo", { cause: new Error("bar") });
|
||||
|
||||
|
||||
//// [errorCause.js]
|
||||
new Error("foo", { cause: new Error("bar") });
|
||||
let err = new Error("foo", { cause: new Error("bar") });
|
||||
err.cause;
|
||||
new EvalError("foo", { cause: new Error("bar") });
|
||||
new RangeError("foo", { cause: new Error("bar") });
|
||||
new ReferenceError("foo", { cause: new Error("bar") });
|
||||
new SyntaxError("foo", { cause: new Error("bar") });
|
||||
new TypeError("foo", { cause: new Error("bar") });
|
||||
new URIError("foo", { cause: new Error("bar") });
|
||||
new AggregateError([], "foo", { cause: new Error("bar") });
|
||||
|
||||
@@ -1,6 +1,45 @@
|
||||
=== tests/cases/compiler/errorCause.ts ===
|
||||
new Error("foo", { cause: new Error("bar") });
|
||||
let err = new Error("foo", { cause: new Error("bar") });
|
||||
>err : Symbol(err, Decl(errorCause.ts, 0, 3))
|
||||
>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
||||
>cause : Symbol(cause, Decl(errorCause.ts, 0, 18))
|
||||
>cause : Symbol(cause, Decl(errorCause.ts, 0, 28))
|
||||
>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
||||
|
||||
err.cause;
|
||||
>err : Symbol(err, Decl(errorCause.ts, 0, 3))
|
||||
|
||||
new EvalError("foo", { cause: new Error("bar") });
|
||||
>EvalError : Symbol(EvalError, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
||||
>cause : Symbol(cause, Decl(errorCause.ts, 3, 22))
|
||||
>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
||||
|
||||
new RangeError("foo", { cause: new Error("bar") });
|
||||
>RangeError : Symbol(RangeError, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
||||
>cause : Symbol(cause, Decl(errorCause.ts, 4, 23))
|
||||
>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
||||
|
||||
new ReferenceError("foo", { cause: new Error("bar") });
|
||||
>ReferenceError : Symbol(ReferenceError, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
||||
>cause : Symbol(cause, Decl(errorCause.ts, 5, 27))
|
||||
>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
||||
|
||||
new SyntaxError("foo", { cause: new Error("bar") });
|
||||
>SyntaxError : Symbol(SyntaxError, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
||||
>cause : Symbol(cause, Decl(errorCause.ts, 6, 24))
|
||||
>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
||||
|
||||
new TypeError("foo", { cause: new Error("bar") });
|
||||
>TypeError : Symbol(TypeError, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
||||
>cause : Symbol(cause, Decl(errorCause.ts, 7, 22))
|
||||
>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
||||
|
||||
new URIError("foo", { cause: new Error("bar") });
|
||||
>URIError : Symbol(URIError, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
||||
>cause : Symbol(cause, Decl(errorCause.ts, 8, 21))
|
||||
>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
||||
|
||||
new AggregateError([], "foo", { cause: new Error("bar") });
|
||||
>AggregateError : Symbol(AggregateError, Decl(lib.es2021.promise.d.ts, --, --), Decl(lib.es2021.promise.d.ts, --, --))
|
||||
>cause : Symbol(cause, Decl(errorCause.ts, 9, 31))
|
||||
>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
=== tests/cases/compiler/errorCause.ts ===
|
||||
new Error("foo", { cause: new Error("bar") });
|
||||
let err = new Error("foo", { cause: new Error("bar") });
|
||||
>err : Error
|
||||
>new Error("foo", { cause: new Error("bar") }) : Error
|
||||
>Error : ErrorConstructor
|
||||
>"foo" : "foo"
|
||||
@@ -9,3 +10,79 @@ new Error("foo", { cause: new Error("bar") });
|
||||
>Error : ErrorConstructor
|
||||
>"bar" : "bar"
|
||||
|
||||
err.cause;
|
||||
>err.cause : any
|
||||
>err : Error
|
||||
>cause : any
|
||||
|
||||
new EvalError("foo", { cause: new Error("bar") });
|
||||
>new EvalError("foo", { cause: new Error("bar") }) : EvalError & Error
|
||||
>EvalError : EvalErrorConstructor
|
||||
>"foo" : "foo"
|
||||
>{ cause: new Error("bar") } : { cause: Error; }
|
||||
>cause : Error
|
||||
>new Error("bar") : Error
|
||||
>Error : ErrorConstructor
|
||||
>"bar" : "bar"
|
||||
|
||||
new RangeError("foo", { cause: new Error("bar") });
|
||||
>new RangeError("foo", { cause: new Error("bar") }) : RangeError & Error
|
||||
>RangeError : RangeErrorConstructor
|
||||
>"foo" : "foo"
|
||||
>{ cause: new Error("bar") } : { cause: Error; }
|
||||
>cause : Error
|
||||
>new Error("bar") : Error
|
||||
>Error : ErrorConstructor
|
||||
>"bar" : "bar"
|
||||
|
||||
new ReferenceError("foo", { cause: new Error("bar") });
|
||||
>new ReferenceError("foo", { cause: new Error("bar") }) : ReferenceError & Error
|
||||
>ReferenceError : ReferenceErrorConstructor
|
||||
>"foo" : "foo"
|
||||
>{ cause: new Error("bar") } : { cause: Error; }
|
||||
>cause : Error
|
||||
>new Error("bar") : Error
|
||||
>Error : ErrorConstructor
|
||||
>"bar" : "bar"
|
||||
|
||||
new SyntaxError("foo", { cause: new Error("bar") });
|
||||
>new SyntaxError("foo", { cause: new Error("bar") }) : SyntaxError & Error
|
||||
>SyntaxError : SyntaxErrorConstructor
|
||||
>"foo" : "foo"
|
||||
>{ cause: new Error("bar") } : { cause: Error; }
|
||||
>cause : Error
|
||||
>new Error("bar") : Error
|
||||
>Error : ErrorConstructor
|
||||
>"bar" : "bar"
|
||||
|
||||
new TypeError("foo", { cause: new Error("bar") });
|
||||
>new TypeError("foo", { cause: new Error("bar") }) : TypeError & Error
|
||||
>TypeError : TypeErrorConstructor
|
||||
>"foo" : "foo"
|
||||
>{ cause: new Error("bar") } : { cause: Error; }
|
||||
>cause : Error
|
||||
>new Error("bar") : Error
|
||||
>Error : ErrorConstructor
|
||||
>"bar" : "bar"
|
||||
|
||||
new URIError("foo", { cause: new Error("bar") });
|
||||
>new URIError("foo", { cause: new Error("bar") }) : URIError & Error
|
||||
>URIError : URIErrorConstructor
|
||||
>"foo" : "foo"
|
||||
>{ cause: new Error("bar") } : { cause: Error; }
|
||||
>cause : Error
|
||||
>new Error("bar") : Error
|
||||
>Error : ErrorConstructor
|
||||
>"bar" : "bar"
|
||||
|
||||
new AggregateError([], "foo", { cause: new Error("bar") });
|
||||
>new AggregateError([], "foo", { cause: new Error("bar") }) : AggregateError
|
||||
>AggregateError : AggregateErrorConstructor
|
||||
>[] : undefined[]
|
||||
>"foo" : "foo"
|
||||
>{ cause: new Error("bar") } : { cause: Error; }
|
||||
>cause : Error
|
||||
>new Error("bar") : Error
|
||||
>Error : ErrorConstructor
|
||||
>"bar" : "bar"
|
||||
|
||||
|
||||
@@ -1,6 +1,23 @@
|
||||
//// [errorCause.ts]
|
||||
new Error("foo", { cause: new Error("bar") });
|
||||
let err = new Error("foo", { cause: new Error("bar") });
|
||||
err.cause;
|
||||
|
||||
new EvalError("foo", { cause: new Error("bar") });
|
||||
new RangeError("foo", { cause: new Error("bar") });
|
||||
new ReferenceError("foo", { cause: new Error("bar") });
|
||||
new SyntaxError("foo", { cause: new Error("bar") });
|
||||
new TypeError("foo", { cause: new Error("bar") });
|
||||
new URIError("foo", { cause: new Error("bar") });
|
||||
new AggregateError([], "foo", { cause: new Error("bar") });
|
||||
|
||||
|
||||
//// [errorCause.js]
|
||||
new Error("foo", { cause: new Error("bar") });
|
||||
let err = new Error("foo", { cause: new Error("bar") });
|
||||
err.cause;
|
||||
new EvalError("foo", { cause: new Error("bar") });
|
||||
new RangeError("foo", { cause: new Error("bar") });
|
||||
new ReferenceError("foo", { cause: new Error("bar") });
|
||||
new SyntaxError("foo", { cause: new Error("bar") });
|
||||
new TypeError("foo", { cause: new Error("bar") });
|
||||
new URIError("foo", { cause: new Error("bar") });
|
||||
new AggregateError([], "foo", { cause: new Error("bar") });
|
||||
|
||||
@@ -1,6 +1,47 @@
|
||||
=== tests/cases/compiler/errorCause.ts ===
|
||||
new Error("foo", { cause: new Error("bar") });
|
||||
>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
||||
>cause : Symbol(cause, Decl(errorCause.ts, 0, 18))
|
||||
>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
||||
let err = new Error("foo", { cause: new Error("bar") });
|
||||
>err : Symbol(err, Decl(errorCause.ts, 0, 3))
|
||||
>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2022.error.d.ts, --, --))
|
||||
>cause : Symbol(cause, Decl(errorCause.ts, 0, 28))
|
||||
>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2022.error.d.ts, --, --))
|
||||
|
||||
err.cause;
|
||||
>err.cause : Symbol(Error.cause, Decl(lib.es2022.error.d.ts, --, --))
|
||||
>err : Symbol(err, Decl(errorCause.ts, 0, 3))
|
||||
>cause : Symbol(Error.cause, Decl(lib.es2022.error.d.ts, --, --))
|
||||
|
||||
new EvalError("foo", { cause: new Error("bar") });
|
||||
>EvalError : Symbol(EvalError, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
||||
>cause : Symbol(cause, Decl(errorCause.ts, 3, 22))
|
||||
>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2022.error.d.ts, --, --))
|
||||
|
||||
new RangeError("foo", { cause: new Error("bar") });
|
||||
>RangeError : Symbol(RangeError, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
||||
>cause : Symbol(cause, Decl(errorCause.ts, 4, 23))
|
||||
>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2022.error.d.ts, --, --))
|
||||
|
||||
new ReferenceError("foo", { cause: new Error("bar") });
|
||||
>ReferenceError : Symbol(ReferenceError, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
||||
>cause : Symbol(cause, Decl(errorCause.ts, 5, 27))
|
||||
>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2022.error.d.ts, --, --))
|
||||
|
||||
new SyntaxError("foo", { cause: new Error("bar") });
|
||||
>SyntaxError : Symbol(SyntaxError, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
||||
>cause : Symbol(cause, Decl(errorCause.ts, 6, 24))
|
||||
>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2022.error.d.ts, --, --))
|
||||
|
||||
new TypeError("foo", { cause: new Error("bar") });
|
||||
>TypeError : Symbol(TypeError, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
||||
>cause : Symbol(cause, Decl(errorCause.ts, 7, 22))
|
||||
>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2022.error.d.ts, --, --))
|
||||
|
||||
new URIError("foo", { cause: new Error("bar") });
|
||||
>URIError : Symbol(URIError, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
||||
>cause : Symbol(cause, Decl(errorCause.ts, 8, 21))
|
||||
>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2022.error.d.ts, --, --))
|
||||
|
||||
new AggregateError([], "foo", { cause: new Error("bar") });
|
||||
>AggregateError : Symbol(AggregateError, Decl(lib.es2021.promise.d.ts, --, --), Decl(lib.es2021.promise.d.ts, --, --))
|
||||
>cause : Symbol(cause, Decl(errorCause.ts, 9, 31))
|
||||
>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2022.error.d.ts, --, --))
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
=== tests/cases/compiler/errorCause.ts ===
|
||||
new Error("foo", { cause: new Error("bar") });
|
||||
let err = new Error("foo", { cause: new Error("bar") });
|
||||
>err : Error
|
||||
>new Error("foo", { cause: new Error("bar") }) : Error
|
||||
>Error : ErrorConstructor
|
||||
>"foo" : "foo"
|
||||
@@ -9,3 +10,79 @@ new Error("foo", { cause: new Error("bar") });
|
||||
>Error : ErrorConstructor
|
||||
>"bar" : "bar"
|
||||
|
||||
err.cause;
|
||||
>err.cause : Error
|
||||
>err : Error
|
||||
>cause : Error
|
||||
|
||||
new EvalError("foo", { cause: new Error("bar") });
|
||||
>new EvalError("foo", { cause: new Error("bar") }) : EvalError
|
||||
>EvalError : EvalErrorConstructor
|
||||
>"foo" : "foo"
|
||||
>{ cause: new Error("bar") } : { cause: Error; }
|
||||
>cause : Error
|
||||
>new Error("bar") : Error
|
||||
>Error : ErrorConstructor
|
||||
>"bar" : "bar"
|
||||
|
||||
new RangeError("foo", { cause: new Error("bar") });
|
||||
>new RangeError("foo", { cause: new Error("bar") }) : RangeError
|
||||
>RangeError : RangeErrorConstructor
|
||||
>"foo" : "foo"
|
||||
>{ cause: new Error("bar") } : { cause: Error; }
|
||||
>cause : Error
|
||||
>new Error("bar") : Error
|
||||
>Error : ErrorConstructor
|
||||
>"bar" : "bar"
|
||||
|
||||
new ReferenceError("foo", { cause: new Error("bar") });
|
||||
>new ReferenceError("foo", { cause: new Error("bar") }) : ReferenceError
|
||||
>ReferenceError : ReferenceErrorConstructor
|
||||
>"foo" : "foo"
|
||||
>{ cause: new Error("bar") } : { cause: Error; }
|
||||
>cause : Error
|
||||
>new Error("bar") : Error
|
||||
>Error : ErrorConstructor
|
||||
>"bar" : "bar"
|
||||
|
||||
new SyntaxError("foo", { cause: new Error("bar") });
|
||||
>new SyntaxError("foo", { cause: new Error("bar") }) : SyntaxError
|
||||
>SyntaxError : SyntaxErrorConstructor
|
||||
>"foo" : "foo"
|
||||
>{ cause: new Error("bar") } : { cause: Error; }
|
||||
>cause : Error
|
||||
>new Error("bar") : Error
|
||||
>Error : ErrorConstructor
|
||||
>"bar" : "bar"
|
||||
|
||||
new TypeError("foo", { cause: new Error("bar") });
|
||||
>new TypeError("foo", { cause: new Error("bar") }) : TypeError
|
||||
>TypeError : TypeErrorConstructor
|
||||
>"foo" : "foo"
|
||||
>{ cause: new Error("bar") } : { cause: Error; }
|
||||
>cause : Error
|
||||
>new Error("bar") : Error
|
||||
>Error : ErrorConstructor
|
||||
>"bar" : "bar"
|
||||
|
||||
new URIError("foo", { cause: new Error("bar") });
|
||||
>new URIError("foo", { cause: new Error("bar") }) : URIError
|
||||
>URIError : URIErrorConstructor
|
||||
>"foo" : "foo"
|
||||
>{ cause: new Error("bar") } : { cause: Error; }
|
||||
>cause : Error
|
||||
>new Error("bar") : Error
|
||||
>Error : ErrorConstructor
|
||||
>"bar" : "bar"
|
||||
|
||||
new AggregateError([], "foo", { cause: new Error("bar") });
|
||||
>new AggregateError([], "foo", { cause: new Error("bar") }) : AggregateError
|
||||
>AggregateError : AggregateErrorConstructor
|
||||
>[] : undefined[]
|
||||
>"foo" : "foo"
|
||||
>{ cause: new Error("bar") } : { cause: Error; }
|
||||
>cause : Error
|
||||
>new Error("bar") : Error
|
||||
>Error : ErrorConstructor
|
||||
>"bar" : "bar"
|
||||
|
||||
|
||||
@@ -1,6 +1,23 @@
|
||||
//// [errorCause.ts]
|
||||
new Error("foo", { cause: new Error("bar") });
|
||||
let err = new Error("foo", { cause: new Error("bar") });
|
||||
err.cause;
|
||||
|
||||
new EvalError("foo", { cause: new Error("bar") });
|
||||
new RangeError("foo", { cause: new Error("bar") });
|
||||
new ReferenceError("foo", { cause: new Error("bar") });
|
||||
new SyntaxError("foo", { cause: new Error("bar") });
|
||||
new TypeError("foo", { cause: new Error("bar") });
|
||||
new URIError("foo", { cause: new Error("bar") });
|
||||
new AggregateError([], "foo", { cause: new Error("bar") });
|
||||
|
||||
|
||||
//// [errorCause.js]
|
||||
new Error("foo", { cause: new Error("bar") });
|
||||
let err = new Error("foo", { cause: new Error("bar") });
|
||||
err.cause;
|
||||
new EvalError("foo", { cause: new Error("bar") });
|
||||
new RangeError("foo", { cause: new Error("bar") });
|
||||
new ReferenceError("foo", { cause: new Error("bar") });
|
||||
new SyntaxError("foo", { cause: new Error("bar") });
|
||||
new TypeError("foo", { cause: new Error("bar") });
|
||||
new URIError("foo", { cause: new Error("bar") });
|
||||
new AggregateError([], "foo", { cause: new Error("bar") });
|
||||
|
||||
@@ -1,6 +1,47 @@
|
||||
=== tests/cases/compiler/errorCause.ts ===
|
||||
new Error("foo", { cause: new Error("bar") });
|
||||
>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
||||
>cause : Symbol(cause, Decl(errorCause.ts, 0, 18))
|
||||
>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
||||
let err = new Error("foo", { cause: new Error("bar") });
|
||||
>err : Symbol(err, Decl(errorCause.ts, 0, 3))
|
||||
>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2022.error.d.ts, --, --))
|
||||
>cause : Symbol(cause, Decl(errorCause.ts, 0, 28))
|
||||
>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2022.error.d.ts, --, --))
|
||||
|
||||
err.cause;
|
||||
>err.cause : Symbol(Error.cause, Decl(lib.es2022.error.d.ts, --, --))
|
||||
>err : Symbol(err, Decl(errorCause.ts, 0, 3))
|
||||
>cause : Symbol(Error.cause, Decl(lib.es2022.error.d.ts, --, --))
|
||||
|
||||
new EvalError("foo", { cause: new Error("bar") });
|
||||
>EvalError : Symbol(EvalError, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
||||
>cause : Symbol(cause, Decl(errorCause.ts, 3, 22))
|
||||
>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2022.error.d.ts, --, --))
|
||||
|
||||
new RangeError("foo", { cause: new Error("bar") });
|
||||
>RangeError : Symbol(RangeError, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
||||
>cause : Symbol(cause, Decl(errorCause.ts, 4, 23))
|
||||
>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2022.error.d.ts, --, --))
|
||||
|
||||
new ReferenceError("foo", { cause: new Error("bar") });
|
||||
>ReferenceError : Symbol(ReferenceError, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
||||
>cause : Symbol(cause, Decl(errorCause.ts, 5, 27))
|
||||
>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2022.error.d.ts, --, --))
|
||||
|
||||
new SyntaxError("foo", { cause: new Error("bar") });
|
||||
>SyntaxError : Symbol(SyntaxError, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
||||
>cause : Symbol(cause, Decl(errorCause.ts, 6, 24))
|
||||
>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2022.error.d.ts, --, --))
|
||||
|
||||
new TypeError("foo", { cause: new Error("bar") });
|
||||
>TypeError : Symbol(TypeError, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
||||
>cause : Symbol(cause, Decl(errorCause.ts, 7, 22))
|
||||
>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2022.error.d.ts, --, --))
|
||||
|
||||
new URIError("foo", { cause: new Error("bar") });
|
||||
>URIError : Symbol(URIError, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
||||
>cause : Symbol(cause, Decl(errorCause.ts, 8, 21))
|
||||
>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2022.error.d.ts, --, --))
|
||||
|
||||
new AggregateError([], "foo", { cause: new Error("bar") });
|
||||
>AggregateError : Symbol(AggregateError, Decl(lib.es2021.promise.d.ts, --, --), Decl(lib.es2021.promise.d.ts, --, --))
|
||||
>cause : Symbol(cause, Decl(errorCause.ts, 9, 31))
|
||||
>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2022.error.d.ts, --, --))
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
=== tests/cases/compiler/errorCause.ts ===
|
||||
new Error("foo", { cause: new Error("bar") });
|
||||
let err = new Error("foo", { cause: new Error("bar") });
|
||||
>err : Error
|
||||
>new Error("foo", { cause: new Error("bar") }) : Error
|
||||
>Error : ErrorConstructor
|
||||
>"foo" : "foo"
|
||||
@@ -9,3 +10,79 @@ new Error("foo", { cause: new Error("bar") });
|
||||
>Error : ErrorConstructor
|
||||
>"bar" : "bar"
|
||||
|
||||
err.cause;
|
||||
>err.cause : Error
|
||||
>err : Error
|
||||
>cause : Error
|
||||
|
||||
new EvalError("foo", { cause: new Error("bar") });
|
||||
>new EvalError("foo", { cause: new Error("bar") }) : EvalError
|
||||
>EvalError : EvalErrorConstructor
|
||||
>"foo" : "foo"
|
||||
>{ cause: new Error("bar") } : { cause: Error; }
|
||||
>cause : Error
|
||||
>new Error("bar") : Error
|
||||
>Error : ErrorConstructor
|
||||
>"bar" : "bar"
|
||||
|
||||
new RangeError("foo", { cause: new Error("bar") });
|
||||
>new RangeError("foo", { cause: new Error("bar") }) : RangeError
|
||||
>RangeError : RangeErrorConstructor
|
||||
>"foo" : "foo"
|
||||
>{ cause: new Error("bar") } : { cause: Error; }
|
||||
>cause : Error
|
||||
>new Error("bar") : Error
|
||||
>Error : ErrorConstructor
|
||||
>"bar" : "bar"
|
||||
|
||||
new ReferenceError("foo", { cause: new Error("bar") });
|
||||
>new ReferenceError("foo", { cause: new Error("bar") }) : ReferenceError
|
||||
>ReferenceError : ReferenceErrorConstructor
|
||||
>"foo" : "foo"
|
||||
>{ cause: new Error("bar") } : { cause: Error; }
|
||||
>cause : Error
|
||||
>new Error("bar") : Error
|
||||
>Error : ErrorConstructor
|
||||
>"bar" : "bar"
|
||||
|
||||
new SyntaxError("foo", { cause: new Error("bar") });
|
||||
>new SyntaxError("foo", { cause: new Error("bar") }) : SyntaxError
|
||||
>SyntaxError : SyntaxErrorConstructor
|
||||
>"foo" : "foo"
|
||||
>{ cause: new Error("bar") } : { cause: Error; }
|
||||
>cause : Error
|
||||
>new Error("bar") : Error
|
||||
>Error : ErrorConstructor
|
||||
>"bar" : "bar"
|
||||
|
||||
new TypeError("foo", { cause: new Error("bar") });
|
||||
>new TypeError("foo", { cause: new Error("bar") }) : TypeError
|
||||
>TypeError : TypeErrorConstructor
|
||||
>"foo" : "foo"
|
||||
>{ cause: new Error("bar") } : { cause: Error; }
|
||||
>cause : Error
|
||||
>new Error("bar") : Error
|
||||
>Error : ErrorConstructor
|
||||
>"bar" : "bar"
|
||||
|
||||
new URIError("foo", { cause: new Error("bar") });
|
||||
>new URIError("foo", { cause: new Error("bar") }) : URIError
|
||||
>URIError : URIErrorConstructor
|
||||
>"foo" : "foo"
|
||||
>{ cause: new Error("bar") } : { cause: Error; }
|
||||
>cause : Error
|
||||
>new Error("bar") : Error
|
||||
>Error : ErrorConstructor
|
||||
>"bar" : "bar"
|
||||
|
||||
new AggregateError([], "foo", { cause: new Error("bar") });
|
||||
>new AggregateError([], "foo", { cause: new Error("bar") }) : AggregateError
|
||||
>AggregateError : AggregateErrorConstructor
|
||||
>[] : undefined[]
|
||||
>"foo" : "foo"
|
||||
>{ cause: new Error("bar") } : { cause: Error; }
|
||||
>cause : Error
|
||||
>new Error("bar") : Error
|
||||
>Error : ErrorConstructor
|
||||
>"bar" : "bar"
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ const repro_43249 = (value: unknown) => {
|
||||
>value : Symbol(value, Decl(flatArrayNoExcessiveStackDepth.ts, 9, 21))
|
||||
|
||||
throw new Error("No");
|
||||
>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
||||
>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2022.error.d.ts, --, --))
|
||||
}
|
||||
const match = value.match(/anything/) || [];
|
||||
>match : Symbol(match, Decl(flatArrayNoExcessiveStackDepth.ts, 13, 9))
|
||||
|
||||
@@ -224,7 +224,7 @@ type Invalid<T extends string> = {
|
||||
|
||||
[key: Error]: string; // Error
|
||||
>key : Symbol(key, Decl(indexSignatures1.ts, 88, 5))
|
||||
>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
||||
>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2022.error.d.ts, --, --))
|
||||
|
||||
[key: T & string]: string; // Error
|
||||
>key : Symbol(key, Decl(indexSignatures1.ts, 89, 5))
|
||||
|
||||
@@ -12,7 +12,7 @@ class Foo {
|
||||
>v : Symbol(v, Decl(privateNamesAssertion.ts, 1, 44))
|
||||
|
||||
throw new Error();
|
||||
>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
||||
>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2022.error.d.ts, --, --))
|
||||
}
|
||||
}
|
||||
m1(v: unknown) {
|
||||
@@ -41,7 +41,7 @@ class Foo2 {
|
||||
>v : Symbol(v, Decl(privateNamesAssertion.ts, 13, 8))
|
||||
|
||||
throw new Error();
|
||||
>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
||||
>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2022.error.d.ts, --, --))
|
||||
}
|
||||
}
|
||||
m1(v: unknown) {
|
||||
|
||||
@@ -12,7 +12,7 @@ class Foo {
|
||||
>v : Symbol(v, Decl(privateNamesAssertion.ts, 1, 44))
|
||||
|
||||
throw new Error();
|
||||
>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
||||
>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2022.error.d.ts, --, --))
|
||||
}
|
||||
}
|
||||
m1(v: unknown) {
|
||||
@@ -41,7 +41,7 @@ class Foo2 {
|
||||
>v : Symbol(v, Decl(privateNamesAssertion.ts, 13, 8))
|
||||
|
||||
throw new Error();
|
||||
>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
||||
>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2022.error.d.ts, --, --))
|
||||
}
|
||||
}
|
||||
m1(v: unknown) {
|
||||
|
||||
@@ -12,7 +12,7 @@ class Foo {
|
||||
>v : Symbol(v, Decl(privateNamesAssertion.ts, 1, 44))
|
||||
|
||||
throw new Error();
|
||||
>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
||||
>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2022.error.d.ts, --, --))
|
||||
}
|
||||
}
|
||||
m1(v: unknown) {
|
||||
@@ -41,7 +41,7 @@ class Foo2 {
|
||||
>v : Symbol(v, Decl(privateNamesAssertion.ts, 13, 8))
|
||||
|
||||
throw new Error();
|
||||
>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
||||
>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2022.error.d.ts, --, --))
|
||||
}
|
||||
}
|
||||
m1(v: unknown) {
|
||||
|
||||
@@ -1,3 +1,12 @@
|
||||
// @target: es2021, es2022, esnext
|
||||
|
||||
new Error("foo", { cause: new Error("bar") });
|
||||
let err = new Error("foo", { cause: new Error("bar") });
|
||||
err.cause;
|
||||
|
||||
new EvalError("foo", { cause: new Error("bar") });
|
||||
new RangeError("foo", { cause: new Error("bar") });
|
||||
new ReferenceError("foo", { cause: new Error("bar") });
|
||||
new SyntaxError("foo", { cause: new Error("bar") });
|
||||
new TypeError("foo", { cause: new Error("bar") });
|
||||
new URIError("foo", { cause: new Error("bar") });
|
||||
new AggregateError([], "foo", { cause: new Error("bar") });
|
||||
|
||||
Reference in New Issue
Block a user