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.

  • homoludens@feddit.deOP
    link
    fedilink
    arrow-up
    2
    ·
    1 year ago

    Like I said in my other replies: I am not attempting to skirt around JS. If TS is a superset of JS, it would obviously make no sense to try to avoid JS. What I’m looking for is a book/tutorial/… that is structured in a way that it teaches the most important parts the way they are used in TS (including JS) first.

    Example: when functions are taught it would explain the basics of JS functions along with the parameter type annotations of TS, because that’s the way functions are used in TS.

    • chaos@beehaw.org
      link
      fedilink
      arrow-up
      5
      ·
      1 year ago

      There just isn’t much use for an approach like this, unfortunately. TypeScript doesn’t stand alone enough for it. If you want to know how functions work, you need to learn how JavaScript functions work, because TypeScript doesn’t change that. It adds some error checking on top of what’s already there, but that’s it.

      An integrated approach would just be a JavaScript book with all the code samples edited slightly to include type annotations, a heavily revised chapter on types (which would be the only place where all those type annotations make any difference at all, in the rest of the book they’d just be there, unremarked upon), and a new chapter on interoperating with vanilla JavaScript. Seeing as the TypeScript documentation is already focused on those exact topics (adding type annotations to existing code, describing how types work, and how to work with other people’s JavaScript libraries that you want to use too), you can get almost exactly the same results by taking a JavaScript book and stapling the TypeScript documentation to the end of it, and it’d have the advantage of keeping the two separate so that you can easily tell what things belong to which side.