diff --git a/packages/create-docusaurus/package.json b/packages/create-docusaurus/package.json index afc064496409..f271ce1bf460 100755 --- a/packages/create-docusaurus/package.json +++ b/packages/create-docusaurus/package.json @@ -31,6 +31,7 @@ "tslib": "^2.6.0" }, "devDependencies": { + "@types/cross-spawn": "^6.0.6", "@types/supports-color": "^10.0.0" }, "engines": { diff --git a/packages/create-docusaurus/src/utils.ts b/packages/create-docusaurus/src/utils.ts index a98402cf163b..33164479ff80 100644 --- a/packages/create-docusaurus/src/utils.ts +++ b/packages/create-docusaurus/src/utils.ts @@ -5,14 +5,15 @@ * LICENSE file in the root directory of this source tree. */ -// @ts-expect-error: no types, but same as spawn() -import CrossSpawn from 'cross-spawn'; -import type {spawn, SpawnOptions} from 'node:child_process'; +import crossSpawn from 'cross-spawn'; + +// This is the same as node's child_process.SpawnOptions type, but extract from +// cross-spawn directly to ensure direct compatibility. +type SpawnOptions = NonNullable[2]>; // We use cross-spawn instead of spawn because of Windows compatibility issues. // For example, "yarn" doesn't work on Windows, it requires "yarn.cmd" // Tools like execa() use cross-spawn under the hood, and "resolve" the command -const crossSpawn: typeof spawn = CrossSpawn; /** * Run a command, similar to execa(cmd,args) but simpler diff --git a/yarn.lock b/yarn.lock index 29b8e8fd2c88..8260f9cc7755 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4617,6 +4617,13 @@ dependencies: "@types/node" "*" +"@types/cross-spawn@^6.0.6": + version "6.0.6" + resolved "https://registry.yarnpkg.com/@types/cross-spawn/-/cross-spawn-6.0.6.tgz#0163d0b79a6f85409e0decb8dcca17147f81fd22" + integrity sha512-fXRhhUkG4H3TQk5dBhQ7m/JDdSNHKwR2BBia62lhwEIq9xGiQKLxd6LymNhn47SjXhsUEPmxi+PKw2OkW4LLjA== + dependencies: + "@types/node" "*" + "@types/d3-array@*": version "3.2.1" resolved "https://registry.yarnpkg.com/@types/d3-array/-/d3-array-3.2.1.tgz#1f6658e3d2006c4fceac53fde464166859f8b8c5"