简体   繁体   English

解析错误:意外的保留字“接口”。 eslint

[英]Parsing error: Unexpected reserved word 'interface'. eslint

I'm trying to use Props in my code and I'm getting the following error on (interface - "Parsing error: Unexpected reserved word 'interface'. (3:0)eslint").我正在尝试在我的代码中使用 Props,但在(接口 - “解析错误:意外的保留字'接口'。(3:0)eslint”)上出现以下错误。

I'm using next with TypeScript to develop this project.我正在使用 next 和 TypeScript 来开发这个项目。

error image错误图片

 import { TitleStyled, SubTitle } from "./Title.style"; interface TitleProps { titulo: String; subtitulo?: String | JSX.Element; } export default function Title(props: TitleProps) { return ( <> <TitleStyled>{props.titulo}</TitleStyled> <SubTitle>{props.subtitulo}</SubTitle> </> ); }

My package.json我的 package.json

 { "name": "pets", "version": "0.1.0", "private": true, "scripts": { "dev": "next dev", "build": "next build", "start": "next start", "lint": "next lint" }, "dependencies": { "@emotion/react": "^11.10.5", "@emotion/styled": "^11.10.5", "@mui/material": "^5.11.4", "@next/font": "13.1.1", "@types/node": "18.11.18", "@types/react": "18.0.26", "@types/react-dom": "18.0.10", "eslint": "8.31.0", "eslint-config-next": "13.1.1", "next": "13.1.1", "react": "18.2.0", "react-dom": "18.2.0", "typescript": "4.9.4" } }

My tsconfig.json我的tsconfig.json

 { "compilerOptions": { "target": "es5", "lib": ["dom", "dom.iterable", "esnext"], "allowJs": true, "skipLibCheck": true, "strict": true, "forceConsistentCasingInFileNames": true, "noEmit": true, "esModuleInterop": true, "module": "esnext", "moduleResolution": "node", "resolveJsonModule": true, "isolatedModules": true, "jsx": "preserve", "incremental": true }, "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"], "exclude": ["node_modules"] }

Have you tried renaming your file Title.tsx instead of Title.jsx ?您是否尝试过重命名文件Title.tsx而不是Title.jsx

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM