Skip to content

Commit 0107e42

Browse files
authored
chore: type-cast server.address() calls (#6965)
Avoid TS complaining about `address()` possibly returning `null`.
1 parent 7b1489a commit 0107e42

File tree

96 files changed

+113
-109
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

96 files changed

+113
-109
lines changed

integration-tests/aiguard/server.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,6 @@ app.get('/abort', async (req, res) => {
4848
})
4949

5050
const server = app.listen(() => {
51-
const port = server.address().port
51+
const port = (/** @type {import('net').AddressInfo} */ (server.address())).port
5252
process.send({ port })
5353
})

integration-tests/appsec/data-collection/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,5 @@ app.get('/', (req, res) => {
2222
})
2323

2424
const server = app.listen(process.env.APP_PORT || 0, () => {
25-
process.send?.({ port: server.address().port })
25+
process.send?.({ port: (/** @type {import('net').AddressInfo} */ (server.address())).port })
2626
})

integration-tests/appsec/endpoints-collection/express.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,6 @@ app.use('/invalid', invalidRouter)
122122
invalidRouter.get('nested', (_, res) => res.send('ok'))
123123

124124
const server = app.listen(0, '127.0.0.1', () => {
125-
const port = server.address().port
125+
const port = (/** @type {import('net').AddressInfo} */ (server.address())).port
126126
process.send({ port })
127127
})

integration-tests/appsec/esm-app/index.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ app.get('/cmdi-vulnerable', (req, res) => {
1414
app.use('/more', (await import('./more.mjs')).default)
1515

1616
const server = app.listen(process.env.APP_PORT || 0, () => {
17-
process.send?.({ port: server.address().port })
17+
process.send?.({ port: (/** @type {import('net').AddressInfo} */ (server.address())).port })
1818
})
1919

2020
Module.register('./custom-noop-hooks.mjs', {

integration-tests/appsec/esm-security-controls/index.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,5 +62,5 @@ app.get('/cmdi-iv-secure', (req, res) => {
6262
})
6363

6464
const server = app.listen(process.env.APP_PORT || 0, () => {
65-
process.send?.({ port: server.address().port })
65+
process.send?.({ port: (/** @type {import('net').AddressInfo} */ (server.address())).port })
6666
})

integration-tests/appsec/iast-esbuild-cjs/app.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ const app = express()
1212
app.use('/iast', iastRouter)
1313

1414
const server = app.listen(0, () => {
15-
process.send?.({ port: server.address().port })
15+
process.send?.({ port: (/** @type {import('net').AddressInfo} */ (server.address())).port })
1616
})

integration-tests/appsec/iast-esbuild-esm/app.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ const app = express()
99
app.use('/iast', iastRouter)
1010

1111
const server = app.listen(0, () => {
12-
process.send?.({ port: server.address().port })
12+
process.send?.({ port: (/** @type {import('net').AddressInfo} */ (server.address())).port })
1313
})

integration-tests/appsec/iast-stack-traces-ts-with-sourcemaps/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ app.use('/not-rewritten', notRewrittenRoutes)
99
app.use('/rewritten', rewrittenRoutes)
1010

1111
const server = app.listen(process.env.APP_PORT || 0, () => {
12-
process.send?.({ port: server.address().port })
12+
process.send?.({ port: (/** @type {import('net').AddressInfo} */ (server.address())).port })
1313
})

integration-tests/appsec/multer/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,6 @@ app.get('/', (req, res) => {
5959
})
6060

6161
const server = http.createServer(app).listen(0, () => {
62-
const port = server.address().port
62+
const port = (/** @type {import('net').AddressInfo} */ (server.address())).port
6363
process.send?.({ port })
6464
})

integration-tests/debugger/target-app/custom-logger.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,5 @@ const server = http.createServer((req, res) => {
1919
})
2020

2121
server.listen(process.env.APP_PORT || 0, () => {
22-
process.send?.({ port: server.address().port })
22+
process.send?.({ port: (/** @type {import('net').AddressInfo} */ (server.address())).port })
2323
})

0 commit comments

Comments
 (0)