Skip to content

Commit

Permalink
Updates for TypeScript 4.4.3 (#2950)
Browse files Browse the repository at this point in the history
* Updates for TS 4.4.3

* Update package-lock
  • Loading branch information
jeffposnick committed Oct 13, 2021
1 parent 8afb372 commit 80cbaf6
Show file tree
Hide file tree
Showing 16 changed files with 277 additions and 192 deletions.
333 changes: 190 additions & 143 deletions package-lock.json

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions package.json
Expand Up @@ -22,8 +22,8 @@
"@types/fs-extra": "^9.0.5",
"@types/lodash": "^4.14.165",
"@types/stringify-object": "^3.3.0",
"@typescript-eslint/eslint-plugin": "^4.28.1",
"@typescript-eslint/parser": "^4.28.1",
"@typescript-eslint/eslint-plugin": "^4.32.0",
"@typescript-eslint/parser": "^4.32.0",
"acorn": "^8.0.1",
"babel-plugin-transform-async-to-promises": "^0.8.15",
"babylon": "^6.18.0",
Expand Down Expand Up @@ -55,7 +55,7 @@
"html-webpack-plugin-v4": "npm:html-webpack-plugin@^4.5.0",
"html-webpack-plugin-v5": "npm:html-webpack-plugin@^5.0.0-alpha.14",
"husky": "^7.0.2",
"idb": "^6.0.0",
"idb": "^6.1.4",
"jsdoc": "^3.6.5",
"jsdoc-baseline": "^0.1.5",
"lerna": "^3.22.1",
Expand All @@ -71,16 +71,16 @@
"require-dir": "^1.2.0",
"rollup": "^2.43.1",
"rollup-plugin-terser": "^7.0.0",
"rollup-plugin-typescript2": "^0.27.2",
"rollup-plugin-typescript2": "^0.30.0",
"selenium-assistant": "^6.1.0",
"semver": "^7.3.2",
"serve-index": "^1.9.1",
"service-worker-mock": "^1.9.3",
"sinon": "^9.0.3",
"tempy": "^0.6.0",
"type-fest": "^0.20.2",
"typescript": "^4.1.5",
"typescript-json-schema": "^0.50.1",
"type-fest": "^2.3.4",
"typescript": "^4.4.3",
"typescript-json-schema": "^0.51.0",
"upath": "^1.2.0",
"webpack-v4": "npm:webpack@^4.44.2",
"webpack-v5": "npm:webpack@^5.9.0",
Expand Down
12 changes: 6 additions & 6 deletions packages/workbox-background-sync/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/workbox-background-sync/package.json
Expand Up @@ -24,7 +24,7 @@
"module": "index.mjs",
"types": "index.d.ts",
"dependencies": {
"idb": "^6.0.0",
"idb": "^6.1.4",
"workbox-core": "6.3.0"
}
}
8 changes: 2 additions & 6 deletions packages/workbox-background-sync/src/Queue.ts
Expand Up @@ -276,9 +276,7 @@ class Queue {
entry.metadata = metadata;
}

await this._queueStore[`${operation}Entry` as 'pushEntry' | 'unshiftEntry'](
entry,
);
await this._queueStore[`${operation}Entry`](entry);

