Reactjs 使用类generictype生成错误响应createContext
我是一名初级前端工程师,我试图创建Context名称StoreContext,它具有初始参数 类型为“类”。这是我的密码 (我使用npx创建下一个应用程序设置我的项目) B.法律改革委员会Reactjs 使用类generictype生成错误响应createContext,reactjs,typescript,Reactjs,Typescript,我是一名初级前端工程师,我试图创建Context名称StoreContext,它具有初始参数 类型为“类”。这是我的密码 (我使用npx创建下一个应用程序设置我的项目) B.法律改革委员会 { "plugins": ["@babel/plugin-transform-destructuring"] } babel.config.js module.exports = { presets: ["@babel/preset-react","@babel/preset-env"]
{
"plugins": ["@babel/plugin-transform-destructuring"]
}
babel.config.js
module.exports = {
presets: ["@babel/preset-react","@babel/preset-env"],
plugins: [
['@babel/plugin-proposal-decorators', { legacy: true }],
["@babel/plugin-transform-destructuring",{"useBuiltIns":true}]
],
};
如何修复编译错误?
那个语法的名称是什么
{}作为托多利斯特
{}作为TodoList
a“cast”。用于告诉typescript推断的类型实际上有点不同。@谢谢,您能发布或链接任何示例吗?
{
"name": "mobx-sample",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start"
},
"dependencies": {
"@babel/core": "^7.7.7",
"@babel/plugin-proposal-decorators": "^7.7.4",
"@babel/plugin-transform-react-jsx": "^7.7.7",
"mobx": "^5.15.1",
"mobx-react-lite": "^1.5.2",
"next": "9.1.7",
"react": "16.12.0",
"react-dom": "16.12.0"
},
"devDependencies": {
"@babel/node": "^7.7.7",
"@babel/plugin-transform-destructuring": "^7.7.4",
"@babel/preset-env": "^7.7.7",
"@babel/preset-react": "^7.7.4",
"@types/node": "^13.1.4",
"@types/react": "^16.9.17",
"typescript": "^3.7.4"
}
}
{
"plugins": ["@babel/plugin-transform-destructuring"]
}
module.exports = {
presets: ["@babel/preset-react","@babel/preset-env"],
plugins: [
['@babel/plugin-proposal-decorators', { legacy: true }],
["@babel/plugin-transform-destructuring",{"useBuiltIns":true}]
],
};