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

create astro --no => typescript == strict, instead of "no" #11609

Open
1 task done
ppo opened this issue Aug 3, 2024 · 4 comments · May be fixed by #12083
Open
1 task done

create astro --no => typescript == strict, instead of "no" #11609

ppo opened this issue Aug 3, 2024 · 4 comments · May be fixed by #12083
Labels
needs discussion Issue needs to be discussed pkg: create-astro Related to the `create-astro` package (scope)

Comments

@ppo
Copy link

ppo commented Aug 3, 2024

Astro Info

create-astro v4.8.1

If this issue only occurs in one browser, which browser is a problem?

No response

Describe the Bug

pnpm create astro@latest foo -- --template minimal --install --git --no --skip-houston

As there is a flag for everything except "no typescript" 🙄, I tried that command with --no expecting it would answer "no" to the only remaining question "Do you plan to write TypeScript?"… but it's not the case, instead it uses --typescript strict.

What's the expected result?

Like the doc says --no (-n) Skip all prompts by declining defaults.
There's a question "Do you plan to write TypeScript? Y/n", so declining the default should result in "no".

PS: But I would expect create-astro to have a flag --no-typescript (like for the other similar flags).

Link to Minimal Reproducible Example

https://example.com/not-applicable

Participation

  • I am willing to submit a pull request for this issue.
@github-actions github-actions bot added the needs triage Issue needs to be triaged label Aug 3, 2024
@bluwy
Copy link
Member

bluwy commented Aug 4, 2024

I think supporting --no-typescript and --no to also disable typescript makes sense to me. I don't know if there's a previous reasoning behing strict as default in this case though. The default is set at

if (no) {
yes = false;
if (install == undefined) install = false;
if (git == undefined) git = false;
if (typescript == undefined) typescript = 'strict';
}

@bluwy bluwy added - P2: nice to have Not breaking anything but nice to have (priority) and removed needs triage Issue needs to be triaged labels Aug 4, 2024
@Fryuni
Copy link
Member

Fryuni commented Aug 4, 2024

PS: But I would expect create-astro to have a flag --no-typescript (like for the other similar flags).

Astro always uses TypeScript. No matter what you chose your code will be processed using a TS compiler.

Answering "no" to the "Do you plan to write TypeScript?" question doesn't mean "disable TypeScript". It causes the generated project to not use the strictest TS config, which outright forbids plain JS files. It will still run TS but allow untyped JS files in the project.

Now, if you plan to write TypeScript and want it to be more forgiving than the default settings, you can choose the relaxed TS config preset. If you are only writing JS files, those two (strict and relaxed) do the same thing, so the current behavior is just fine. If you are also writing TS files and want them relaxed, then the answer to "Do you plan to write TypeScript?" is not "no" is it? You see the option to set TS to relaxed only if you intend to use TS in the first place.

@bluwy bluwy added needs discussion Issue needs to be discussed and removed - P2: nice to have Not breaking anything but nice to have (priority) labels Aug 4, 2024
@ppo
Copy link
Author

ppo commented Aug 4, 2024

Thanks @Fryuni. That explains why there's still a tsconfig.json with "base" 😁
I guess things got mixed up in my mind when I saw that some projects were ditching TS and I don't remember if Astro actually did or if it's just me who decided to create Astro projects without TS and therefore was expecting a JS project template.

While on that topic. If Astro uses TS anyway, if we use relaxed, what's the best practice for the files we create? Always use .ts? Or does it make sense to use .js and .mjs?

@vrabe
Copy link

vrabe commented Aug 29, 2024

I think it's .astro files interpreted as typescript. There will be errors for js-styled .astro files if type check enabled.

@florian-lefebvre florian-lefebvre added the pkg: create-astro Related to the `create-astro` package (scope) label Sep 28, 2024
@florian-lefebvre florian-lefebvre linked a pull request Sep 28, 2024 that will close this issue
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs discussion Issue needs to be discussed pkg: create-astro Related to the `create-astro` package (scope)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants