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

Поделиться
HTML-код
  • Опубликовано: 29 сен 2024
  • 📘New Course: Build full-stack React Typescript applications tsreact.maksim...
    How to use *.d.ts files

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

  • @valentinussofa4135
    @valentinussofa4135 2 года назад

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

  • @mdhasanuzzaman1546
    @mdhasanuzzaman1546 2 года назад

    It was really very helpful

  • @superigno
    @superigno 3 года назад +14

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

    • @stealtime
      @stealtime 2 года назад

      also wondering about this...

    • @seanpaulson9098
      @seanpaulson9098 2 года назад

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

  • @RezaMohseni
    @RezaMohseni 2 года назад +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 Год назад

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

  • @kirillzlobin7135
    @kirillzlobin7135 Год назад

    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 Год назад

    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

  • @thebluechimera
    @thebluechimera 4 года назад +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 3 года назад +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.

  • @randompointlessness2766
    @randompointlessness2766 2 года назад +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"

  • @PhongNguyen-tp7lg
    @PhongNguyen-tp7lg 2 года назад +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 ///

  • @samislam2746
    @samislam2746 Год назад

    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

  • @tabliqatchi6696
    @tabliqatchi6696 2 года назад

    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.

  • @tiagoagm
    @tiagoagm 3 года назад +2

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

  • @yab570
    @yab570 3 года назад +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?

  • @CushiMusi1
    @CushiMusi1 4 года назад +2

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

  • @Blue-bb9ro
    @Blue-bb9ro 2 года назад +1

    Extremely helpful, thanks! 😄

  • @grzegorzzych4290
    @grzegorzzych4290 4 года назад +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.

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

    Very well explained and organized. Thank you

  • @gangasai_kumar_G
    @gangasai_kumar_G Год назад

    can you tell me what is your vscode theme?

  • @RavindraSingh-lp9pl
    @RavindraSingh-lp9pl 9 месяцев назад

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

    • @satansdeer1
      @satansdeer1  9 месяцев назад

      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

  • @maxschwarzschmied5744
    @maxschwarzschmied5744 5 месяцев назад

    perfect, short and informative

  • @BruceWayne-lm6xt
    @BruceWayne-lm6xt Месяц назад

    Great video
    Very helpful

  • @facundosoler2200
    @facundosoler2200 9 месяцев назад

    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).

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

    Awesome explaination .

  • @monkeymagic2385
    @monkeymagic2385 2 года назад +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.

  • @IsfhanAhmed
    @IsfhanAhmed Год назад

    Awesome

  • @yuriihusak1959
    @yuriihusak1959 4 года назад +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  4 года назад +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 4 года назад

      @@satansdeer1 looking forward to it!

  • @homelander973
    @homelander973 10 месяцев назад

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

  • @codecodecode8595
    @codecodecode8595 Год назад

    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!

  • @dharnilm
    @dharnilm 6 месяцев назад

    Really Good Content

  • @idynxcode5744
    @idynxcode5744 2 года назад

    Great! Thanks

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

    best expplanation out there

  • @jeferson.luckas
    @jeferson.luckas 2 года назад

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

  • @tntg5
    @tntg5 2 года назад

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

  • @MrRe-sj2iv
    @MrRe-sj2iv Год назад

    Great. very clear

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

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

  • @_filipe.miranda
    @_filipe.miranda 2 года назад

    thank you!

  • @julioalbertoaraniscontrera7941
    @julioalbertoaraniscontrera7941 2 года назад

    Nice video!

  • @fromsoundtosea2010
    @fromsoundtosea2010 Год назад

    good!

  • @nicolaschin7328
    @nicolaschin7328 3 года назад

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

  • @rahul-thakare
    @rahul-thakare 2 года назад

    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.

  • @김경태-p4x
    @김경태-p4x 2 года назад

    salvador dali!

  • @yakimovev
    @yakimovev 5 месяцев назад

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

  • @omarislearning3329
    @omarislearning3329 3 года назад

    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.

  • @raymondmichael4987
    @raymondmichael4987 Год назад

    Thanks this is quite helpful, as I'm learning

  • @vitalii4329
    @vitalii4329 3 года назад

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

  • @swaroopbhave651
    @swaroopbhave651 Год назад

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

  • @Jtube0101Mega
    @Jtube0101Mega 4 месяца назад

    Great lesson! Thank you very much!

  • @ajaykotian5
    @ajaykotian5 2 года назад

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

  • @ninjarogue
    @ninjarogue 3 года назад

    Thank you Maksim! Excellent explanation!

  • @specterepiphane5243
    @specterepiphane5243 3 года назад

    thanks for the video. it is well explained

  • @チョリパン-j4f
    @チョリパン-j4f Год назад

    Thank you so much for this!

  • @Cognitoman
    @Cognitoman 3 года назад

    thanks, I forgot what they were for

  • @StEvUgnIn
    @StEvUgnIn 3 года назад

    I'm still stuck...

  • @Oswee
    @Oswee 4 года назад

    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  4 года назад

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

    • @Oswee
      @Oswee 4 года назад

      @@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! :)

  • @DK-ox7ze
    @DK-ox7ze 2 года назад

    Great explanations!

  • @VadimSuharnikov
    @VadimSuharnikov 3 года назад

    Hi! Which theme do you use?

  • @VELIXYZ
    @VELIXYZ Год назад

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

  • @kevinnacario359
    @kevinnacario359 4 года назад

    Thank you so much, this was very informative!

  • @matthewzecchini9951
    @matthewzecchini9951 3 года назад

    Great content man, more typescript videos!

  • @justaskaulakis8202
    @justaskaulakis8202 3 года назад

    Thanks a lot, man!

  • @abdouseck4894
    @abdouseck4894 3 года назад

    thx

  • @sunstrike8943
    @sunstrike8943 4 года назад

    Please Make form submit API React+typescript please

    • @satansdeer1
      @satansdeer1  4 года назад +1

      Hey, what is submit API?

    • @sunstrike8943
      @sunstrike8943 4 года назад

      @@satansdeer1 oh sorry sir it was mistaked by keyboard

  • @yuriihusak1959
    @yuriihusak1959 4 года назад

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

  • @muhammadkasymov4087
    @muhammadkasymov4087 3 года назад

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

  • @Grapeoff
    @Grapeoff 3 года назад

    Спасибки

  • @mikhailgrechka1336
    @mikhailgrechka1336 4 года назад +3

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

  • @aroxing
    @aroxing 3 года назад

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