loading...
markdown guide
 
 

Honestly you don't have to write a .d.ts these days, tsconfig can let you generate one with one of its many options (to drunk to look it up sorry)

Edit: for js authored libs you can use Microsoft's cli tool as seen bellow.

 

This is actually not true. There are too many pure JavaScript projects with or without JSDoc (and sometimes TypeScript IntelliSense just doesn't read JSDoc...) That's why github.com/DefinitelyTyped/Definit... exists, which are actually hand-written *.d.ts's.

(Though, I know it is possible to generate *.d.ts from JSDoc. I do that sometimes.)

You can also add *.d.ts to a pure JavaScript project of someone else, without submitting to DefinitelyTyped. Even if they don't merge the PR, npm install *.git from GitHub is definitely an option.

Ah ... Of course, I wasn't thinking about this context where a library was not originally authored in Typescript (but I was drunk so you can let me off). I'm sure there is tooling to introspect JavaScript libs and generate .d.ts files anyway. When there's a will there's a way.

Thank you Maciej and thank you Microsoft.

So you see a definition file is not desirable to hand write because, it's bad enough maintaing code that actually do something, can you imagine refactoring this every time you make a change as well, people would rage quit typescript. I used to do it by hand then decide I cba. But there we go, you can and should generate as much as possible.

 

tsconfig is like glasses, stick to the default you will know what to change / lookup when things are not working the way you want.

 

There is package 'foo' which has '@types/foo' and the latter is used in project. The latter has some types/interfaces declared wrong (not fully typed or actually wrong). How to extend or rewrite those fishy places in local types not abandoning all other parts of original "@types..."?

 

Not sure how ‘experimental’ the ‘experimental decorators’ still are, thought about trying to implement a custom one the other day but kind of gave up! Maybe you could go into a bit more detail on how they work, when to/not to use them, etc?

 

Decorators are still in draft and have been for ages. github.com/tc39/proposal-decorators

But as this is compiled sec for a language that never actually runs, it's safe to use. Same for babel.

 
 

Generics would be a nice thing to cover :)

 
 

Enums please (I know what they are in other languages) how do they or compile / or they dont?

 

Please do this! I will try and think of some other things people didn’t already say. But yes, this would be great!

 

I think advanced typescript should include some intermediate OOP, since that's often not solidified for JS developers

Classic DEV Post from Aug 1 '19

Which dev.to loading GIF do you prefer?

I made some dev.to loading gifs

Maciej Sikora profile image
I am Software Developer, currently interested in static type languages (TypeScript, Elm, Reason) mostly in the frontend land

dev.to now has dark theme. 🌝

Go to the "misc" section of your settings and select night theme

P.S. It's the best move you can make for your dev career.