[英]typescript error when I tried to destructuring an object
I made a react app with create-react-app typescript template.我使用 create-react-app typescript 模板制作了一个反应应用程序。 I made a simple card component, and I tried to destructuring an object but i have the following error: enter image description here我制作了一个简单的卡片组件,并尝试解构 object 但出现以下错误:在此处输入图像描述
this is my tsconfig file这是我的 tsconfig 文件
{ "compilerOptions": { "target":"ES2020", "lib": [ "dom", "dom.iterable", "esnext" ], "allowJs": true, "skipLibCheck": true, "esModuleInterop": true, "allowSyntheticDefaultImports": true, "strict": true, "forceConsistentCasingInFileNames": true, "noFallthroughCasesInSwitch": true, "module":"ES2020", "moduleResolution": "node", "resolveJsonModule": true, "isolatedModules": true, "noEmit": true, "jsx": "react-jsx" }, "include": [ "src" ], "exclude": ["node_modules"] }
default
is a reserved keyword used in switch statements. default
是 switch 语句中使用的保留关键字。 Any other name will be fine.任何其他名称都可以。
interface CardProps {
default: 'test';
defaults: 'test';
}
declare const props: CardProps;
const { default } = props; // KO
const { defaults } = props; // OK
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.