if (process.env.NODE_ENV !== 'production') {
logger.log(
Expand Down Expand Up @@ -309,9 +307,7 @@ class Queue {
operation: 'pop' | 'shift',
): Promise<QueueEntry | undefined> {
const now = Date.now();
const entry = await this._queueStore[
`${operation}Entry` as 'popEntry' | 'shiftEntry'
]();
const entry = await this._queueStore[`${operation}Entry`]();

if (entry) {
// Ignore requests older than maxRetentionTime. Call this function
Expand Down
21 changes: 21 additions & 0 deletions packages/workbox-background-sync/src/index.ts
Expand Up @@ -11,6 +11,27 @@ import {BackgroundSyncPlugin} from './BackgroundSyncPlugin.js';

import './_version.js';

// See https://github.com/GoogleChrome/workbox/issues/2946
interface SyncManager {
getTags(): Promise<string[]>;
register(tag: string): Promise<void>;
}

declare global {
interface ServiceWorkerRegistration {
readonly sync: SyncManager;
}

interface SyncEvent extends ExtendableEvent {
readonly lastChance: boolean;
readonly tag: string;
}

interface ServiceWorkerGlobalScopeEventMap {
sync: SyncEvent;
}
}

/**
* @module workbox-background-sync
*/
Expand Down
14 changes: 3 additions & 11 deletions packages/workbox-build/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion packages/workbox-build/package.json
Expand Up @@ -63,5 +63,8 @@
"workbox": {
"packageType": "node_ts"
},
"types": "build/index.d.ts"
"types": "build/index.d.ts",
"devDependencies": {
"@types/node": "^16.10.2"
}
}
Expand Up @@ -86,16 +86,11 @@ export async function writeSWUsingDefaultTemplate({

return filePaths;
} catch (error) {
// error.code is typed any
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
if (error.code === 'EISDIR') {
const err = error as NodeJS.ErrnoException;
if (err.code === 'EISDIR') {
// See https://github.com/GoogleChrome/workbox/issues/612
throw new Error(errors['sw-write-failure-directory']);
}
throw new Error(
`${errors['sw-write-failure']} '${
error instanceof Error && error.message ? error.message : ''
}'`,
);
throw new Error(`${errors['sw-write-failure']} '${err.message}'`);
}
}
11 changes: 8 additions & 3 deletions packages/workbox-expiration/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/workbox-expiration/package.json
Expand Up @@ -22,7 +22,7 @@
"module": "index.mjs",
"types": "index.d.ts",
"dependencies": {
"idb": "^6.0.0",
"idb": "^6.1.4",
"workbox-core": "6.3.0"
}
}
19 changes: 19 additions & 0 deletions packages/workbox-navigation-preload/src/index.ts
Expand Up @@ -11,6 +11,25 @@ import {enable} from './enable.js';
import {isSupported} from './isSupported.js';
import './_version.js';

// See https://github.com/GoogleChrome/workbox/issues/2946
interface NavigationPreloadState {
enabled?: boolean;
headerValue?: string;
}

interface NavigationPreloadManager {
disable(): Promise<void>;
enable(): Promise<void>;
getState(): Promise<NavigationPreloadState>;
setHeaderValue(value: string): Promise<void>;
}

declare global {
interface ServiceWorkerRegistration {
readonly navigationPreload: NavigationPreloadManager;
}
}

/**
* @module workbox-navigation-preload
*/
Expand Down
4 changes: 1 addition & 3 deletions packages/workbox-strategies/src/StrategyHandler.ts
Expand Up @@ -155,9 +155,7 @@ class StrategyHandler {
event instanceof FetchEvent &&
event.preloadResponse
) {
const possiblePreloadResponse = (await event.preloadResponse) as
| Response
| undefined;
const possiblePreloadResponse = await event.preloadResponse;
if (possiblePreloadResponse) {
if (process.env.NODE_ENV !== 'production') {
logger.log(
Expand Down
7 changes: 7 additions & 0 deletions packages/workbox-strategies/src/index.ts
Expand Up @@ -15,6 +15,13 @@ import {Strategy} from './Strategy.js';
import {StrategyHandler} from './StrategyHandler.js';
import './_version.js';

// See https://github.com/GoogleChrome/workbox/issues/2946
declare global {
interface FetchEvent {
readonly preloadResponse: Promise<Response | undefined>;
}
}

/**
* There are common caching strategies that most service workers will need
* and use. This module provides simple implementations of these strategies.
Expand Down
4 changes: 3 additions & 1 deletion packages/workbox-streams/src/concatenate.ts
Expand Up @@ -21,7 +21,9 @@ import './_version.js';
* @return {ReadableStreamReader}
* @private
*/
function _getReaderFromSource(source: StreamSource): ReadableStreamReader {
function _getReaderFromSource(
source: StreamSource,
): ReadableStreamReader<unknown> {
if (source instanceof Response) {
return source.body!.getReader();
}
Expand Down
2 changes: 1 addition & 1 deletion packages/workbox-window/src/Workbox.ts
Expand Up @@ -575,7 +575,7 @@ class Workbox extends WorkboxEventTarget {
if (process.env.NODE_ENV !== 'production') {
logger.log('Registered service worker now controlling this page.');
}
this._controllingDeferred.resolve(sw!);
this._controllingDeferred.resolve(sw);
}
};

Expand Down

0 comments on commit 80cbaf6

Please sign in to comment.