refactor: fix a few type inconsistencies (#5788)

This commit is contained in:
Joshua Chen 2021-10-27 17:53:08 +08:00 committed by GitHub
parent 075234851c
commit 72990726e5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 28 additions and 20 deletions

View file

@ -35,7 +35,7 @@
"@types/copy-webpack-plugin": "^8.0.1",
"@types/css-minimizer-webpack-plugin": "^3.0.2",
"@types/detect-port": "^1.3.0",
"@types/mini-css-extract-plugin": "^2.3.0",
"@types/mini-css-extract-plugin": "^1.4.3",
"@types/module-alias": "^2.0.1",
"@types/nprogress": "^0.2.0",
"@types/react-dom": "^17.0.9",

View file

@ -87,8 +87,7 @@ export default async function choosePort(
host: string,
defaultPort: number,
): Promise<number | null> {
// @ts-expect-error: bad lib typedef?
return detect(defaultPort, host).then(
return detect({port: defaultPort, hostname: host}).then(
(port) =>
new Promise((resolve) => {
if (port === defaultPort) {

View file

@ -23,6 +23,7 @@ describe('translate', () => {
});
test('reject when no id or message', () => {
// TODO tests are not resolving type defs correctly
// @ts-expect-error: TS should protect when both id/message are missing
expect(() => translate({})).toThrowErrorMatchingInlineSnapshot(
`"Docusaurus translation declarations must have at least a translation id or a default translation message"`,

View file

@ -9,7 +9,9 @@ declare module 'remark-admonitions';
declare module 'react-loadable-ssr-addon-v5-slorber';
declare module 'resolve-pathname';
declare module 'resolve-pathname' {
export default function resolvePathname(to: string, from?: string): string;
}
declare module '@slorber/static-site-generator-webpack-plugin';

View file

@ -10,7 +10,6 @@ import {
mergeWithCustomize,
customizeArray,
customizeObject,
CustomizeRule,
} from 'webpack-merge';
import webpack, {
Configuration,
@ -224,8 +223,7 @@ export function applyConfigureWebpack(
content,
);
if (res && typeof res === 'object') {
// @ts-expect-error: annoying error due to enums: https://github.com/survivejs/webpack-merge/issues/179
const customizeRules: Record<string, CustomizeRule> = mergeStrategy ?? {};
const customizeRules = mergeStrategy ?? {};
return mergeWithCustomize({
customizeArray: customizeArray(customizeRules),
customizeObject: customizeObject(customizeRules),