What Are *.d.ts files? How to Use *.d.ts Files in TypeScript?

Sdílet
Vložit
  • čas přidán 13. 07. 2020
  • 📘New Course: Build full-stack React Typescript applications tsreact.maksimivanov.com/s/ytd
    How to use *.d.ts files

Komentáře • 83

  • @yuriihusak1959
    @yuriihusak1959 Před 4 lety

    Man, I have been looking for a channel like this for months!! Keep going!

  • @monkeymagic2385
    @monkeymagic2385 Před 2 lety +1

    Yeah really helpful. I was confused about whether the d.ts files are just for auto-generated type definitions and/or used to define types. Your suggestion to leave .d.ts files for auto-generation and .ts file for locally defined types has cleared the mist for me.

  • @rahul-thakare
    @rahul-thakare Před 2 lety

    For a long time I was wondering what these *.d.ts files are and what these are used for.
    This video cleared all the doubts about it.
    Thanks from India for sharing.

  • @matthewzecchini9951
    @matthewzecchini9951 Před 3 lety

    Great content man, more typescript videos!

  • @swaroopbhave651
    @swaroopbhave651 Před rokem

    Thats precisely i was looking for. Thanks for a very short and clear video

  • @mikhailgrechka1336
    @mikhailgrechka1336 Před 4 lety +3

    Твои видео выходят быстрее, чем я успеваю развиваться. Спасибо большое за то, что делаешь фронтенд доступней)

  • @ajaykotian5
    @ajaykotian5 Před 2 lety

    You are plain awesome! The best explanation to understand types in TypeScript.

  • @thebluechimera
    @thebluechimera Před 4 lety +10

    This is really helpful! Well done and thank you :)
    It seems like .d.ts files are a parallel to interfaces in Java, since you export function definitions but not implementations. It might be interesting to see a .d.ts file used that way

    • @MrAfusensi
      @MrAfusensi Před 3 lety +9

      No, interfaces are a part of typescript as well. I think d.ts files are mostly used for libraries made with Javascript, so typescript users have proper typing without the code base being written in typescript.

  • @TheSowut
    @TheSowut Před 2 lety +1

    Много информативно, благодаря!

  • @kevinnacario359
    @kevinnacario359 Před 3 lety

    Thank you so much, this was very informative!

  • @ninjarogue
    @ninjarogue Před 3 lety

    Thank you Maksim! Excellent explanation!

  • @Blue-bb9ro
    @Blue-bb9ro Před 2 lety +1

    Extremely helpful, thanks! 😄

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

    Thank you for this video ! I finally understand why I was struggling so much to install "Vue 2" libraries like vue-zoomer or vue-picture-swipe. They didn't support typescript apparently so they don't include the /type folder with the index.d.ts definitions either.
    If anyone else faced this issue I resolved it by adding a 'declare module 'vue-zoomer';' line to my 'shims-vue.d.ts' file and then I can follow instructions from the Github or official website for the library in order to add the components. What this does is treats the component as an 'any' type which still works fine (you just don't get the benefits of strongly typed javascript while using typescript).

  • @Jtube0101Mega
    @Jtube0101Mega Před 3 měsíci

    Great lesson! Thank you very much!

  • @ajithmoni1712
    @ajithmoni1712 Před 2 lety +1

    Very well explained and organized. Thank you

  • @justaskaulakis8202
    @justaskaulakis8202 Před 3 lety

    Thanks a lot, man!

  • @jeferson.luckas
    @jeferson.luckas Před 2 lety

    Thanks for the explanation, I used files like that but I didn't know why.

  • @user-hk6ns2eg1w
    @user-hk6ns2eg1w Před rokem

    Thank you so much for this!

  • @omarislearning3329
    @omarislearning3329 Před 2 lety

    Thanks for the video, and if you can make a video series covering tsconfig, project reference, and other topic regarding tsconfig as even the official docs aren't that easy to understand.

  • @ramusesandasari8451
    @ramusesandasari8451 Před 2 lety +1

    Awesome explaination .

  • @codecodecode8595
    @codecodecode8595 Před rokem

    Thank you for amazing tutorials!
    Which extension do you use: "VSCode Neovim" or "Vim"? If first one, how did you manage to fix mouse selection? Thank you in advance!

  • @DK-ox7ze
    @DK-ox7ze Před 2 lety

    Great explanations!

  • @grzegorzzych4290
    @grzegorzzych4290 Před 3 lety +2

    Hey Maksim, great channel.
    As I know you don't need to export types from *.d.ts files. Types should be available w/o export/import.

  • @maxschwarzschmied5744
    @maxschwarzschmied5744 Před 3 měsíci

    perfect, short and informative

  • @julioalbertoaraniscontrera7941

    Nice video!

  • @specterepiphane5243
    @specterepiphane5243 Před 3 lety

    thanks for the video. it is well explained

  • @vitalii4329
    @vitalii4329 Před 3 lety

    Hej, Maksim Great channel and material. What shell plugin do You use for the terminal? zsh?

  • @idynxcode5744
    @idynxcode5744 Před rokem

    Great! Thanks

  • @MrRe-sj2iv
    @MrRe-sj2iv Před rokem

    Great. very clear

  • @IsfhanAhmed
    @IsfhanAhmed Před rokem

    Awesome

  • @valentinussofa4135
    @valentinussofa4135 Před 2 lety

    Very helpfull Sir. I have problem like this in my express-handlebars. Many thanks from Indonesia.

  • @yapayzeka
    @yapayzeka Před 3 lety +1

    best expplanation out there

  • @dharnilm
    @dharnilm Před 4 měsíci

    Really Good Content

  • @BruceWayne-lm6xt
    @BruceWayne-lm6xt Před hodinou

    Great video
    Very helpful

  • @raymondmichael4987
    @raymondmichael4987 Před rokem

    Thanks this is quite helpful, as I'm learning

  • @aroxing
    @aroxing Před 2 lety

    спасибо, отличное видео

  • @tntg5
    @tntg5 Před 2 lety

    Thanks for these explanations!
    How do I generate d.ts files for an npm package that doesn't not have one ?

  • @superigno
    @superigno Před 3 lety +14

    Thanks Maksim for this! How about "declare" when do we use it in the d.ts file?

    • @stealtime
      @stealtime Před 2 lety

      also wondering about this...

    • @seanpaulson9098
      @seanpaulson9098 Před 2 lety

      I think declare is used when you want to use . notation. so if you want intelisense to show available chainable methods and variables.

  • @CushiMusi1
    @CushiMusi1 Před 4 lety +2

    Please make a video about the tsconfig file. Really like your videos keep up with your amazing work 👌

  • @mdhasanuzzaman1546
    @mdhasanuzzaman1546 Před 2 lety

    It was really very helpful

  • @PhongNguyen-tp7lg
    @PhongNguyen-tp7lg Před 2 lety +3

    Thanks Maksim! subcribed ^^
    Im newbie to TS too & still strugling how to use the .d.ts file.
    Im really confused on some ponits:
    1. When to use import/export & when to use ///

  • @_filipe.miranda
    @_filipe.miranda Před 2 lety

    thank you!

  • @kirillzlobin7135
    @kirillzlobin7135 Před rokem

    PLEASE, HELP. In our project we use Jest and want to integrate Cypress. When we started integrating Cypress - it started having conflicts with Jest's types, because some of the types between Jest and Cypress have the same names.
    But how it could happen, if each library should have its own path to d.ts file?
    It looks like the types for the whole application eventually are collected in one place? Or how it is possible?

  • @viniciusfranca1443
    @viniciusfranca1443 Před rokem

    Hi Marksim Ivanov, thanks for the video, i want to learn how to build an @types project from scratch. My objective is to export only the type definitions of my project A so i can install these types in another project B. Did you have any information/video about it? please let me know

  • @yab570
    @yab570 Před 3 lety +1

    How do I use my local d.ts file in angular 11 application? Do I have to follow the same process as it is shown in the video?

  • @tiagoagm
    @tiagoagm Před 3 lety +2

    In react what's the difference between using interface or types? Is interface possibile to add in d.ts?

  • @VELIXYZ
    @VELIXYZ Před rokem

    Спасибо большое!

  • @nicolaschin7328
    @nicolaschin7328 Před 2 lety

    Thanks for your share! Do you have blog text for this video?

  • @VadimSuharnikov
    @VadimSuharnikov Před 3 lety

    Hi! Which theme do you use?

  • @homelander973
    @homelander973 Před 8 měsíci

    отдуши душевно в душу

  • @RezaMohseni
    @RezaMohseni Před 2 lety +1

    Thank you 🙂 though I hoped you would touch on why types declared in the d.ts files aren't "export"ed, though seemingly auto imported?!

    • @akshay-kumar-007
      @akshay-kumar-007 Před rokem

      It needs to be added in `include` parameter of tsconfig.json and the interfaces and types will be available globally in your project.

  • @samislam2746
    @samislam2746 Před rokem

    What about the name of the d.ts files, for example, why someone will call it index.d.ts? and can I use the same name I have for the module, for example I have stack.ts, can I make a file called stack.d.ts and import it inside stack.ts ?
    and what is the /// thing

  • @gangasaikumarg7393
    @gangasaikumarg7393 Před rokem

    can you tell me what is your vscode theme?

  • @fromsoundtosea2010
    @fromsoundtosea2010 Před rokem

    good!

  • @tabliqatchi6696
    @tabliqatchi6696 Před 2 lety

    Thanks a lot. Very useful. In the end you said join my Discord server. But I can't find it on you channel. No Discord icons I see on your banner.

  • @randompointlessness2766
    @randompointlessness2766 Před 2 lety +1

    What if I find one js library that does not include types ? And I don't want to manually write them up.. like "react-graph-vis"

  • @Oswee
    @Oswee Před 3 lety

    Would like to see how to handle Ambient Modules so i could avoid hard dependencies and thus some circular dependencies in some cases (i know that TSC handles circular dependencies, but in some cases they should be eliminated).

    • @satansdeer1
      @satansdeer1  Před 3 lety

      tbh i rarely use them, can you guve me ab example where you have problems with them?

    • @Oswee
      @Oswee Před 3 lety

      @@satansdeer1 I can give my recent example. Redux Ducks approach where you organize Redux into features and combine them into rootReducer and export RootState. But then you want to import same RootState into Selectors for example. Its a circular dependency. For example in Bazel it's not allowed because all module dependencies should be explicitly declared. You can't import from feature into root and then import root back into feature. So.. the way to handle this is Ambient Modules because all i need from the RootState is its type signature `const getState = (state: RootState) => state.something`. But i found it challenging to configure nested/extended tsconfig so that i would eliminate hard dependency on `import {RootState} from 'Types'` where Types is the ambient module injected in upstream tsconfig.compilerOptions.types field. I dont want to use `... from '../../../types'` because this is hard dependency. Hope this makes sense. As i said... TSC handles this easily and you dont need ambient modules and so most of devs are ok with their circular dependencies. But overall i think it's a antipatern anyway. I do not expect you to make a video on such rare usecase. Just listed my experience. Have a nice day! :)

  • @Cognitoman
    @Cognitoman Před 3 lety

    thanks, I forgot what they were for

  • @abdouseck4894
    @abdouseck4894 Před 3 lety

    thx

  • @yuriihusak1959
    @yuriihusak1959 Před 4 lety +1

    A lot of people who are diving into TS are searching clear explanation of difference between global and namespace. What should you use? or how to make your types be available in the whole project

    • @satansdeer1
      @satansdeer1  Před 4 lety +2

      I'm I it's better to import export types instead of polluting the global namespace. I'll think about some example project to demonstrate how to use both though

    • @yuriihusak1959
      @yuriihusak1959 Před 4 lety

      @@satansdeer1 looking forward to it!

  • @RavindraSingh-lp9pl
    @RavindraSingh-lp9pl Před 7 měsíci

    please let us know functionality of tsconfig file ? Love from India

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

      this file allows you to configure the way your code is compiled and typechecked
      for example if it should allow you to use type any
      if you generate this file using tsc init - it will have comments explaining a bunch of fields there
      to learn about other settings you can use there check the documentation

  • @Grapeoff
    @Grapeoff Před 3 lety

    Спасибки

  • @user-du8jb4ti2l
    @user-du8jb4ti2l Před 2 lety

    salvador dali!

  • @StEvUgnIn
    @StEvUgnIn Před 3 lety

    I'm still stuck...

  • @sunstrike8943
    @sunstrike8943 Před 4 lety

    Please Make form submit API React+typescript please

    • @satansdeer1
      @satansdeer1  Před 4 lety +1

      Hey, what is submit API?

    • @sunstrike8943
      @sunstrike8943 Před 4 lety

      @@satansdeer1 oh sorry sir it was mistaked by keyboard

  • @yakimovev
    @yakimovev Před 3 měsíci

    Хороший английский

  • @muhammadkasymov4087
    @muhammadkasymov4087 Před 3 lety

    а можно на русском тоже самое :D