astro
astro copied to clipboard
`create-astro`: always create `tsconfig.json`
Changes
Alway write chosen config to tsconfig.json
.
- Before: Only when
strict
orstrictest
was selected - After: Also when
base
is 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 defaultbase
tsconfig.json
, which is the case for all 23 official templates, but not necessarily for third-party templates. -
If
strict
orstrictest
: A) Make suretsconfig.json
exists (create if missing). B) Write chosenextends
totsconfig.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.