我的 VS Code 中有一个设置,当
getServerSideProps
出现在代码中时,它会自动更改我的类型。它用通用类型替换了我的类型,然后破坏了文件中的所有类型检查。我必须在 vi 中编辑才能绕过 vs 代码覆盖。
const Account = ({user}: AccountProps)
当我保存文件时,它会自动更改为
const Account = ({user}: InferGetServerSidePropsType<typeof getServerSideProps>)
像这样:
我尝试禁用我安装的每个扩展,包括 ESLint、Prettier、各种 Snippets 扩展等。没有效果。我在整个用户首选项中搜索变体“getServerSideProps”,但没有找到任何东西。我没有 eslintrc.json,但这是我的 ts 配置:
{
"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,
"sourceMap": true,
"outDir": "dist",
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
"exclude": ["node_modules"]
}
什么是自动更正?
检查您是否安装了
Prisma NextJS
扩展。