From 6e7184d98db8b9eca156dcc068504be472f1dbbb Mon Sep 17 00:00:00 2001 From: Aaron Klinker Date: Tue, 11 Jul 2023 09:42:08 -0500 Subject: [PATCH] fix: Generate valid type for `EntrypointPath` when there are no entrypoints --- src/core/build/generateTypesDir.ts | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/core/build/generateTypesDir.ts b/src/core/build/generateTypesDir.ts index 5e82d077..98c5a72e 100644 --- a/src/core/build/generateTypesDir.ts +++ b/src/core/build/generateTypesDir.ts @@ -48,22 +48,23 @@ async function writePathsDeclarationFile( config: InternalConfig, ): Promise { const filePath = resolve(config.typesDir, 'paths.d.ts'); + const unions = entrypoints + .map((entry) => { + const path = getEntrypointBundlePath( + entry, + config.outDir, + entry.inputPath.endsWith('.html') ? '.html' : '.js', + ); + return ` | "/${path}"`; + }) + .sort(); await fs.writeFile( filePath, [ '// Generated by wxt', 'type EntrypointPath =', - ...entrypoints - .map((entry) => { - const path = getEntrypointBundlePath( - entry, - config.outDir, - entry.inputPath.endsWith('.html') ? '.html' : '.js', - ); - return ` | "/${path}"`; - }) - .sort(), + ...(unions.length === 0 ? [' never'] : unions), ].join('\n') + '\n', );