I'm using typescript.
An error occurs at the "as any" point.
I want to get rid of "any" and add a type, but if I change "any" to a string type, it will not work.
But it didn't work.
tsError
Unexpected any. Specify a different type.eslint@typescript-eslint/no-explicit-any
import React from 'react';
import FacebookIcon ...
import LinkedinIcon ...
import TwitterIcon ...
type Props = {
icon: 'facebook' | 'linkedin' | 'twitter';
fontSize?: string;
};
const iconMap = {
facebook: FacebookIcon,
linkedin: LinkedinIcon,
twitter: TwitterIcon
}
export const Icon = ({ icon, fontSize }: Props) => {
const CompName = iconMap[icon];
return (<CompName {...({ fontSize } as any)} />) as JSX.Element;};
<CompName style={{ fontSize }} />