this post was submitted on 02 Oct 2023
9 points (90.9% liked)

Programming

13389 readers
41 users here now

All things programming and coding related. Subcommunity of Technology.


This community's icon was made by Aaron Schneider, under the CC-BY-NC-SA 4.0 license.

founded 2 years ago
MODERATORS
 

Can anyone recommend a good introduction/book to TypeScript for people who already know some programming (e.g. Java, Python) but have no experience with JavaScript?

The only texts I've found so far assume prior JS knowledge (like The TypeScript Handbook https://www.typescriptlang.org/docs/handbook/intro.html) or seem rather unstructured to me (e.g. dropping a lot of different ways and shortcuts to do things without explaining concepts or making no clear distinction between basics/best practices and advanced use cases/edge cases).

Ideally it would explain core concepts (like functions, types, classes, ...) first, with their most common use cases. Later chapter would do deep dives into different topics.

Edit: when I'm talking about TypeScript I'm talking about the whole language, not just the "modifications" it makes to JavaScript.

you are viewing a single comment's thread
view the rest of the comments
[–] andros@hostux.social 3 points 1 year ago (1 children)

@homoludens I don‘t think is a good idea. Every TypeScript developer ought know deeply JavaScript. For example, if you work with Django you ought programming with Python.

[–] homoludens@feddit.de 1 points 1 year ago (2 children)

Yes, that I need to learn some amount of Javascript is a given. But I would rather not learn some JS aspects that I won't need anyway, because TS prevents me from using them or has other best practices.

[–] madkarlsson@beehaw.org 3 points 1 year ago (1 children)

Typescript doesn't really remove anything you learn in JavaScript. Like at all. It's not really a library as such. It adds ways to enhance your JavaScript, with typing, structure, and tooling

Learn JavaScript as much as possible. Every bit you learn will benefit you with typescript

[–] homoludens@feddit.de 1 points 1 year ago (2 children)

I know TS doesn't remove that much from JS, but I expect the typing, structuring etc. to prevent some behavior that can occur in JS - otherwise what would be the point of e.g. the typing system? So that are the parts I don't need to learn (at least not at first).

I think an important point for me is that I'd rather learn "from a TS perspective", that is starting with best practices and common use cases as they appear in a TS environment. Right now it sounds to me that the usual way would be to read some JS book, where I learn e.g. about functions or objects. And then I would read another book with all the modifications that TS makes to e.g. functions or objects.

[–] madkarlsson@beehaw.org 2 points 1 year ago

Its important to understand that:

  • JavaScript is typescript
  • Typescript is JavaScript with types

When you are writing typescript, you are writing JavaScript but have additional syntax to help support type safety and structure. If you are creating a function that does x, it should very much be the same in JS and TS, just in TS it has extra syntax

TS doesn't modify the way JS works, its one of the stated needs for the tooling.

In TS, for example, I can denote an object as

const x: Record = {}

In JS it would be

const x = {}

It's still nothing but an object. TS doesn't change the functionality, it just adds typing and checks that you are using that object properly as static build step.

[–] lemmyvore@feddit.nl 1 points 1 year ago

otherwise what would be the point of e.g. the typing system?

What's the point of type hinting in Python?

[–] andros@hostux.social 0 points 1 year ago (1 children)
[–] homoludens@feddit.de 1 points 1 year ago

Please see my other replies.