Need an example of an advance typescript developer uses d.ts!
prismqubic
Yes this is a good callout. I have engineers on my team that ask about d.ts and I just tell them you basically never need to use them so don't worry about it until you get much more advanced with TS.
thomasini
I think this differs when it comes to libraries vs application code.
Build tools are currently not great at extracting the desired types for publishing. Commonly you’ll see the exposed types in a .d.ts file which is simply copied over to the dist folder when building
brukts
I used to get this wrong and even after I was told not to do it, I didn’t know why until now. Thank you!
flygonfiasco
Module augmentation also belongs in the .d.ts file :)
JlNGLEZ
Let's look at a case where I'm using jsdoc with Js and I don't want to write all my types using jsdoc. Is it okay to put my types in d.ts files?
thelazycoder
what would be some examples of "very advanced" stuff?
aprilmintacpineda
ok but if you don't do "declare" in these files then you're not changing anything globally. isn't that kinda ok?
sohrb
This would be incorrect on libraries as d.ts would have types and .js instead of .ts will have the logic to ensure compatibility
nithinsvarrier
Imagine you have a type you want to use all around your project, a generic, or a bunch of constants - That's what you put in d.ts files.
shapelessed
could you elaborate on why is this not a good practice? i thought i understood .d.ts, but apparently i know very little about it. I'd gladly watch a video of yours on the subject
felipe
I can't imagine people did this mistake.
aArcziMetin
I put everything in my ts files…
The only .d.ts files in my repo are generated ones
EnbyCherry
"I see a lot of people getting this wrong" I have seen this 0 times. I actually thought d.ts files were like an automatic extraction of compiled typescript types for external use (such as for those who use your published package)
carlosmspk
I have a counter example, put a plain interface in a .ts file then tell me what that emitted file contents will be 😂