mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-05 20:32:42 +02:00
refactor: fix a lot of errors in type-aware linting (#7477)
This commit is contained in:
parent
222bf3c091
commit
bf1513a3e3
120 changed files with 407 additions and 364 deletions
|
@ -89,7 +89,7 @@ export default function pluginPWA(
|
|||
new webpack.EnvironmentPlugin({
|
||||
PWA_DEBUG: debug,
|
||||
PWA_SERVICE_WORKER_URL: path.posix.resolve(
|
||||
`${config.output?.publicPath || '/'}`,
|
||||
`${(config.output?.publicPath as string) || '/'}`,
|
||||
'sw.js',
|
||||
),
|
||||
PWA_OFFLINE_MODE_ACTIVATION_STRATEGIES:
|
||||
|
@ -102,7 +102,7 @@ export default function pluginPWA(
|
|||
|
||||
injectHtmlTags() {
|
||||
const headTags: HtmlTags = [];
|
||||
if (isProd && pwaHead) {
|
||||
if (isProd) {
|
||||
pwaHead.forEach(({tagName, ...attributes}) => {
|
||||
(['href', 'content'] as const).forEach((attribute) => {
|
||||
const attributeValue = attributes[attribute];
|
||||
|
@ -160,7 +160,7 @@ export default function pluginPWA(
|
|||
plugins: [
|
||||
new webpack.EnvironmentPlugin({
|
||||
// Fallback value required with Webpack 5
|
||||
PWA_SW_CUSTOM: swCustom || '',
|
||||
PWA_SW_CUSTOM: swCustom ?? '',
|
||||
}),
|
||||
new LogPlugin({
|
||||
name: 'Service Worker',
|
||||
|
@ -189,7 +189,7 @@ export default function pluginPWA(
|
|||
'**/*.{png,jpg,jpeg,gif,svg,ico}',
|
||||
'**/*.{woff,woff2,eot,ttf,otf}',
|
||||
// @ts-expect-error: internal API?
|
||||
...(injectManifest.globPatterns ?? []),
|
||||
...((injectManifest.globPatterns as string[] | undefined) ?? []),
|
||||
],
|
||||
// Those attributes are not overrideable
|
||||
swDest,
|
||||
|
|
|
@ -23,7 +23,7 @@ const DEFAULT_OPTIONS = {
|
|||
reloadPopup: '@theme/PwaReloadPopup',
|
||||
};
|
||||
|
||||
const Schema = Joi.object({
|
||||
const optionsSchema = Joi.object<PluginOptions>({
|
||||
debug: Joi.bool().default(DEFAULT_OPTIONS.debug),
|
||||
offlineModeActivationStrategies: Joi.array()
|
||||
.items(
|
||||
|
@ -58,5 +58,5 @@ export function validateOptions({
|
|||
validate,
|
||||
options,
|
||||
}: OptionValidationContext<PluginOptions, PluginOptions>): PluginOptions {
|
||||
return validate(Schema, options);
|
||||
return validate(optionsSchema, options);
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ import {createStorageSlot} from '@docusaurus/theme-common';
|
|||
|
||||
// First: read the env variables (provided by Webpack)
|
||||
/* eslint-disable prefer-destructuring */
|
||||
const PWA_SERVICE_WORKER_URL = process.env.PWA_SERVICE_WORKER_URL;
|
||||
const PWA_SERVICE_WORKER_URL = process.env.PWA_SERVICE_WORKER_URL!;
|
||||
const PWA_RELOAD_POPUP = process.env.PWA_RELOAD_POPUP;
|
||||
const PWA_OFFLINE_MODE_ACTIVATION_STRATEGIES = process.env
|
||||
.PWA_OFFLINE_MODE_ACTIVATION_STRATEGIES as unknown as (keyof typeof OfflineModeActivationStrategiesImplementations)[];
|
||||
|
@ -34,7 +34,7 @@ async function clearRegistrations() {
|
|||
}
|
||||
await Promise.all(
|
||||
registrations.map(async (registration) => {
|
||||
const result = await registration?.unregister();
|
||||
const result = await registration.unregister();
|
||||
if (debug) {
|
||||
console.log(
|
||||
`[Docusaurus-PWA][registerSw]: unregister() service worker registration`,
|
||||
|
@ -69,7 +69,7 @@ async function isAppInstalledEventFired() {
|
|||
declare global {
|
||||
interface Navigator {
|
||||
getInstalledRelatedApps: () => Promise<{platform: string}[]>;
|
||||
connection: {effectiveType: string; saveData: boolean};
|
||||
connection?: {effectiveType: string; saveData: boolean};
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue