DEV Community

Cover image for What are some concepts in TypeScript that you'd like to know more about?
Nick Taylor
Nick Taylor

Posted on • Updated on • Originally published at iamdeveloper.com

What are some concepts in TypeScript that you'd like to know more about?

Cover photo care of flickr user souravsarkar2013

I wrote an introductory post on TypeScript last October.

I'm looking to write some more posts on TypeScript and I was wondering what people might be interested in knowing more about that either is a source of confusion, needs elaboration or you just heard about something in TS and just want to read a blog post about it.

Top comments (14)

Collapse
 
antonfrattaroli profile image
Anton Frattaroli • Edited

I converted a project to typescript recently. It was my first experience transpiling with babel and updated to webpack 4 in the process. Types existed for the majority of external libraries and adjusting interfaces was smooth. Good experience overall. Not too many issues in the code, just a lot of .toString(). I like to think of it as eslint++, where .eslintrc is the equivalent of globals.d.ts.

One issue I had was that the migration guides I found were all out of date. Lots of webpack 1 examples, some unnecessary steps.

Visual studio tooling (roslyn) was questionable where webpack watch was much better.

Collapse
 
nickytonline profile image
Nick Taylor

I'm curious why you had to do a lot of toString(). Also, for the documentation, that sounds like since you went through it with webpack 4, maybe consider throwing up a PR for webpack 4 in the docs or create an issue so that others don't stumble. 😉

Collapse
 
antonfrattaroli profile image
Anton Frattaroli

In the jQuery type, they have .val() returning string | number | string[], and the code I was working with assumed it would always be a string. Impacted field validation code quite a bit.

Maybe I'll write an article on dev.to about the migration.

Collapse
 
nektro profile image
Meghan (she/her)

Do you know about the progress of TS-WASM compilation?

Collapse
 
nickytonline profile image
Nick Taylor

My experience with WASM is just some articles I've read and podcasts I've listened to. No experience myself with it, but I'm assuming you're referring to this project, github.com/AssemblyScript/assembly... ?

Collapse
 
nektro profile image
Meghan (she/her)

Yes, wow they have made some amazing progress since I last checked them out! I was also looking at Microsoft/TypeScript#9202 though it seems that they wouldn't re-visit the idea until WASM implements garbage collection

Collapse
 
nickytonline profile image
Nick Taylor

Have you done any work with WASM @nektro ?

Thread Thread
 
nektro profile image
Meghan (she/her) • Edited

I haven't made anything particularly useful, but conceptually I really love WASM and think it has a very bright potential. I don't think the tooling is quite there yet, but it's still a new tech and for being as new as it is, browser adoption is fantastic.

As someone very interested in programming language design, the recent #discuss topic Hating on languages you don't use piqued my interest. I have my opinions about some of the languages out there but I was glad to see in the comments one of my favorite observations about the various programming languages out there.

Turing complete languages are essentially just morphisms of finite state automata, so why argue about the packaging?

When performance is the same, the only thing worth arguing about in language design is the grammar. And while I personally love JavaScript many out there would love to see JS's monopoly on the Web come to an end. And they are totally valid in having that opinion. WASM to me, is the answer to that. A common compilation target that any new or old language could come in and target and experience the same performance that browsers have been working on for so long.

To wrap back, I really like a lot about TypeScript and would love a way for it to be interpreted in a more "native-like" way on the Web (instead of just back compilation)

Thread Thread
 
nickytonline profile image
Nick Taylor

Sounds like you should write a post about WASM ;)

Collapse
 
stargator profile image
Stargator

Why the type definitions are on the right after a : instead of on the left where final, let, var are used? What was the reasoning behind that.

Collapse
 
nickytonline profile image
Nick Taylor

TypeScript is a superset of JavaScript, i.e. any valid plain JavaScript is also TypeScript and the types can be optional depending on how strict you make TypeScript in your project, so my guess would be that since they're optional, it's probably easier to parse the Abstract Syntax Tree (AST) when it's var/let/const variableName : SomeType vs. var/let/const SomeType : variableName. I know that @nektro is big into programming language design and is a fan of TS as well, so she might have some more insight into this as well.

Collapse
 
nektro profile image
Meghan (she/her) • Edited

Some feel it helps readability but Nick is right in that it also lies in that the type indicators for languages that put the type on the right are optional because the language has type inference.

You can read more about it here in a discussion I had a little while back

Collapse
 
amineamami profile image
amineamami

Distributive conditional types that would be nice

Collapse
 
tunaxor profile image
Angel Daniel Munoz Gonzalez

a good decorator explanation and how typescript is a good enhancer of this would be nice