Skip to content

Commit

Permalink
Don't use unknown for workbox-build method config (#3037)
Browse files Browse the repository at this point in the history
* Don't use unknown for config

* Relax internal type

* Tweaked casting
  • Loading branch information
jeffposnick authored Mar 2, 2022
1 parent b47500c commit ab2882b
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
6 changes: 4 additions & 2 deletions packages/workbox-build/src/generate-sw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import upath from 'upath';

import {BuildResult, GetManifestOptions} from './types';
import {BuildResult, GetManifestOptions, GenerateSWOptions} from './types';
import {getFileManifestEntries} from './lib/get-file-manifest-entries';
import {rebasePath} from './lib/rebase-path';
import {validateGenerateSWOptions} from './lib/validate-options';
Expand Down Expand Up @@ -193,7 +193,9 @@ import {writeSWUsingDefaultTemplate} from './lib/write-sw-using-default-template
*
* @memberof workbox-build
*/
export async function generateSW(config: unknown): Promise<BuildResult> {
export async function generateSW(
config: GenerateSWOptions,
): Promise<BuildResult> {
const options = validateGenerateSWOptions(config);
let entriesResult;

Expand Down
6 changes: 4 additions & 2 deletions packages/workbox-build/src/get-manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

import {getFileManifestEntries} from './lib/get-file-manifest-entries';
import {GetManifestResult} from './types';
import {GetManifestOptions, GetManifestResult} from './types';
import {validateGetManifestOptions} from './lib/validate-options';

// eslint-disable-next-line jsdoc/newline-after-description
Expand Down Expand Up @@ -88,7 +88,9 @@ import {validateGetManifestOptions} from './lib/validate-options';
*
* @memberof workbox-build
*/
export async function getManifest(config: unknown): Promise<GetManifestResult> {
export async function getManifest(
config: GetManifestOptions,
): Promise<GetManifestResult> {
const options = validateGetManifestOptions(config);

return await getFileManifestEntries(options);
Expand Down
6 changes: 4 additions & 2 deletions packages/workbox-build/src/inject-manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import fse from 'fs-extra';
import stringify from 'fast-json-stable-stringify';
import upath from 'upath';

import {BuildResult} from './types';
import {BuildResult, InjectManifestOptions} from './types';
import {errors} from './lib/errors';
import {escapeRegExp} from './lib/escape-regexp';
import {getFileManifestEntries} from './lib/get-file-manifest-entries';
Expand Down Expand Up @@ -117,7 +117,9 @@ import {validateInjectManifestOptions} from './lib/validate-options';
*
* @memberof workbox-build
*/
export async function injectManifest(config: unknown): Promise<BuildResult> {
export async function injectManifest(
config: InjectManifestOptions,
): Promise<BuildResult> {
const options = validateInjectManifestOptions(config);

// Make sure we leave swSrc and swDest out of the precache manifest.
Expand Down
2 changes: 1 addition & 1 deletion packages/workbox-cli/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ interface BuildCommand {
*/
async function runBuildCommand({command, config, watch}: BuildCommand) {
const {count, filePaths, size, warnings} = await workboxBuild[command](
config,
config as any,
);

for (const warning of warnings) {
Expand Down

0 comments on commit ab2882b

Please sign in to comment.