diff --git a/.changeset/angry-cups-hug.md b/.changeset/angry-cups-hug.md new file mode 100644 index 000000000..f56777b72 --- /dev/null +++ b/.changeset/angry-cups-hug.md @@ -0,0 +1,5 @@ +--- +'create-astro': patch +--- + +Fix typescript prompt handling diff --git a/packages/create-astro/src/index.ts b/packages/create-astro/src/index.ts index 5b4973a12..f1571398f 100644 --- a/packages/create-astro/src/index.ts +++ b/packages/create-astro/src/index.ts @@ -312,7 +312,7 @@ export async function main() { args.typescript = 'strict'; } - const tsResponse = + let tsResponse = args.typescript || ( await prompts( @@ -342,7 +342,7 @@ export async function main() { if (tsResponse === 'unsure') { await typescriptByDefault(); - tsResponse.typescript = 'base'; + tsResponse = 'base'; } if (args.dryRun) { ora().info(dim(`--dry-run enabled, skipping.`)); @@ -353,7 +353,7 @@ export async function main() { // If the template doesn't have a tsconfig.json, let's add one instead fs.writeFileSync( templateTSConfigPath, - stringify({ extends: `astro/tsconfigs/${tsResponse}` }, null, 2) + stringify({ extends: `astro/tsconfigs/${tsResponse ?? 'base'}` }, null, 2) ); return; @@ -363,7 +363,7 @@ export async function main() { if (templateTSConfig && typeof templateTSConfig === 'object') { const result = assign(templateTSConfig, { - extends: `astro/tsconfigs/${tsResponse.typescript}`, + extends: `astro/tsconfigs/${tsResponse ?? 'base'}`, }); fs.writeFileSync(templateTSConfigPath, stringify(result, null, 2));