Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Rock-Solid Components with TypeScript and GraphQL

Mat Warger
January 11, 2019

Rock-Solid Components with TypeScript and GraphQL

Most recent javascript frameworks bring a solid component model to modern web development, but how can you guarantee that your components work correctly? In this session, you learn how the features of Typescript can be leveraged to bring clarity and dependability when constructing components with React. Using Typescript can help to catch errors early in the development life-cycle. GraphQL and its type system can ensure confidence in your components while fetching remote data. This comprehensive approach ensures that your components behave as you expect, and allows you to eliminate run-time errors. Learn how using types can keep your users happy!

Mat Warger

January 11, 2019
Tweet

Other Decks in Technology

Transcript

  1. CCTATTCACTATTGGAGCATTCCGTTCGAGCATGGCAGTAAGTACGCCTTCTCCAT TCTGGTAACCTTCATCCCTATCAGAGCTTGGAGCCAATGATCAGGGTTATTCCCTT GGGACAGACTTCCTACTCACAGenum variants = “condensed” | “outline“ ACTCCATGGGTCTTCGGCTTGACCGTGAGTTTCGGCCCCGCGCTGC TGTATAGTCGATTCTCATCCGGCCCTCACATCTGGAAACCCCAACTTATTTAGATA

    ACATCATTAGCCGAAGTTGCTGGGCATGTCCACCGTGGAGTCCTCCCCGGGCGTCC CTCCTTCAAATGACGATAAGCACCGGCAAGCACCATTGATCAACGCAAGGATCGGT GATGTTAACAAAGATTCGGCACATTACTCTTGTTGGTGTGGAATCGCTTAACTACG CGGCGAAGCCTTATGGCAAAACCGATGGGGAATGATTCGGGTAGCGCTAAAAGTCC ATAGCACGTACATCCCAACCTGGCGTGCGTAC export interface Button Props extends StandardProps <ButtonBaseProps, ButtonClas sKey,'component’> CTAAATTAATGGAGCACTACGGAGCACTTCTCAAAGTC CTGCTCTAAGGACAATTACGGAGTGGGCGGCCTGGCGGGAGCACTACCCCATCGAC GCGTACTCGAATACTGTATATTGCTCTCACATGAACAAATTAGTAGAGTGCCGCTT TCAGCCCCCCTGTCGTCGGCGACGTCTGTAAAATGGCGTTGATGTGGATCGACTCT ATAGAGGCATCTACTGATGCGTAGGGAGATCCGGAATGTATTTATTTATT type
  2. type HasRenderProp<T> = T extends { render: (props: any) =>

    React.ReactNode } ? T : never; type HasChildrenProp<T> = T extends { children: (props: any) => React.ReactNode } ? T : never; type IsFunction<T> = T extends (...args: any[]) => any ? T : never; export const hasRender = <T extends {}>(value: T): value is HasRenderProp<T> => 'render' in value && isFunction((value as HasRenderProp<T>).render); export const hasChildren = <T extends {}>(value: T): value is HasChildrenProp<T> => 'children' in value && isFunction((value as HasChildrenProp<T>).children); const isFunction = <T extends {}>(value: T): value is IsFunction<T> => typeof value === 'function';