From c69c364c9fc235a620bb9199160a6cfacce7a934 Mon Sep 17 00:00:00 2001 From: Nate Moore Date: Tue, 24 Jan 2023 11:01:26 -0600 Subject: [PATCH] fix(create-astro): typescript prompt handling (#5958) * fix(create-astro): typescript prompt handling * fallback * fix(create-astro): additional case Co-authored-by: Nate Moore --- .changeset/angry-cups-hug.md | 5 +++++ packages/create-astro/src/index.ts | 8 ++++---- 2 files changed, 9 insertions(+), 4 deletions(-) create mode 100644 .changeset/angry-cups-hug.md 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));