fix(benchpress): update type castings for JSON.parse usage (#40710)

Update usages of JSON.parse to be cast as specific types.

PR Close #40710
This commit is contained in:
Joey Perrott 2021-02-04 14:39:32 -08:00 committed by Alex Rickabaugh
parent f728490222
commit e721a5d258
3 changed files with 3 additions and 3 deletions

View File

@ -86,7 +86,7 @@ export class ChromeDriverExtension extends WebDriverExtension {
.then((entries) => { .then((entries) => {
const events: PerfLogEvent[] = []; const events: PerfLogEvent[] = [];
entries.forEach((entry: any) => { entries.forEach((entry: any) => {
const message = JSON.parse(entry['message'])['message']; const message = (JSON.parse(entry['message']) as {message: any})['message'];
if (message['method'] === 'Tracing.dataCollected') { if (message['method'] === 'Tracing.dataCollected') {
events.push(message['params']); events.push(message['params']);
} }

View File

@ -44,7 +44,7 @@ export class IOsDriverExtension extends WebDriverExtension {
.then((entries) => { .then((entries) => {
const records: any[] = []; const records: any[] = [];
entries.forEach((entry: any) => { entries.forEach((entry: any) => {
const message = JSON.parse(entry['message'])['message']; const message = (JSON.parse(entry['message']) as {message: any})['message'];
if (message['method'] === 'Timeline.eventRecorded') { if (message['method'] === 'Timeline.eventRecorded') {
records.push(message['params']['record']); records.push(message['params']['record']);
} }

View File

@ -50,7 +50,7 @@ import {Injector, JsonFileReporter, MeasureValues, Options, SampleDescription} f
[mv(0, 0, {'a': 3, 'b': 6}), mv(1, 1, {'a': 5, 'b': 9})]); [mv(0, 0, {'a': 3, 'b': 6}), mv(1, 1, {'a': 5, 'b': 9})]);
const regExp = /somePath\/someId_\d+\.json/; const regExp = /somePath\/someId_\d+\.json/;
expect(loggedFile['filename'].match(regExp) != null).toBe(true); expect(loggedFile['filename'].match(regExp) != null).toBe(true);
const parsedContent = JSON.parse(loggedFile['content']); const parsedContent = JSON.parse(loggedFile['content']) as any;
expect(parsedContent).toEqual({ expect(parsedContent).toEqual({
'description': { 'description': {
'id': 'someId', 'id': 'someId',