Planning to run some advanced TS series on dev.to. Plan is to go through some really sofisticated examples of type system usage. Whould you be interested in such? And If so, what topic would be most interesting for you?
For further actions, you may consider blocking this person and/or reporting abuse
Top comments (16)
index.d.ts
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.
Yes there is github.com/microsoft/dts-gen
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.
OOP implementation by typescript.
Generics would be a nice thing to cover :)
Please write about generics π€
I think advanced typescript should include some intermediate OOP, since that's often not solidified for JS developers
Please do this! I will try and think of some other things people didnβt already say. But yes, this would be great!
Enums please (I know what they are in other languages) how do they or compile / or they dont?