sLeeNguyen/react-flip-clock-countdown

className in typescript

Kublick opened this issue · 5 comments

Seems className property its not defined, thus giving an error when used on the function.

Type '{ className: string; to: Date; digitBlockStyle: { fontSize: number; fontFamily: string; }; showLabels: false; showSeparators: true; }' is not assignable to type 'IntrinsicAttributes & Pick<FlipClockCountdownProps, "to" | "containerProps" | "labelStyle" | "digitBlockStyle" | "separatorStyle" | "dividerStyle" | "duration"> & InexactPartial<...> & InexactPartial<...>'.
Property 'className' does not exist on type 'IntrinsicAttributes & Pick<FlipClockCountdownProps, "to" | "containerProps" | "labelStyle" | "digitBlockStyle" | "separatorStyle" | "dividerStyle" | "duration"> & InexactPartial<...> & InexactPartial<...>'.

Adding the prop to FlipClockCountdown would fix the issue

@Kublick FlipClockCountdownProps extends properties from React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement> so that the className prop should have in FlipClockCountdown. I think the problem might come from your react version, it should be >= 16.13.0

Can you show me the code you are using FlipClockCountdown and get that error?

The problem comes from typescript compiler, try to add this to your tsconfig.json

"compilerOptions": {
    "esModuleInterop": true,
    "allowSyntheticDefaultImports": true
  }

Ref: https://stackoverflow.com/questions/60551025/how-can-i-get-rid-of-my-types-react-index-can-only-be-default-imported-using