Skip to content

Commit 4f7ff96

Browse files
josephperrottalxhub
authored andcommitted
fix(service-worker): update type castings for JSON.parse usage (#40710)
Update usages of JSON.parse to be cast as specific types. PR Close #40710
1 parent 2827845 commit 4f7ff96

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

packages/service-worker/cli/main.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9-
const {Generator, NgswConfig} = require('@angular/service-worker/config');
9+
const {Generator} = require('@angular/service-worker/config');
1010
const fs = require('fs');
1111
const path = require('path');
1212
import {NodeFilesystem} from './filesystem';
13+
import {Config} from '../config/src/in';
1314

1415

1516
const cwd = process.cwd();
@@ -18,7 +19,7 @@ const distDir = path.join(cwd, process.argv[2]);
1819
const config = path.join(cwd, process.argv[3]);
1920
const baseHref = process.argv[4] || '/';
2021

21-
const configParsed = JSON.parse(fs.readFileSync(config).toString());
22+
const configParsed = JSON.parse(fs.readFileSync(config).toString()) as Config;
2223

2324
const filesystem = new NodeFilesystem(distDir);
2425
const gen = new Generator(filesystem, baseHref);

packages/service-worker/worker/test/happy_spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -994,7 +994,7 @@ describe('Driver', () => {
994994
const getClientAssignments = async (sw: SwTestHarness, baseHref: string) => {
995995
const cache = await sw.caches.open(`ngsw:${baseHref}:db:control`) as unknown as MockCache;
996996
const dehydrated = cache.dehydrate();
997-
return JSON.parse(dehydrated['/assignments'].body!);
997+
return JSON.parse(dehydrated['/assignments'].body!) as any;
998998
};
999999

10001000
const initializeSwFor = async (baseHref: string, initialCacheState = '{}') => {

packages/service-worker/worker/testing/fetch.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export class MockBody implements Body {
2929
}
3030

3131
async json(): Promise<any> {
32-
return JSON.parse(this.getBody());
32+
return JSON.parse(this.getBody()) as any;
3333
}
3434

3535
async text(): Promise<string> {

0 commit comments

Comments
 (0)