admin管理员组文章数量:1391943
i'm occuring that problem:
Line 9:38: Parsing error: Unexpected token, expected "," prettier/prettier
in index.tsx file.
import React, { StrictMode } from 'react';
import { createRoot } from 'react-dom/client';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import reportWebVitals from './reportWebVitals';
const rootElement = document.getElementById('root');
const root = createRoot(rootElement as Element);
root.render(
<React.StrictMode>
<App />
</React.StrictMode>
);
reportWebVitals();
I can't find fix on the internet, anyone know how to fix that?
i'm occuring that problem:
Line 9:38: Parsing error: Unexpected token, expected "," prettier/prettier
in index.tsx file.
import React, { StrictMode } from 'react';
import { createRoot } from 'react-dom/client';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import reportWebVitals from './reportWebVitals';
const rootElement = document.getElementById('root');
const root = createRoot(rootElement as Element);
root.render(
<React.StrictMode>
<App />
</React.StrictMode>
);
reportWebVitals();
I can't find fix on the internet, anyone know how to fix that?
Share Improve this question edited Jul 14, 2022 at 17:37 xFlame asked Jul 14, 2022 at 17:34 xFlamexFlame 1551 gold badge3 silver badges10 bronze badges 6- Have you configured eslint & prettier in your project? – Pratik Wadekar Commented Jul 14, 2022 at 17:38
- @PatikWadekar yes, here's my configuration on Github: github./xflameyoke/interactive-ment-section-app/blob/main/… – xFlame Commented Jul 14, 2022 at 17:40
-
I think you need to check this configuration
prettier/prettier
in your eslintrc – Pratik Wadekar Commented Jul 14, 2022 at 17:48 -
Is this really necessary
const root = createRoot(rootElement as Element);
? Wouldn't sth likeconst root = createRoot(rootElement);
suffice? – user18821127 Commented Jul 14, 2022 at 18:29 - @user18821127 error after deleting 'as Element': Argument of type 'HTMLElement | null' is not assignable to parameter of type 'Element | DocumentFragment'. Type 'null' is not assignable to type 'Element | DocumentFragment'. – xFlame Commented Jul 14, 2022 at 18:49
1 Answer
Reset to default 5I found the issue by cloning into your repo. It is with "parser": "babel"
in eslint.rc prettier/prettier
.
Use "parser": "babel-ts"
or "parser": "typescript"
.
本文标签:
版权声明:本文标题:javascript - How to fix Parsing error: Unexpected token, expected "," in index.tsx? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744715908a2621400.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论