`create-astro`: always create `tsconfig.json`
Changes
Alway write chosen config to tsconfig.json.
- Before: Only when
strictorstrictestwas selected - After: Also when
baseis selected (via "Relaxed" or "I prefer not to use TypeScript")
Testing
Added new typescript-step.test.js test file to test existing and new behavior related to the typescript prompt / --typescript CLI argument).
Docs
Existing create-astro docs don't mention tsconfig.json, so no changes are needed.
Motivation
Before this PR:
-
If
base: A) Do nothing: assumes a defaultbasetsconfig.json, which is the case for all 23 official templates, but not necessarily for third-party templates. -
If
strictorstrictest: A) Make suretsconfig.jsonexists (create if missing). B) Write chosenextendstotsconfig.json(e.g.{ "extends": "astro/tsconfigs/strict" }).
After this PR: base is treated the same as strict or strictest.
Template without tsconfig.json
The example command for installing a third-party template -- rather conveniently for the sake of this PR -- uses a template without a tsconfig.json file, and installing it (prior to the changes in this PR) with the base Typescript option results in no tsconfig.json file, rather than a tsconfig.json file containing { "extends": "astro/tsconfigs/base" } as would be expected.
Template with tsconfig.json not containing { "extends": "astro/tsconfigs/base" }
If a third-party template doesn't use the base config, installing it (prior to the changes in this PR) with the base Typescript option results in no changes to tsconfig.json, rather than setting extends to astro/tsconfigs/base as would be expected.