简体   繁体   English

typescript 错误不允许作为变量声明名称.ts

[英]typescript error is not allowed as a variable declaration name.ts

I am using next.js, react, and typescript.我正在使用 next.js、反应和 typescript。
When I use switch as a variable name, I get a typescript error.当我使用 switch 作为变量名时,出现 typescript 错误。
How can I avoid the error?我怎样才能避免错误?

'switch' is not allowed as a variable declaration name.ts(1389)
const Template: Story = (args: AtomSwitchProps) => <Switch {...args} />;

export const switch = Template.bind({});
switch.args = {
};

You can't use a keyword as an identifier in your JavaScript programs.您不能在 JavaScript 程序中使用关键字作为标识符。 Switch is a Reserved keyword . Switch 是一个Reserved keyword Reserved keywords are used to perform internal operations.保留关键字用于执行内部操作。 Here's a list of keywords of JavaScript. 是JavaScript的关键字列表。

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

相关问题 打字稿错误:环境模块声明只允许在文件的顶层 - Typescript Error: An ambient module declaration is only allowed at the top level in a file 错误TS7016:找不到模块“”的声明文件。 &#39;&#39;隐含一个&#39;any&#39;类型。 TypeScript 2.0 - error TS7016: Could not find a declaration file for module ''. '' implicitly has an 'any' type. TypeScript 2.0 获取:错误 TS1128:预期的声明或语句。 在 ReactJS 和 TypeScript 应用程序中 - Getting: error TS1128: Declaration or statement expected. In ReactJS & TypeScript app Typescript:是否可以从声明文件和.js文件生成ts文件? - Typescript: is it possible to generate a ts file from declaration file and .js file? 下一个 Js Typescript 出现错误 TS2304:找不到名称“AppProps” - Next Js Typescript getting error TS2304: Cannot find name 'AppProps' React/Typescript - 语义错误 TS2304:找不到名称“片段” - React/Typescript - semantic error TS2304: Cannot find name 'Fragment' Typescript自定义类型声明出错 - Error with Typescript custom type declaration 从 js 转换为 ts 时出现 typescript 错误 - typescript error while coverting from js to ts React TypeScript:使用 useReducer 时出现 TS 错误 - React TypeScript: TS Error when using useReducer 打字稿错误:TS2604 - 如何修复? - Typescript Error: TS2604 - How to fix?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM