Gatsby minimal TS starter generates code with deprecated React import #38869
Labels
status: triage needed
Issue or pull request that need to be triaged and assigned to a reviewer
type: bug
An issue or pull request relating to a bug in Gatsby
Preliminary Checks
Description
Hello 🙂
Testing Gatsby today, I immediately got stumped when I opened
src/pages/index.tsx
on account of the React import there.Direct React imports have been obsolete since the new jsx transform arrived in 2020. The namespace import style in
src/pages/index.tsx
has been deprecated even before that.Connected to those imports is the jsx setting for TypeScript, which should now be
"react-jsx"
.While this is easily fixed on my end, this should not be yielded from your starters.
Apart from just being old stuff, this encourages a code style that makes reading the code more onerous.
I will look into providing PRs to fix, if and when I decide to go further with Gatsby.
Reproduction Link
https://stackblitz.com/github/gatsbyjs/gatsby-starter-minimal-ts?file=src%2Fpages%2Findex.tsx
Steps to Reproduce
npm init gatsby bug -- -y -ts
bug/tsconfig.json
andbug/src/pages/index.tsx
in an editorExpected Result
index.tsx
should have neither animport * as React from "react"
nor animport React from "react"
, both of which are deprecated and obsolete.Also, there should be no issues when removing such an obsolete import.
tsconfig.json
should havecompilerOptions.jsx
set to"react-jsx"
.Actual Result
index.tsx
starts withimport * as React from "react"
, and when removing this line, TypeScript raises this error for all JSX tags:Environment
Config Flags
No response
The text was updated successfully, but these errors were encountered: