next.js 类型脚本错误:意外的标记'' div,应为jsx标识符

unftdfkk  于 2023-01-25  发布在  其他
关注(0)|答案(2)|浏览(543)

我正在建立一个基于nextjs-typescript和tailwindcss的网站
我遇到了这个奇怪的错误Expression expected

我在候机厅也收到了这个:

Unexpected token `div`. Expected jsx identifier
  const UseCases = () => {
  7 |   return (
  8 |     <div className="relative z-10 bg-gray-100 py-20">
    :      ^^^
  9 |       <FadeIntoView>

这是我的密码

import dataUseCases from "../../data/cases.data"
import FadeIntoView from "../../utils/gsap/fadeIntoView"

import Cases from "./useCases"

const UseCases = () => {
  return (
    <div className="relative z-10 bg-gray-100 py-20">
      <FadeIntoView>
        <h2 className="xs:text-8xl text-22vw fill-color pb-7 text-right font-black">Case</h2>
        <div>
          {dataUseCases.map((case, index) => (<Cases key={case.title + "-" + index} index={index + 1}  />))}
        </div>
      </FadeIntoView>
    </div>
  )
}

export default UseCases

文件名为index.tsx,位于src/components/useCase
配置:

{
  "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,
    "plugins": [
      {
        "name": "next"
      }
    ],
    "baseUrl": ".",
    "paths": {
      "@/*": ["./src/*"]
    }
  },
  "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
  "exclude": ["node_modules"]
}

我尝试了一些建议
swc#issue-2237stack-overflow
但他们好像都不在这儿工作

cu6pst1q

cu6pst1q1#

case是javascript中保留关键字将Map中的变量更改为其他值

iezvtpos

iezvtpos2#

中断字节大小写捕获char类 * const continue调试器默认值delete do double else枚举 * eval导出 * extends* false final函数的finally浮点数后藤if implements import* in instanceof int接口let* long本机新空包私有受保护公共返回short static super* 开关synchronized此抛出抛出瞬时真try类型var无效抽象参数wait * boolean volatile while with yield
所有这些keywords都是javaScript中保留的,您不能将它们用作变量、标签或函数名

相关问题