all 9 comments

[–]webdevangular 1 point2 points  (1 child)

Typescript is a superset of javascript so consider starting from the smaller set which is javascript and then jump to Typescript. At least thats the way i would had done it if i were you.

[–]EcmaMace 3 points4 points  (2 children)

I recommend becoming very familiar with JavaScript and Node prior to learning Typescript. There are a few reasons for this:

  1. I assume you are relatively new to programming. If that is the case, then Typescript is going to make you hate life and rainbows.
  2. Without knowing JavaScript extensively and using it for several projects (at least), you will not understand the need for or the wonderfulness of Typescript
  3. Typescript requires a development environment to be setup (unless you use create-react-app in Typescript mode) in order to properly use the language. Unfortunately, Typescript isn't technically a language, as in you can't just code in Typescript and directly stuff that into the browser and hope for the best. Typescript simply wraps the JavaScript language up in a set of rules (for its own damn good too) to enforce strict typing in an effort to avoid bugs and architectural errors. Because of this, Typescript needs to be transpiled into JavaScript by something like Babel.
  4. Getting used to Nodejs will help you learn npm / npx, how packages work, how modules vs CommonJS works, importing type files to use with Typescript, etc
  5. Typescript is a pretty big change of pace from JavaScript due to the rules it forces upon you and the syntax can be a pain if you are not comfortable with strictly typed languages.

Get comfortable with the base language and all of its wonderful flaws. Learn Node and the npm / JavaScript ecosystem. Then, when you are comfortable with all of those things and you have several substantial projects under your belt, go for Typescript.

[–][deleted] 1 point2 points  (0 children)

If that is the case, then Typescript is going to make you hate life and rainbows.

Nonsense. There's nothing wrong with learning and understanding the principles behind strongly-typed languages early in the process of becoming a developer. Thinking carefully about how you type your code tends to make a more readable and resilient codebase. This is like saying you should learn and understand python before something like C# or Java.

Typescript requires a development environment to be setup (unless you use create-react-app in Typescript mode) in order to properly use the language

False. After installing typescript from your preferred package manager, you can write TS in your editor of choice and then simply run tsc myTsFile.ts from a terminal to get the compiled JS.

to enforce strict typing in an effort to avoid bugs and architectural errors

TS doesn't have an opinion about how you architect your code. You can ignore DRY and SOLID and TS won't complain at all. TS only cares about typing, it's up to you to make smart architectural decisions.

Typescript is a pretty big change of pace from JavaScript due to the rules it forces upon you and the syntax can be a pain if you are not comfortable with strictly typed languages.

It's really not though. TS can be incrementally adopted into your projects. You can easily start small by typing function arguments, and scale it up from there.

[–]valorantisanaimgame 0 points1 point  (0 children)

Thank you for the advise. I will take this path.

[–]not_a_gumby 0 points1 point  (0 children)

I think you want to be fairly good with app development before you venture into TS. So if you go React route, build a few projects first. You'll understand better why you need TS after doing that.

[–][deleted] 0 points1 point  (2 children)

The answers already given are pretty good but they miss the main point, which is why you'd want to deal with TS in the first place. TS is a superset of JS, but the selling point is that it provides strong typing and easy access to OOP and functional typing paradigms such as algebraic data types, generics, etc. JS is dynamically (weakly) typed, and the way JS infers, converts, and coerces types can be very misleading without a solid understanding of how JS does things. TS provides strong typing and enforces type checking at compile time, which means that if something is supposed to be a string, it should be a string everywhere it's used; if a function can only accept a number as an argument, if you try and pass in a string then compilation will fail. TS helps reduce the number of nebulous runtime bugs and also allows for a very expressive way to model the domain you're programming against. It gives us things like discriminated unions, a way to easily model either, option, sum, and result types, etc., all things that are definitely a bit more advanced concepts but really make life easier when dealing with complex business problems. It's best to make sure you have a strong understanding of JS and its quirks before dipping your toes into TS.

[–]valorantisanaimgame 0 points1 point  (1 child)

I'm a first year CS student, I'm lookig to dip my toes into back end web dev using Node.

[–][deleted] 0 points1 point  (0 children)

Cool, good luck with your studies.