Skip to content

Commit dcd0841

Browse files
committed
fix: resolve axios 1.x and thor-devkit 2.2.0 type errors
driver/simple-net.ts: - Cast resp.headers to Record<string,string> (AxiosResponseHeaders type change) - Use optional chaining on err.config (possibly undefined in axios 1.x) framework/tsconfig.json: - Add lib ES2017 for String.padStart - Add node to types repl/tsconfig.json: - Add @vechain/connex-types, driver-interface and node to types root package.json: - Upgrade @types/node ^20 → ^22 (required for Buffer<T> generics in thor-devkit 2.2.0)
1 parent 44f993d commit dcd0841

5 files changed

Lines changed: 15 additions & 11 deletions

File tree

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"solo:down": "docker compose -f docker/docker-compose.yml down"
1717
},
1818
"devDependencies": {
19-
"@types/node": "^20.19.37",
19+
"@types/node": "^22.19.15",
2020
"@typescript-eslint/eslint-plugin": "^8.57.1",
2121
"@typescript-eslint/parser": "^8.57.1",
2222
"@vitest/browser": "^4.1.0",

packages/driver/src/simple-net.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export class SimpleNet implements Net {
3636
params: params.query
3737
})
3838
if (params.validateResponseHeader) {
39-
params.validateResponseHeader(resp.headers)
39+
params.validateResponseHeader(resp.headers as Record<string, string>)
4040
}
4141
return resp.data
4242
} catch (err) {
@@ -55,18 +55,20 @@ export class SimpleNet implements Net {
5555
}
5656

5757
function convertError(err: AxiosError) {
58+
const method = err.config?.method ?? ''
59+
const url = err.config?.url ?? ''
5860
if (err.response) {
5961
const resp = err.response
6062
if (typeof resp.data === 'string') {
6163
let text = resp.data.trim()
6264
if (text.length > 50) {
6365
text = text.slice(0, 50) + '...'
6466
}
65-
return new Error(`${resp.status} ${err.config.method} ${err.config.url}: ${text}`)
67+
return new Error(`${resp.status} ${method} ${url}: ${text}`)
6668
} else {
67-
return new Error(`${resp.status} ${err.config.method} ${err.config.url}`)
69+
return new Error(`${resp.status} ${method} ${url}`)
6870
}
6971
} else {
70-
return new Error(`${err.config.method} ${err.config.url}: ${err.message}`)
72+
return new Error(`${method} ${url}: ${err.message}`)
7173
}
7274
}

packages/framework/tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
"extends": "../../tsconfig.base.json",
33
"compilerOptions": {
44
"outDir": "./dist",
5-
"types": ["@vechain/connex-types"],
5+
"lib": ["ES2017"],
6+
"types": ["@vechain/connex-types", "node"],
67
},
78
"include": [
89
"./src"

packages/repl/tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
"compilerOptions": {
44
"outDir": "./dist",
55
"resolveJsonModule": true,
6-
"esModuleInterop": true
6+
"esModuleInterop": true,
7+
"types": ["@vechain/connex-types", "@vechain/connex-framework/dist/driver-interface", "node"]
78
},
89
"include": [
910
"./src"

0 commit comments

Comments
 (0)