next.js icon indicating copy to clipboard operation
next.js copied to clipboard

TypeScript Auto-Install

Open vicasas opened this issue 3 years ago • 4 comments
trafficstars

Verify canary release

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

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 21.6.0: Wed Aug 10 14:28:35 PDT 2022; root:xnu-8020.141.5~2/RELEASE_ARM64_T8101
Binaries:
  Node: 16.17.0
  npm: 8.15.0
  Yarn: 1.22.17
  pnpm: N/A
Relevant packages:
  next: 12.3.0
  eslint-config-next: 12.3.0
  react: 18.2.0
  react-dom: 18.2.0

What browser are you using? (if relevant)

Chrome Versión 105.0.5195.102 (Build oficial) (arm64)

How are you deploying your application? (if relevant)

next build & next start

Describe the Bug

Context

According to the latest release of Next.js at version 12.3.0, it has the feature to auto install typescript on the fly.

see: https://nextjs.org/blog/next-12-3#typescript-auto-install

When creating a new application with npm using npx create-next-app@latest when changing a file extension to .ts or .tsx the new feature does not work as expected.

This is because it only does some parts of what appears in the blog gif.

I understand that this should do the following:

  • [x] Create tsconfig.json
  • [ ] Install typescript
  • [x] Install @types/node
  • [x] Install @types/react
  • [x] Create file next-env.d

But the installation of typescript doesn't seem to be working.

UPDATE: From the VSCode terminal it does not install any packages.

Expected Behavior

I would expect the functionality to operate in the same way as it is shown in the 12.3.0 blog gif. That you can install typescript just the same.

  • Additionally I think @types/react-dom should be installed.

Link to reproduction

.

To Reproduce

  1. Create a new JavaScript project using npx create-next-app@latest --use-npm.
  2. Change the extension of some pages file from .js to .tsx. or from .jsx to .tsx,
  3. You will see that it is not installed as a typescript dependency.

vicasas avatar Sep 10 '22 16:09 vicasas

Hi, can you provide a complete reproduction, following the provided steps does not seem to reproduce the issue. Note if TypeScript isn't being installed it may already be present in your tree including globally installed.

ijjk avatar Sep 13 '22 00:09 ijjk

@ijjk Step to step:

  1. Create a new project using npx create-next-app@latest --use-npm
  2. Execute project using npm run dev
  3. Change extension name file from .js to .tsx

Sep-14-2022 23-26-09

vicasas avatar Sep 15 '22 02:09 vicasas

Auto-install works when renaming .jsx file to .tsx, but doesn't work when renaming .js file to .ts

Umbrien avatar Sep 15 '22 16:09 Umbrien

I just upgraded an app from NextJS 12.2.5 to 12.3, renamed _app.jsx to _app.tsx and it didn't install typescript automatically. All it did was install .tsconfig.json and next-env.d files.

danielvanc avatar Sep 19 '22 08:09 danielvanc

This issue has been automatically closed because it received no activity for a month and had no reproduction to investigate. If you think it was closed by accident, please leave a comment. If you are running into a similar issue, please open a new issue with a reproduction. Thank you.

balazsorban44 avatar Oct 20 '22 23:10 balazsorban44

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[bot] avatar Nov 20 '22 00:11 github-actions[bot]