타입스크립트로 컴파일을 하다가, styled css 쪽에서 에러가 났습니다.

Item은 EffectedItem을 상속받고 있는데,
export const Item = styled(EffectedItem)`
  text-align: center;
`;
EffectedItem의 props의 타입이 export 되지 않아 생긴 에러였습니다.
import { useTheme } from "@emotion/react";
import { forwardRef, useCallback } from "react";
import {
  ListItemDefaultProps,
  ListItemForwardedRef,
} from "../../../types/props";
import { rippleEffect } from "../../../utilities/css";
import { ItemBase } from "../../base/ItemBase";
interface EffectedItemProps extends ListItemDefaultProps {
  active: boolean;
}
const EffectedItem = forwardRef(
  (props: EffectedItemProps, forwardedRef: ListItemForwardedRef) => {
    const theme = useTheme();
    const { onClick = () => {} } = props;
    const handleClick = useCallback(
      (event: any) => {
        rippleEffect(event, theme, true);
        onClick(event);
      },
      [onClick]
    );
    return <ItemBase {...props} ref={forwardedRef} onClick={handleClick} />;
  }
);
export default EffectedItem;
export를 붙여주면 에러가 사라집니다.
export interface EffectedItemProps extends ListItemDefaultProps {
  active: boolean;
}
참고 https://github.com/styled-components/styled-components/issues/1063
Typescript 2.4 Error: Variable StyledComponentClass from external module cannot be named. · Issue #1063 · styled-components/st
Version 2.1.1 Typescript: 2.4.2 Reproduction Given a styled-component src/wrapper.tsx import * as React from 'react'; import styled from 'styled-components'; const Wrapper = styled....
github.com
'웹 > 프론트엔드' 카테고리의 다른 글
| [Typescript] 유니온 타입 사용 시 타입 증명하기 (0) | 2022.11.23 | 
|---|---|
| [React/Typescript] 라이브러리없이 웹 캐싱 기능 구현하기 (0) | 2022.10.05 | 
| [S3] AWS S3 fetch시 cors문제 해결 (0) | 2022.09.20 | 
| [Next.js] Next.js에서 Toast UI Editor 사용하기 (0) | 2022.09.20 | 
| [React] Material UI의 TextField 만들어보기 (0) | 2022.09.04 | 
 
										
									 
										
									 
										
									
댓글