Advanced Typescript

Поделиться
HTML-код
  • Опубликовано: 25 окт 2024

Комментарии • 5

  • @akshayashok391
    @akshayashok391 2 года назад +1

    Thanks Santosh and Anurag for these awesome content, was completely hooked till the end 😄

  • @rohitchopra8389
    @rohitchopra8389 3 года назад +1

    hey guys you nailed typescript today. extremely good content

  • @anuraghazra4772
    @anuraghazra4772 3 года назад +3

    24:14 To those who got confused, so what basically happened here is that I did not set the generic `Props` to the argument of the useAccordionCondi instead I directly put the `AccordionProps` in the argument.
    Wrong Code:
    export function useAccordionCondi(
    props: AccordionProps // wrong!
    ) {
    return (
    props.allowMultiple === true
    ? { allowMultiple: true, returns: ["string"] }
    : { allowMultiple: false, returns: "string" }
    ) as Value;
    }
    Good Code:
    export function useAccordionCondi(props: T /* passing T in here */) {
    return (
    props.allowMultiple === true
    ? { allowMultiple: true, returns: ["string"] }
    : { allowMultiple: false, returns: "string" }
    ) as Value;
    }