Skip to content

Commit

Permalink
chore(typescript): bump tsc globally and switch to nodenext for iroha2
Browse files Browse the repository at this point in the history
Here are all the changes implemented for
moduleResolution to nodeNext and Typescript upgrade
-------------------------------------------
1. Upgraded TypeScript to 4.7.4 globally and switched
moduleResolution nodeNext in cactus-plugin-ledger-connector-iroha2
2. Upgraded @typescript-eslint/eslint-plugin &
@typescript-eslint/eslint/parser to 5.27.0
so that it supports the newer version of Typescript.
3. Added useUnknownInCatchVariables: false in tsconfig
and tsconfig.base.json to fix the errors related to
'unknown' type in catch variables that occurred after
upgrading the typescript.
4. Updated rxjs to v7.8.1 globally in all package.json files
to match the version in IrohaV2. This is better than adding a resolution
in the root package.json because it makes it visible and explicit that
we've upgraded the dependency everywhere. The global resolutions
override is a last resort option because it is pretty confusing to
beginners when they specify a dependency version in their own package.json
but it doesn't ever get installed because of the override coming from the
top level package.json.
The reason the upgrade was needed to begin with: Typescript compiler
errors were being caused by the mismatching version of rxjs that the
iroha2 client packages depend on vs. the versions that our codebase
uses. Now with the upgrade they are in sync and the build passes.

