Skip to content

Commit c2e6ade

Browse files
committed
ref: Enable noUncheckedIndex TS config
1 parent 60dad34 commit c2e6ade

File tree

149 files changed

+650
-589
lines changed

Some content is hidden

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

149 files changed

+650
-589
lines changed

dev-packages/node-integration-tests/suites/express/multiple-routers/complex-router/test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ afterAll(() => {
99
conditionalTest({ min: 16 })('complex-router', () => {
1010
test('should construct correct url with multiple parameterized routers, when param is also contain in middle layer route and express used multiple middlewares with route', done => {
1111
// parse node.js major version
12-
const [major] = process.versions.node.split('.').map(Number);
12+
const [major = 0] = process.versions.node.split('.').map(Number);
1313
// Split test result base on major node version because regex d flag is support from node 16+
1414

1515
const EXPECTED_TRANSACTION =
@@ -36,7 +36,7 @@ conditionalTest({ min: 16 })('complex-router', () => {
3636

3737
test('should construct correct url with multiple parameterized routers, when param is also contain in middle layer route and express used multiple middlewares with route and original url has query params', done => {
3838
// parse node.js major version
39-
const [major] = process.versions.node.split('.').map(Number);
39+
const [major = 0] = process.versions.node.split('.').map(Number);
4040
// Split test result base on major node version because regex d flag is support from node 16+
4141
const EXPECTED_TRANSACTION =
4242
major >= 16
@@ -62,7 +62,7 @@ conditionalTest({ min: 16 })('complex-router', () => {
6262

6363
test('should construct correct url with multiple parameterized routers, when param is also contain in middle layer route and express used multiple middlewares with route and original url ends with trailing slash and has query params', done => {
6464
// parse node.js major version
65-
const [major] = process.versions.node.split('.').map(Number);
65+
const [major = 0] = process.versions.node.split('.').map(Number);
6666
// Split test result base on major node version because regex d flag is support from node 16+
6767
const EXPECTED_TRANSACTION =
6868
major >= 16

dev-packages/node-integration-tests/suites/express/multiple-routers/middle-layer-parameterized/test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ afterAll(() => {
99
conditionalTest({ min: 16 })('middle-layer-parameterized', () => {
1010
test('should construct correct url with multiple parameterized routers, when param is also contain in middle layer route', done => {
1111
// parse node.js major version
12-
const [major] = process.versions.node.split('.').map(Number);
12+
const [major = 0] = process.versions.node.split('.').map(Number);
1313
// Split test result base on major node version because regex d flag is support from node 16+
1414
const EXPECTED_TRANSACTION =
1515
major >= 16

dev-packages/node-integration-tests/suites/public-api/LocalVariables/test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ conditionalTest({ min: 18 })('LocalVariables integration', () => {
4444
.ignore('session')
4545
.expect({
4646
event: event => {
47-
for (const frame of event.exception?.values?.[0].stacktrace?.frames || []) {
47+
for (const frame of event.exception?.values?.[0]?.stacktrace?.frames || []) {
4848
expect(frame.vars).toBeUndefined();
4949
}
5050
},

dev-packages/node-integration-tests/suites/public-api/startSpan/with-nested-spans/test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ test('should report finished spans as children of the root transaction.', done =
1010
.expect({
1111
transaction: transaction => {
1212
const rootSpanId = transaction.contexts?.trace?.span_id;
13-
const span3Id = transaction.spans?.[1].span_id;
13+
const span3Id = transaction.spans?.[1]?.span_id;
1414

1515
expect(rootSpanId).toEqual(expect.any(String));
1616
expect(span3Id).toEqual(expect.any(String));
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": "../tsconfig.test.json",
3+
}

dev-packages/node-integration-tests/utils/index.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,13 @@ export class TestEnv {
196196
* @returns The extracted envelope.
197197
*/
198198
public async getEnvelopeRequest(options?: DataCollectorOptions): Promise<Array<Record<string, unknown>>> {
199-
return (await this.getMultipleEnvelopeRequest({ ...options, count: 1 }))[0];
199+
const requests = await this.getMultipleEnvelopeRequest({ ...options, count: 1 });
200+
201+
if (!requests[0]) {
202+
throw new Error('No requests found');
203+
}
204+
205+
return requests[0];
200206
}
201207

202208
/**
@@ -239,7 +245,7 @@ export class TestEnv {
239245
.post('/api/1337/envelope/', body => {
240246
const envelope = parseEnvelope(body);
241247

242-
if (envelopeType.includes(envelope[1].type as EnvelopeItemType)) {
248+
if (envelopeType.includes(envelope[1]?.type as EnvelopeItemType)) {
243249
envelopes.push(envelope);
244250
} else {
245251
return false;
@@ -296,7 +302,7 @@ export class TestEnv {
296302
.post('/api/1337/envelope/', body => {
297303
const envelope = parseEnvelope(body);
298304

299-
if (options.envelopeType.includes(envelope[1].type as EnvelopeItemType)) {
305+
if (options.envelopeType.includes(envelope[1]?.type as EnvelopeItemType)) {
300306
reqCount++;
301307
return true;
302308
}

dev-packages/overhead-metrics/src/util/github.ts

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const octokit = new Octokit({
1313
// log: console,
1414
});
1515

16-
const [, owner, repo] = (await Git.repository).split('/');
16+
const [, owner, repo] = (await Git.repository).split('/') as [string, string, string];
1717
const defaultArgs = { owner, repo };
1818

1919
async function downloadArtifact(url: string, path: string): Promise<void> {
@@ -51,15 +51,10 @@ async function tryAddOrUpdateComment(commentBuilder: PrCommentBuilder): Promise<
5151
For example, refs/heads/feature-branch-1.
5252
*/
5353
let prNumber: number | undefined;
54-
if (
55-
typeof process.env.GITHUB_REF == 'string' &&
56-
process.env.GITHUB_REF.length > 0 &&
57-
process.env.GITHUB_REF.startsWith('refs/pull/')
58-
) {
59-
prNumber = parseInt(process.env.GITHUB_REF.split('/')[2]);
60-
console.log(
61-
`Determined PR number ${prNumber} based on GITHUB_REF environment variable: '${process.env.GITHUB_REF}'`,
62-
);
54+
const githubRef = process.env.GITHUB_REF;
55+
if (typeof githubRef == 'string' && githubRef.length > 0 && githubRef.startsWith('refs/pull/')) {
56+
prNumber = parseInt(githubRef.split('/')[2] as string);
57+
console.log(`Determined PR number ${prNumber} based on GITHUB_REF environment variable: '${githubRef}'`);
6358
} else if (!(await Git.branchIsBase)) {
6459
prNumber = (
6560
await octokit.rest.pulls.list({
@@ -155,15 +150,17 @@ export const GitHub = {
155150
status: 'success',
156151
});
157152

158-
if (workflowRuns.data.total_count == 0) {
153+
const firstRun = workflowRuns.data.workflow_runs[0];
154+
155+
if (workflowRuns.data.total_count == 0 || !firstRun) {
159156
console.warn(`Couldn't find any successful run for workflow '${workflow.name}'`);
160157
return;
161158
}
162159

163160
const artifact = (
164161
await octokit.actions.listWorkflowRunArtifacts({
165162
...defaultArgs,
166-
run_id: workflowRuns.data.workflow_runs[0].id,
163+
run_id: firstRun.id,
167164
})
168165
).data.artifacts.find(it => it.name == artifactName);
169166

dev-packages/test-utils/src/event-proxy-server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export async function startEventProxyServer(options: EventProxyServerOptions): P
5959
? zlib.gunzipSync(Buffer.concat(proxyRequestChunks)).toString()
6060
: Buffer.concat(proxyRequestChunks).toString();
6161

62-
const envelopeHeader: EnvelopeItem[0] = JSON.parse(proxyRequestBody.split('\n')[0]);
62+
const envelopeHeader: EnvelopeItem[0] = JSON.parse(proxyRequestBody.split('\n')[0] as string);
6363

6464
const shouldForwardEventToSentry = options.forwardToSentry != null ? options.forwardToSentry : true;
6565

packages/aws-serverless/src/sdk.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ export function tryPatchHandler(taskRoot: string, handlerPath: string): void {
141141
return;
142142
}
143143

144-
const [, handlerMod, handlerName] = match;
144+
const [, handlerMod = '', handlerName = ''] = match;
145145

146146
let obj: HandlerBag;
147147
try {

packages/aws-serverless/test/sdk.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ describe('AWSLambda', () => {
502502

503503
expect(evtProcessor).toBeInstanceOf(Function);
504504
// @ts-expect-error just mocking around...
505-
expect(evtProcessor(event).exception.values[0].mechanism).toEqual({
505+
expect(evtProcessor(event).exception.values[0]?.mechanism).toEqual({
506506
handled: false,
507507
type: 'generic',
508508
});

0 commit comments

Comments
 (0)