mirror of
https://github.com/facebook/docusaurus.git
synced 2025-08-02 08:19:07 +02:00
refactor: fix a few type inconsistencies (#5788)
This commit is contained in:
parent
075234851c
commit
72990726e5
11 changed files with 28 additions and 20 deletions
|
@ -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",
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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"`,
|
||||
|
|
4
packages/docusaurus/src/types.d.ts
vendored
4
packages/docusaurus/src/types.d.ts
vendored
|
@ -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';
|
||||
|
||||
|
|
|
@ -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),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue