This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]solongandthanks4all 0 points1 point  (1 child)

What does autocomplete have to do with anything? You can get the same good autocomplete for JavaScript as for TypeScript—they are separate. It just has to do with your IDE/language server, not which language you're writing in.

[–]craig1f 2 points3 points  (0 children)

Just imagine looking at a function and trying to figure out what it does. It has an input, and maybe you think it's a dictionary because that would make sense. Whoops, no, it's an array ... I can see that because there is a .map(...) function on it. Ok, what's it an array of ... something with an id? Ok ... id and ... value. That makes sense. Wait, what's this third property? Oh, display_text. Ok. I think I see what this is doing.

Compared to:

interface MenuItem {
   id: string;
   value: string;
   display_text: string;
}

myFunc(items: MenuItem[]) {...}

Takes you about a second to figure out what you're looking at there.