---
Secondary change:
Peter: I'm sneaking in another hot-fix for the codegen task which makes
the .jar download (that's part of the warmup script) SEQUENTIAL instead
of having it PARALLEL which appeared to be working fine earlier but it
no longer seems to be the case, e.g., I've seen some race condition
looking errors pop up after having merged the PR with the earlier hotfix.
The root cause of the issue likely the openapi-generator-cli package
itself not being safe for concurrent use in general, but a full audit of
that code would have to be performed to validate this theory. For now
it is just easier to set it to SEQUENTIAL and be done with it (hopefully)

Fixes #2158

Co-authored-by: Peter Somogyvari <peter.somogyvari@accenture.com>

Signed-off-by: aldousalvarez <aldousss.alvarez@gmail.com>
Signed-off-by: Peter Somogyvari <peter.somogyvari@accenture.com>
  • Loading branch information
aldousalvarez authored and petermetz committed Jun 22, 2023
1 parent e52942e commit 6742817
Show file tree
Hide file tree
Showing 19 changed files with 122 additions and 134 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
"@ionic-native/splash-screen": "5.36.0",
"@ionic-native/status-bar": "5.36.0",
"@ionic/angular": "6.0.15",
"rxjs": "7.5.5",
"rxjs": "7.8.1",
"tslib": "2.3.1",
"zone.js": "0.11.4"
},
Expand Down
2 changes: 1 addition & 1 deletion examples/cactus-example-supply-chain-frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
"@ionic-native/splash-screen": "5.36.0",
"@ionic-native/status-bar": "5.36.0",
"@ionic/angular": "6.1.5",
"rxjs": "7.5.5",
"rxjs": "7.8.1",
"tslib": "2.4.0",
"zone.js": "0.11.5"
},
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"lint": "eslint '*/*/src/**/*.{js,ts}' --quiet --fix && cspell \"*/*/src/**/*.{js,ts}\"",
"tsc": "tsc --build --verbose",
"codegen": "lerna run codegen",
"precodegen": "npm-run-all --parallel --aggregate-output --continue-on-error --print-label --print-name codegen:warmup-*",
"precodegen": "npm-run-all --sequential --continue-on-error --print-label --print-name codegen:warmup-*",
"postcodegen": "rm --force --verbose ./openapitools.json",
"codegen:warmup-v5.2.1": "yarn openapi-generator-cli version-manager set 5.2.1",
"codegen:warmup-v6.3.0": "yarn openapi-generator-cli version-manager set 6.3.0",
Expand Down Expand Up @@ -102,8 +102,8 @@
"@types/tape": "4.13.2",
"@types/tape-promise": "4.0.1",
"@types/uuid": "8.3.1",
"@typescript-eslint/eslint-plugin": "4.29.1",
"@typescript-eslint/parser": "4.29.1",
"@typescript-eslint/eslint-plugin": "5.27.0",
"@typescript-eslint/parser": "5.27.0",
"buffer": "6.0.3",
"codecov": "3.8.3",
"cpy-cli": "4.1.0",
Expand Down Expand Up @@ -156,7 +156,7 @@
"ts-jest": "28.0.2",
"ts-loader": "9.2.5",
"ts-node": "10.9.1",
"typescript": "4.3.5",
"typescript": "4.7.4",
"webpack": "5.76.0",
"webpack-bundle-analyzer": "4.4.2",
"webpack-cli": "4.7.2"
Expand Down
2 changes: 1 addition & 1 deletion packages/cactus-api-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"@hyperledger/cactus-core": "2.0.0-alpha.1",
"@hyperledger/cactus-core-api": "2.0.0-alpha.1",
"@hyperledger/cactus-plugin-consortium-manual": "2.0.0-alpha.1",
"rxjs": "7.3.0"
"rxjs": "7.8.1"
},
"devDependencies": {
"@hyperledger/cactus-test-tooling": "2.0.0-alpha.1"
Expand Down
4 changes: 2 additions & 2 deletions packages/cactus-api-client/src/main/typescript/api-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export class ApiClient extends BaseAPI {
*
* @param ctor
*/
public extendWith<T extends any>(
public extendWith<T>(
ctor: new (configuration?: Configuration) => T,
): T & this {
const instance = new ctor(this.configuration) as any;
Expand Down Expand Up @@ -101,7 +101,7 @@ export class ApiClient extends BaseAPI {
* consortium metadata at runtime for the purposes of looking up ledgers by
* the provided `ledgerId` parameter.
*/
public async ofLedger<T extends any>(
public async ofLedger<T>(
ledgerOrId: string | Ledger,
ctor: new (configuration?: Configuration) => T,
ctorArgs: Record<string, unknown>,
Expand Down
2 changes: 1 addition & 1 deletion packages/cactus-cmd-api-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
"node-forge": "1.3.0",
"prom-client": "13.2.0",
"run-time-error": "1.4.0",
"rxjs": "7.3.0",
"rxjs": "7.8.1",
"semver": "7.3.5",
"socket.io": "4.4.1",
"socket.io-client": "4.4.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/cactus-core-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
"@grpc/proto-loader": "0.6.4",
"@types/express": "4.17.13",
"make-dir-cli": "3.0.0",
"rxjs": "7.3.0",
"rxjs": "7.8.1",
"socket.io": "4.4.1",
"typescript-optional": "2.0.1"
}
Expand Down
2 changes: 1 addition & 1 deletion packages/cactus-plugin-ledger-connector-besu/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"openapi-types": "9.1.0",
"prom-client": "13.2.0",
"run-time-error": "1.4.0",
"rxjs": "7.3.0",
"rxjs": "7.8.1",
"socket.io-client": "4.1.3",
"typescript-optional": "2.0.1",
"web3": "1.5.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/cactus-plugin-ledger-connector-corda/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
"joi": "17.9.1",
"node-ssh": "12.0.0",
"prom-client": "13.2.0",
"rxjs": "7.3.0",
"rxjs": "7.8.1",
"temp": "0.9.4",
"typescript-optional": "2.0.1"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
"node-vault": "0.9.22",
"openapi-types": "9.1.0",
"prom-client": "13.2.0",
"rxjs": "7.3.0",
"rxjs": "7.8.1",
"sanitize-filename": "1.6.3",
"sanitize-html": "2.7.0",
"secp256k1": "4.0.3",
Expand Down
2 changes: 1 addition & 1 deletion packages/cactus-plugin-ledger-connector-iroha/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
"openapi-types": "7.0.1",
"prom-client": "13.1.0",
"run-time-error": "1.4.0",
"rxjs": "7.3.0",
"rxjs": "7.8.1",
"sanitize-html": "2.7.0",
"typescript-optional": "2.0.1"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
"@iroha2/data-model": "3.0.0",
"fast-safe-stringify": "2.1.1",
"hada": "0.0.8",
"rxjs": "7.3.0",
"rxjs": "7.8.1",
"sanitize-html": "2.7.0",
"undici": "5.19.1"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"outDir": "./dist/lib/",
"declarationDir": "dist/types",
"resolveJsonModule": true,
"moduleResolution": "nodenext",
"rootDir": "./src",
"tsBuildInfoFile": "../../.build-cache/cactus-plugin-ledger-connector-iroha2.tsbuildinfo"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
"minimist": "1.2.8",
"prom-client": "13.2.0",
"run-time-error": "1.4.0",
"rxjs": "7.3.0",
"rxjs": "7.8.1",
"sanitize-html": "2.7.0",
"typescript-optional": "2.0.1",
"web3": "1.5.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/cactus-plugin-persistence-ethereum/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
"@types/express": "4.17.13",
"@types/pg": "8.6.5",
"jest-extended": "2.0.0",
"rxjs": "7.3.0",
"rxjs": "7.8.1",
"web3": "1.5.2",
"web3-core": "1.5.2",
"web3-eth": "1.5.2"
Expand Down
2 changes: 1 addition & 1 deletion packages/cactus-verifier-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,6 @@
"@hyperledger/cactus-plugin-ledger-connector-iroha": "2.0.0-alpha.1",
"@hyperledger/cactus-plugin-ledger-connector-quorum": "2.0.0-alpha.1",
"jest-extended": "0.11.5",
"rxjs": "7.3.0"
"rxjs": "7.8.1"
}
}
3 changes: 2 additions & 1 deletion tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
/* Advanced Options */
"forceConsistentCasingInFileNames": true, /* Disallow inconsistently-cased references to the same file. */
"skipLibCheck": true
"skipLibCheck": true,
"useUnknownInCatchVariables": false
},
}
10 changes: 4 additions & 6 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@
// "allowJs": true, /* Allow javascript files to be compiled. */
// "checkJs": true, /* Report errors in .js files. */
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
"declaration": true, /* Generates corresponding '.d.ts' file. */
"declaration": true /* Generates corresponding '.d.ts' file. */,
// "declarationDir": "dist/lib",
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
// "sourceMap": true, /* Generates corresponding '.map' file. */
Expand Down Expand Up @@ -194,12 +194,10 @@
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
"typeRoots": [
"./node_modules/@types",
"./typings"
],
"typeRoots": ["./node_modules/@types", "./typings"],
"esModuleInterop": true,
"inlineSourceMap": true,
"forceConsistentCasingInFileNames": true
"forceConsistentCasingInFileNames": true,
"useUnknownInCatchVariables": false
}
}
Loading

0 comments on commit 6742817

Please sign in to comment.