I have written a 16 part "Notes on TypeScript" series, which is an unstructured collection of TypeScript related notes. Trying to convert this series into a more structured learning resource. Here are some questions, where I would be very interested in some feedback.
What do you find hard about TypeScript and what would you like to learn more about?
How could a good learning experience look like?
Top comments (8)
I am forever bugged by
Why not
T | undefined
? What is a good way to override this behavior.Also, I am looking for a good series on Vue TypeScript. Recently I got this behavior solved, $mq.
Mostly the problem is always, extending incomplete typed libraries, or JSDoc is lost, and VSCode showing the useless,
declare module '...'
instead. (No, they are not telling how to properly writedeclaration.d.ts
or evensrc/@types/.../index.d.ts
. They don't even provide a link, onlyNo quick fixes available.
).The other way round is problematic too. I cannot write JSDoc
@type
from TypeScript types / interfaces.Here is a solution for the problem with
objGet
:We can limit the possible lookup keys by using
keyof T
, which would prevent calling any undefined keys. This would also ensure that the correct type is written for any provided lookup key.Thanks for the great example and feedback! Don't know too much about Vue, but will definitely have a look at the example you posted.
I think having a solid grasp of what benefits Typescript gives and why you would use it over vanilla JS would be benefitial to beginners.
Thanks for the feedback! Very good point regarding explaining the benefits of TypeScript.
Just start my journey to TS...from python to Js with Ts...Thanks ya!
Knowing when I'm looking at a good use for generics.
Thanks for the feedback!