Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: migrate to Typescript target of ES2022 and use Error.cause #3593

Merged
merged 1 commit into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"importHelpers": true,
"target": "ES2022",
"lib": [
"es2018",
"ES2022",
"dom"
],
"resolveJsonModule": true,
Expand Down
6 changes: 2 additions & 4 deletions examples/test-run-transaction/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@
"compilerOptions": {
/* Basic Options */
"incremental": true, /* Enable incremental compilation */
"target": "ES2017", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */
"target": "ES2022", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */
"module": "CommonJS", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
"lib": [
"es2015",
"es2016",
"es2017",
"ES2022",
"dom"
], /* Specify library files to be included in the compilation. */
// "allowJs": true, /* Allow javascript files to be compiled. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,25 @@ import { RuntimeError } from "run-time-error-cjs";
import { coerceUnknownToError } from "./coerce-unknown-to-error";

/**
* ## DEPRECATED
*
* Instead of relying on this function, in the future, use the new `cause`
* property of the built-in `Error` type in combination
* with the `asError(unknown)` utility function:
* ```typescript
* import { asError } from "@hyperledger/cactus-common";
*
* try {
* await performSomeImportantOperation();
* } catch (ex: unknown) {
* const cause = asError(ex);
* throw new Error("Something went wrong while doing something.", { cause });
* }
* ```
* More information about the EcmaScript proposal that made this possible:
* https://github.com/tc39/proposal-error-cause
*
* ## The Old Documentation Prior to the Deprecation:
* ### STANDARD EXCEPTION HANDLING - EXAMPLE WITH RE-THROW:
*
* Use the this utility function and pass in any throwable of whatever type and format
Expand Down Expand Up @@ -77,6 +96,7 @@ import { coerceUnknownToError } from "./coerce-unknown-to-error";
* return result; // 42
* }
* ```
* @deprecated
*
* @param message The contextual information that will be passed into the
* constructor of the returned {@link RuntimeError} instance.
Expand All @@ -93,9 +113,28 @@ export function createRuntimeErrorWithCause(
}

/**
* ## DEPRECATED
*
* Instead of relying on this function, in the future, use the new `cause`
* property of the built-in `Error` type in combination
* with the `asError(unknown)` utility function:
* ```typescript
* import { asError } from "@hyperledger/cactus-common";
*
* try {
* await performSomeImportantOperation();
* } catch (ex: unknown) {
* const cause = asError(ex);
* throw new Error("Something went wrong while doing something.", { cause });
* }
* ```
* More information about the EcmaScript proposal that made this possible:
* https://github.com/tc39/proposal-error-cause
*
* An alias to the `createRuntimeErrorWithCause` function for those prefering
* a shorter utility for their personal style.
*
* @deprecated
* @see {@link createRuntimeErrorWithCause}
* @returns `RuntimeError`
*/
Expand Down
7 changes: 2 additions & 5 deletions tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,10 @@
},
/* Basic Options */
"incremental": true, /* Enable incremental compilation */
"target": "ES2017", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */
"target": "ES2022", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */
"module": "CommonJS", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
"lib": [
"es2015",
"es2016",
"es2017",
"es2019",
"ES2022",
"dom"
], /* Specify library files to be included in the compilation. */
// "allowJs": true, /* Allow javascript files to be compiled. */
Expand Down
7 changes: 2 additions & 5 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -172,13 +172,10 @@
],
"compilerOptions": {
"incremental": true,
"target": "ES2017",
"target": "ES2022",
"module": "Node16",
"lib": [
"es2015",
"es2016",
"es2017",
"es2019",
"ES2022",
"dom"
] /* Specify library files to be included in the compilation. */,
// "allowJs": true, /* Allow javascript files to be compiled. */
Expand Down
Loading