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

CI=true create-next-app --ts sets up project using JS instead of TS #42592

Closed
1 task done
tmadeira opened this issue Nov 7, 2022 · 1 comment · Fixed by #42596
Closed
1 task done

CI=true create-next-app --ts sets up project using JS instead of TS #42592

tmadeira opened this issue Nov 7, 2022 · 1 comment · Fixed by #42596
Labels
create-next-app Related to our CLI tool for quickly starting a new Next.js application.

Comments

@tmadeira
Copy link

tmadeira commented Nov 7, 2022

Verify canary release

  • I verified that the issue exists in the latest Next.js canary release

Provide environment information

Operating System:
  Platform: linux
  Arch: x64
  Version: #1 SMP PREEMPT_DYNAMIC Thu, 03 Nov 2022 18:01:58 +0000
Binaries:
  Node: 14.21.0
  npm: 8.19.2
  Yarn: 1.22.19
  pnpm: N/A
Relevant packages:
  next: 13.0.2
  eslint-config-next: 13.0.2
  react: 18.2.0
  react-dom: 18.2.0

What browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

No response

Describe the Bug

Using npx create-next-app@latest --ts my-app does not work in continuous integration environments (i.e., if CI env var is set). The CLI simply ignores the --ts flag (https://github.com/vercel/next.js/blob/canary/packages/create-next-app/index.ts#L160).

Expected Behavior

Project should be bootstraped with TypeScript.

(It's okay to default to JavaScript to not break existing CI expecting JS, but if the command line argument --ts is given explicitly then create-next-app should install TypeScript packages and use TypeScript.)

Link to reproduction

CI=true npx create-next-app@latest --ts my-app

To Reproduce

  1. Run CI=true npx create-next-app@latest --ts my-app
  2. create-next-app should install TypeScript packages, but it doesn't.
@tmadeira tmadeira added the bug Issue was opened via the bug report template. label Nov 7, 2022
tmadeira referenced this issue Nov 7, 2022
…esting (#42012)

Resubmitting this PR following this comment from Tim. This work has been done already and we can build off of it to get this in faster. 

> Just to be clear we're planning to rework create-next-app to give you the option to choose between JavaScript or TypeScript so it'll solve this request. For `app` right now it'll stay TypeScript till that is implemented.
> 
> _Originally posted by @timneutkens in #41745 (reply in thread)

---

I added the `--ts, --typescript` flag to `create-next-app` in #24655, and since then I have seen it used very frequently, including in recent issues (such as #33314) and most Next.js tutorials on YouTube. I noticed the template logic added in this PR was also used to add the `appDir` configuration as well.

We discussed a while ago adding the following user flow:

- `create-next-app --js, --javascript` creates a JS project
- `create-next-app --ts, --typescript` creates a TS project
- `create-next-app [name]` (no `--js, --ts`) prompts the user to choose either JS or TS, with TS selected by default.

### Review

Adding support for appDir and refactoring the templates brought the pain-of-review up a bit, but it's not so bad when broken into increments.

The original 8-file diff is here:
ctjlewis@1f47d9b

And the PR that brought the diff up to 59 files (mostly owed to `app` template dirs and file structure refactors):
ctjlewis@bd3ae4a ([PR link](https://github.com/ctjlewis/next.js/pull/3/files))

### Demo

https://user-images.githubusercontent.com/1657236/198586216-4691ff4c-48d4-4c6c-b7c1-705c38dd0194.mov


Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
@tmadeira tmadeira changed the title CI=true create-next-app --ts foo sets up project using JS instead of TS CI=true create-next-app --ts sets up project using JS instead of TS Nov 7, 2022
@balazsorban44 balazsorban44 added create-next-app Related to our CLI tool for quickly starting a new Next.js application. kind: bug and removed bug Issue was opened via the bug report template. labels Nov 7, 2022
ijjk added a commit that referenced this issue Nov 7, 2022
Fixes: #42592

## Bug

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Errors have a helpful link attached, see `contributing.md`
@github-actions
Copy link
Contributor

github-actions bot commented Dec 8, 2022

This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 8, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
create-next-app Related to our CLI tool for quickly starting a new Next.js application.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants