Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typescript starter template doesn't include required commands #7031

Closed
1 task
CGamesPlay opened this issue May 8, 2023 · 2 comments · Fixed by #8853
Closed
1 task

Typescript starter template doesn't include required commands #7031

CGamesPlay opened this issue May 8, 2023 · 2 comments · Fixed by #8853
Labels
- P2: nice to have Not breaking anything but nice to have (priority) pkg: create-astro Related to the `create-astro` package (scope)

Comments

@CGamesPlay
Copy link

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 with astro 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

  • I am willing to submit a pull request for this issue.
@Princesseuh
Copy link
Member

@astrojs/ts-plugin is a TypeScript plugin, those only run in the editor. So no, it is not required in CI.

Rest are valid points 😄

@Princesseuh Princesseuh added the - P2: nice to have Not breaking anything but nice to have (priority) label May 19, 2023
@natemoo-re natemoo-re added the pkg: create-astro Related to the `create-astro` package (scope) label Aug 16, 2023
@rishi-raj-jain
Copy link
Contributor

@Princesseuh @natemoo-re what is the required solution here? Happy to implement!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
- P2: nice to have Not breaking anything but nice to have (priority) pkg: create-astro Related to the `create-astro` package (scope)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants