Matt Pocock

Matt Pocock

Become a TypeScript wizard with tips, tricks and tutorials. Plus, updates from the latest TypeScript releases (and other open source awesomeness).

The TSConfig Cheat Sheet

The TSConfig Cheat Sheet

TypeScript 5.3 First Look

TypeScript 5.3 First Look

Will this code error?

Will this code error?

Learn tRPC in 5 minutes

Learn tRPC in 5 minutes

Пікірлер

  • @salaheddine.el-farissi
    @salaheddine.el-farissi20 сағат бұрын

    Thank you

  • @edgeeffect
    @edgeeffect2 күн бұрын

    I still haven't done enough TS to be much more than an "armchair theoretician" (typical KZread commenter) at this point... but, yeah, Phase 3 is best! ;)

  • @yeorinim2sida
    @yeorinim2sida2 күн бұрын

    Based on this video, I created code that specifically changes the return type. I have the following union type and wanted to narrow down the type of the returned array depending on whether it's 'title' or 'body'. export type IndexMap = | { type: 'title'; keyword: string; target: Title } | { type: 'body'; keyword: string; target: Body } Therefore, I defined the return type as follows: function searchAt<T extends IndexMap['type']>( content: string ): Extract<IndexMap, { type: T }>['target'][] { return [] } If the type is 'title', it returns a Title[] and if it is 'body', it returns a Body[]. searchAt<'title'>('.....') returns Title[] searchAt<'body'>('....') returns Body[]

  • @-anonim-3008
    @-anonim-30082 күн бұрын

    Thanks a lot! That's easy)

  • @bobsawey
    @bobsawey3 күн бұрын

    thx

  • @JPilsonSumbo
    @JPilsonSumbo3 күн бұрын

    People get into these problems for misusing enums, you want to do things that enums were not designed for. Enums are designed to represent a fixed set of related constants with descriptive names, which makes code more readable and maintainable.

  • @WendiCahyono-yf7xc
    @WendiCahyono-yf7xc3 күн бұрын

    as the name suggests

  • @hatemtraif4164
    @hatemtraif41644 күн бұрын

    The way I read this now, this is similar to as const, but with as const you are narrowing the entire thing as a value while this will narrow the types for you only ? I saw also another comment that satisfies can be mixed with as const, what are actual use cases were combining both is desired?

  • @AlvaroDevLabs
    @AlvaroDevLabs4 күн бұрын

    Best explanation out there of the why, and you answer the most common question, should I force ESM only? It's always depending on your users. Great video.

  • @pulserudeus7968
    @pulserudeus79684 күн бұрын

    awesome find! thanks

  • @JaquaSchao
    @JaquaSchao4 күн бұрын

    I'm member number 50,490 on 31/05/24 use this extension. Good content, good video. Thanks <3

  • @josevargas686
    @josevargas6866 күн бұрын

    If you like a minimal amount of dependencies, look into Fresh framework from Deno. You get EVERYTHING and ZERO build steps, it's absolutely calming.

  • @Zufarabyan
    @Zufarabyan6 күн бұрын

    I guess your example is similiar to the usage of enum (?). are there any other example besides that?

  • @eulucaspedroabreu
    @eulucaspedroabreu10 күн бұрын

    Was in dare need of this explanation! Thank you, Matt!

  • @user-nb3nf7gc7z
    @user-nb3nf7gc7z10 күн бұрын

    this isn't type safe at runtime. The server can return something you aren't expecting.

  • @jasonjimenez9116
    @jasonjimenez911611 күн бұрын

    Nowadays, we just let chatgpt generate the generic types. Lol

  • @Shogoeu
    @Shogoeu11 күн бұрын

    Right at the end of this video, I got a suggested video "Don't use const!"

  • @shatzofhudson
    @shatzofhudson11 күн бұрын

    you could also just not use typescript.....significantly easier

  • @sanjivgautam4416
    @sanjivgautam441612 күн бұрын

    Aren't you a fucking genius?

  • @chamseboulabba1742
    @chamseboulabba174212 күн бұрын

    Useless , complicating things , learn how teach first , understanding things dosn't mean you know how to teach it , the worst explanation ever seen

  • @mattpocockuk
    @mattpocockuk12 күн бұрын

    What felt bad about my teaching style?

  • @otiamaino2461
    @otiamaino246112 күн бұрын

    Weird if they learnt js this shouldn’t be a problem I mean DOM nodes are anything from a tag to a text, and HTMLElements are html tags 🤲🏾

  • @real-oppenheimer
    @real-oppenheimer14 күн бұрын

    Could you show a setup where the "package" uses React? I want to use React there to e.g. write reusable hooks that are then used in the apps.

  • @mattpocockuk
    @mattpocockuk14 күн бұрын

    Add "jsx" to your tsconfig.json. That's it!

  • @real-oppenheimer
    @real-oppenheimer14 күн бұрын

    @@mattpocockuk Thanks :)

  • @AbstruseJoker
    @AbstruseJoker14 күн бұрын

    This man’s content is always golden. Unlike theo and prime ranting about the most random crap

  • @LokiDaFerret
    @LokiDaFerret14 күн бұрын

    I think "people doing database stuff" already have written try/finally blocks. And it seems a bit pointless to rewrite existing code which has no optimal performance value. So good for new/future development. Not very useful in existing projects. 2 cents.

  • @zilahi8
    @zilahi814 күн бұрын

    Did not get to like turborepo, however, nx is just pure awesomesness!

  • @dheerajsinghnagdali
    @dheerajsinghnagdali15 күн бұрын

    Thanks for deleting my comment 🤡