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
This commit is contained in:
parent
28278450a4
commit
4f7ff96e50
|
@ -6,10 +6,11 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
const {Generator, NgswConfig} = require('@angular/service-worker/config');
|
||||
const {Generator} = require('@angular/service-worker/config');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
import {NodeFilesystem} from './filesystem';
|
||||
import {Config} from '../config/src/in';
|
||||
|
||||
|
||||
const cwd = process.cwd();
|
||||
|
@ -18,7 +19,7 @@ const distDir = path.join(cwd, process.argv[2]);
|
|||
const config = path.join(cwd, process.argv[3]);
|
||||
const baseHref = process.argv[4] || '/';
|
||||
|
||||
const configParsed = JSON.parse(fs.readFileSync(config).toString());
|
||||
const configParsed = JSON.parse(fs.readFileSync(config).toString()) as Config;
|
||||
|
||||
const filesystem = new NodeFilesystem(distDir);
|
||||
const gen = new Generator(filesystem, baseHref);
|
||||
|
|
|
@ -994,7 +994,7 @@ describe('Driver', () => {
|
|||
const getClientAssignments = async (sw: SwTestHarness, baseHref: string) => {
|
||||
const cache = await sw.caches.open(`ngsw:${baseHref}:db:control`) as unknown as MockCache;
|
||||
const dehydrated = cache.dehydrate();
|
||||
return JSON.parse(dehydrated['/assignments'].body!);
|
||||
return JSON.parse(dehydrated['/assignments'].body!) as any;
|
||||
};
|
||||
|
||||
const initializeSwFor = async (baseHref: string, initialCacheState = '{}') => {
|
||||
|
|
|
@ -29,7 +29,7 @@ export class MockBody implements Body {
|
|||
}
|
||||
|
||||
async json(): Promise<any> {
|
||||
return JSON.parse(this.getBody());
|
||||
return JSON.parse(this.getBody()) as any;
|
||||
}
|
||||
|
||||
async text(): Promise<string> {
|
||||
|
|
Loading…
Reference in New Issue