The past 2 TSConf keynotes have had this same slide and I thought it might be fun to look at each of these aspects of @typescript one by one. đŸ§”

(you can see @ahejlsberg present the slide here in 2020 and in 2019)
Erasable - with a few exceptions the extra syntax TS adds onto JS leaves no trace in the generated JS, it is completely erased. TS does not make any additional type information available at runtime or use type information to improve the generated JS

https://www.typescriptlang.org/play?removeComments=true#code/PTAEBUGVQdwSwDYNAQwCZtHAdqARAK4DOApqEQC4BOcAxhXqAEYCeoaJAZigRQLAAoQTgokq3WmUjUcAcwAKVAPYAHUAG9BobSuUqAXORnZZAbkEBfQYM4Fs9OEtyySFRaoAUKKrMPSaJu4qAJSGlAGyGlqgVK4EVLjesgB0uqrmAlZCArROREoIJMkISrIe-nJBwaAgoABS0AAWKESg2EqotJJErRQdUIJAA
Gradual - A TS program with missing types or type errors can still be converted into JS and run. This helps when introducing TS into an existing JS codebase, or when quickly trying out an idea.

https://www.typescriptlang.org/play?noImplicitAny=false&removeComments=true#code/PTAEFpQOwewUQLYEsAuB5KcBOWZYFygBmAhgDYDOApgLABQIE0MAkggA5lIDGqAglACehUpVp169IgFco3FEhhRQAcyooAyiixIoKgBQksKgJSEK23StABveqFBZ10rMqMqAdCkHsqG7jrsKAD6JBQU0ghUFMEoABZIMVQAHokoFPomANz0AL70QA
Generic - types in TS can include placeholders where specifying that part is deferred. This also allows the type to be reused in slightly different situations. Other languages like ‘go’ did not include support for generics but have since changed direction.
https://www.typescriptlang.org/play?#code/JYOwLgpgTgZghgYwgAgOIRNYCAKUD2ADgDwAqAfMgN4CwAUMo4QYQFzKkDc9AvvfTACuIBGGD4QyAOYQweImXIAKOFCnt0mKNnkkKASnalq9RlFmCok1VIB0zItzp86QA
Inferable - It is not required that all symbols have their type written next to it. TS can use existing information to determine the type. The ‘as const’ syntax can be used to switch TS into inferring a narrower type for a literal value.

https://www.typescriptlang.org/play?#code/JYOwLgpgTgZghgYwgAgOIRNYCAKUD2ADgDwAqAfMgN4CwAUMo4QYQFzKkDc9AvvfTACuIBGGD4QyAOYQweImXIAKOFCnt0mKNnkkKASnalq9RlFmCok1VIB0zItzp869ADazkAD2QBeabK6SlTIDmzIANoAjAA0yABMcQDMALrIPPpO7p4Ann4BcizBoSzs0XGJyKnIcADOyAgStWDpmfRAA
You can follow @acutmore.
Tip: mention @twtextapp on a Twitter thread with the keyword “unroll” to get a link to it.

Latest Threads Unrolled:

By continuing to use the site, you are consenting to the use of cookies as explained in our Cookie Policy to improve your experience.