You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import{FunctionComponent,useMemo}from'react'exportinterfaceButtonProps{size?: 'sm'|'base'|'lg'}exportconstButton: FunctionComponent<ButtonProps>=props=>{props.size??='base'constsizeClassNames=useMemo(()=>{return{sm: 'px-3 py-2 text-sm',base: 'px-4 py-2 text-sm',lg: 'px-4 py-2 text-base'}[props.size]// << Type 'undefined' cannot be used as an index type.(2538)},[props.size])return(<buttontype="button"className={sizeClassNames}>Buttontext</button>)}
π Actual behavior
Type 'undefined' cannot be used as an index type.(2538)
π Expected behavior
props.size should not be considered as undefined
The text was updated successfully, but these errors were encountered:
Bug Report
Previous discussion #37255 (comment)
Title is borrowed from @danielrentz #37255 (comment) I don't know if its accurate description of the problem.
π Search Terms
None
π Version & Regression Information
Any
β― Playground Link
Playground
π» Code
π Actual behavior
Type 'undefined' cannot be used as an index type.(2538)
π Expected behavior
props.size
should not be considered asundefined
The text was updated successfully, but these errors were encountered: