aahhuhuhu
aahhuhuhu

Reputation: 493

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

I am using next.js , react, and typescript.
When I use switch as a variable name, I get a typescript error.
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 = {
};

Upvotes: 3

Views: 6530

Answers (1)

Deepak
Deepak

Reputation: 2742

You can't use a keyword as an identifier in your JavaScript programs. Switch is a Reserved keyword. Reserved keywords are used to perform internal operations. Here's a list of keywords of JavaScript.

Upvotes: 4

Related Questions