Easily Extend TypeScript Types In All Libraries!

Sdílet
Vložit
  • čas přidán 11. 09. 2024
  • In this video, we'll go over what we believe is the easiest way to extend the defined TypeScript types of any and all npm libraries including some common ones like express and lusca...
    GitHub Repo: github.com/cov...
    Express Template Repo: github.com/cov...
    Don't forget to like this video and subscribe to our channel - we're publishing more videos and walkthroughs every week. Comment below and let us know what you'd like to see next!
    Join the Covalence community: covalence.io
    Shop Covalence merch: covalence.merc...

Komentáře • 8

  • @AyushKumar-po8no
    @AyushKumar-po8no Před 7 měsíci

    That was actually very good content. Helped a lot.

  • @emreaka3965
    @emreaka3965 Před rokem

    Thank you. I encounter this in one of our legacy applications and I wanted to learn what that was for. In the first place, I've got a clue about what that is for but I just wanted to be sure and learn more about it.

  • @NavySturmGewehr
    @NavySturmGewehr Před 7 měsíci

    I'm really struggling with this concept: What if I want to create a type definition library for my own javascript components? I want to be able to share types between a number of different projects, so I just want to npm install ../types and have access to namespace.mytype globally without imports (es6).

    • @covalence-io
      @covalence-io  Před 6 měsíci

      you could create your own npm package or add your types to a github repo and add the repo as a dependency to your package.json

  • @salkohajric6176
    @salkohajric6176 Před měsícem

    Can you crate a video on how to change existing values or extend them

    • @covalence-io
      @covalence-io  Před 20 dny +1

      you should be able to change existing values the same way or just by redefining the interface. it should take the last definition that's been defined.

    • @salkohajric6176
      @salkohajric6176 Před 17 dny

      @@covalence-io and how to extend them? For example, if I have an object and keys a,b,c,d (all a string etc.) from some package and I simply want to make a little change and make the b to be number etc. and leave other fields typed as they are typed from the package itself

    • @covalence-io
      @covalence-io  Před 13 dny

      @@salkohajric6176 you could try something like this and use type B in your code instead of A. Rewriting the value of A doesn't make sense since there is clearly a library using that value as a string.
      interface A {
      x: string
      }
      export type B = Omit & { x: number };