Typescript starter template doesn't include required commands #7031
Labels
- P2: nice to have
Not breaking anything but nice to have (priority)
pkg: create-astro
Related to the `create-astro` package (scope)
What version of
astro
are you using?2.4.1
Are you using an SSR adapter? If so, which one?
None
What package manager are you using?
npm
What operating system are you using?
Mac
What browser are you using?
None
Describe the Bug
I encountered a lot of difficulty using the TypeScript starter template with Astro, so I wanted to file this bug to document some of the things that would make the DX much cleaner (also, for anyone else who wonders why the default TypeScript template for Astro doesn't actually include type checking).
I created a project using
npm create astro@latest -- --skip-houston --typescript strictest
. I see a message saying "TypeScript customized" in the output, and the program has created my site, which builds cleanly. I open Card.astro and change every instance of "body" to "content".As documented, "the Astro dev server won’t perform any type checking", so the dev server shows 4 empty cards (on the index page) with no errors in the terminal or browser console. Strangely,
npm run build
also cleanly finishes, resulting in a broken site.It turns out that the starter template doesn't seem to fully set up TypeScript, and there are at least 2 steps that need to be manually performed, both documented on the same page. First, we need to install and configure
@astrojs/ts-plugin
(it says you need to do this "if you are not using VSCode", which I can only assume also means "if you are a CI environment", but it isn't totally clear). Then, much further down on the same page there is an additional note that we need to replace our build script withastro check && tsc --noEmit && astro build
. After doing these, the script successfully reports the errors that we introduced.I'm listing this as a bug because I think these are pretty much required for anyone interested in using TypeScript with Astro, and the setup script, despite advertising that it has configured TypeScript, did not perform these required steps. Separately from this, I also wasn't able to find anything about improving the DX here, like showing the errors in "astro dev" somehow, although I assume this is on the roadmap.
Link to Minimal Reproducible Example
https://github.com/withastro/astro/blob/50bf66e4df8ac9b427e653a48cb8e4e84913d8f2/examples/basics/
Participation
The text was updated successfully, but these errors were encountered: