Skip to content

Cannot use JSX unless the '--jsx' flag is provided #1

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

Closed
taiga-programming opened this issue Dec 7, 2020 · 3 comments
Closed

Cannot use JSX unless the '--jsx' flag is provided #1

taiga-programming opened this issue Dec 7, 2020 · 3 comments

Comments

@taiga-programming
Copy link
Owner

taiga-programming commented Dec 7, 2020

I did yarn start and compiling was a success but a lot of problems have appeared

$ yarn start also npm run start
yarn run v1.22.4
$ react-scripts start

The following changes are being made to your tsconfig.json file:
  - compilerOptions.jsx must be react-jsx (to support the new JSX transform in React 17)

i 「wds」: Project is running at http://192.168.56.1/
i 「wds」: webpack output is served from
i 「wds」: Content not from webpack is served from C:\Users\taiga\Github\Typescript\eslint-app\example\public
i 「wds」: 404s will fallback to /
Starting the development server...
Compiled successfully!

You can now view example in the browser.

  Local:            http://localhost:3000
  On Your Network:  http://192.168.56.1:3000

Note that the development build is not optimized.
To create a production build, use npm run build.

error

  • Cannot use JSX unless the '--jsx' flag is provided

  • Module './App' was resolved to 'c:/Users/taiga/Github/Typescript/eslint-app/example/src/App.tsx', but '--jsx' is not set.

  • Argument for '--jsx' option must be: 'preserve', 'react-native', 'react'.

I try

I used

@taiga-programming
Copy link
Owner Author

taiga-programming commented Dec 8, 2020

my solution 1

.eslintrc.js

//deleted
  extends: [
    'standard',
  ],

//added 

 rules: {
    '@typescript-eslint/no-use-before-define': 'off',
    'no-use-before-define': 'off',
    '@typescript-eslint/no-unused-vars': 'off',
    'no-unused-vars': 'off',

   // I don't know this plugin had better set or not 
    // '@typescript-eslint/explicit-module-boundary-types': 'off',
    // 'explicit-module-boundary-types': 'off',
   
   //I add now
 ` eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types` in the each of tsx file .

@taiga-programming
Copy link
Owner Author

taiga-programming commented Dec 8, 2020

I tried at eslint

fail

  • 2021 version was not working. The newest version eslint on typescript is 2020

.eslintrc.js (i changed the place)

es2021:true→es2020: true
ecmaVersion: 2021→ecmaVersion: 2020

@taiga-programming
Copy link
Owner Author

taiga-programming commented Dec 8, 2020

Solution 2

situation

  • I did change .eslintrc and other stuff that's work but after I did restart yarn start that' causing the same problems have occurred.

How did I solve it?

  • I've gone to my visual studio and command ctrl + shift + p and then the typescript version was appeared and applied the version(my visual studio typescript version is 4.2.0) also (my typescript version 4.1.0 package.json )

I used

  • I solved the problem base on this article

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant