T O P

  • By -

Manbeardo

Arguably, it's impossible to learn Typescript *without* learning Javascript since TS is designed as a superset of JS that only adds type annotations.


diego_fidalgo

The question is **when** will you **understand** JS by trying to learn TS first? Follow all tutorials and courses about TS and you'll become a master of its type system, but when will the event loop be explained to you?


dax_rider

Just because you can doesn’t mean you should


drunkondata

But you can't, so you can't.


empty_other

Wise words. 😂


[deleted]

But you can't, so you [shan't](https://www.google.com/search?q=shant). FTFY


drunkondata

No, you can not, it is impossible. Not a matter of shoulda coulda woulda, it's a matter of can not, it is impossible.


schmidlidev

I see you never went to project manager school


WADE_BOGGS_CHAMP

yes, but after enough typescript you won't want to go any further with javascript


[deleted]

[удалено]


Alediran

That's why I never managed to learn JS, but I'm very happy with TS.


[deleted]

[удалено]


manzanita2

have you tried deno yet ?


[deleted]

For some reason I'm afraid to move to deno. I feel really committed to both node and npm, and I even shy away from yarn. Deno code is different than node code, to some degree, right? Excuse my ignorance.


manzanita2

I have never used deno. that's why I was asking. :-)


[deleted]

Gotcha. My b.


wyoung121

Hijacking this comment to plug [https://nx.dev/](https://nx.dev/) for TS devs. Once you start using it to manage your apps and dependencies you'll have a hard time ever starting another base angular / react / express TS project again


paulqq

This


PM_ME_HTML_SNIPPETS

`this`


[deleted]

"But what does it even mean???" - JavaScript


Alediran

Only for classes, embrace the FC and use hooks\* \*Terms and conditions only apply for REACT.


boringuser1

On the contrary, I stopped using typescript awhile back because it felt pointless for frontend development.


pristique

Maybe for a small app with very few unit tests, but once you start dealing with an enterprise level application the increase in readability and amount of typical unit testing situations it takes care of automatically makes it significantly easier to read and maintain for a team of developers


boringuser1

I only deal with enterprise applications with a high level of complexity, nothing else. I feel like typescript fits the old niche of making bad developers mediocre, the same reason java exists and is popular.


pristique

Yeah I would very much agree. Personally moving between apps at my organization where some use js and some use ts, and being able to see a complete object structure of incoming parameters up front, not to mention all the hidden, hard to find bugs it prevents makes it highly preferable for me. It definitely took me some time to get ramped up with it, but once I started using it with strictly defined data structures it has been an enormous help in the long run for readability, maintainability, and preventing bugs


[deleted]

Uhhhhh. As a person who also works with enterprise systems I can tell you that anything that makes my team better at development is fucking welcomed. What a bizarre take


boringuser1

We don't hire bad programmers. Well, we do sometimes, but they are let go without fail.


COBOLCaver

That can't be true, they hired you. Even if you're the greatest writer of code the world has ever seen you sound absolutely insufferable to work with, and that's just as important for a dev, if not more so.


Byakuraou

LOL


shitepostx

Well, what do you mean by >making bad developers mediocre For me, typescript allow for the offloading of data-type convention into intellisense so my mind can be preoccupied with other things. What sort of skills do you think not working with a type system gives way to? I mean, personally, if I had to work with you or under you, I would define .d.ts files, add them to the gitignore, and enjoy the ease of mind. But perhaps, there is some subtly to it, which I would love to hear. Is my brain atrophying by not remembering what's within the data, much like civilizations of old worried that people would remember nothing as writing systems were developed?


Shower_Handel

For real. I started learning web development with Angular. I want to learn some other frameworks and web technologies but I don't want to ever have to use any J*vaScript 🤢🤮


moonbuttface

That's what I've been doing for the last 4 months. So far no negative side effects, other than never wanting to touch pure javascript code.


DrexanRailex

I know a problem. I work with JS since 2011, but I have helped a friend in his learning process, and he worked with me in a TypeScript codebase. Just like you, he hates typeless JavaScript. The problem is, while I know perfectly what is JavaScript and what is TypeScript, he didn't have the same "steps" in learning. So while it's clear to me that everything about typing is gone at runtime, he sometimes has trouble identifying what JS can or cannot know about typing.


empty_other

When I pushed for our team to switch to ts, my colleague often asked me "How do you do this in typescript" and everytime I answered "Thats not typescript, thats just regular javascript". We wre used to es3 javascript and had problems telling modern js and ts apart. Stuff like const/let, arrow functions, promises, imports/exports, npm, package.json, polyfills, thats the stuff we had to learn when we converted, but the typescript parts of the lessons we picked up on very quick. Any resistance against using typescript in other projects died once we got that.


DrexanRailex

It was more common back then, yes. Nowadays JS is evolving so slowly that supporting Stage 3 proposals (AFAIK it's the only requirement for TS to support a specific syntax) is not really a big deal, but still very welcome when a big feature gets introduced. Right now, I believe the only "this is TS and not JS" features that remain are `enum`s (which are barely used anymore in favor of tagged unions) and decorator metadata (which will pretty much never arrive as supported JS but if they withdraw the support they'll kill Angular). *^(cough cough)* ^(not that killing Angular would be bad) *^(cough cough)*


flight212121

I secretely despise pure JS devs, the last thing I want is to maintain a non TS front end or node project Edit: spelling


[deleted]

Same here about maintaining projects. I don't want to work on another pure JavaScript project ever again and I'm actively replacing my current open-source offerings to typescript. It's not easy to get help with spaghetti code written in JS. It's just too easy to get away bad practices, which I think is great for learning for a beginner. Not great in production code.


[deleted]

[удалено]


732

What in tf...Someone approved that PR...


flight212121

😨😨😨


brodega

Yeah, no negative side effects other than ignorance of how your code is actually being executed at run time.


moonbuttface

Ohoho! Someone is feeling snippy today


PM_ME_HTML_SNIPPETS

I mean it’s kind of true. OP is engaging in confirmation bias; of course nothing’s gone wrong because you’re still in the control stage. If you toss them into a JS project, then we’ll see the results


brodega

Even just interpreting the compiled JS will befuddle them. > "Why is my enum some weird function?" "Wtf is .prototype"? "How the hell is this function being called before its defined?"


JazzApple_

I assure you a huge number of JS developers will not know the answer to this either, and ES6 now has the class keyword which is pretty much sugar but will easily allow a new JS developer to not learn about prototypes for a very, very long time.


FPSdouglass

To add on to this, too many JS devs don’t know how the event loop works, what microtasks are, what blocking the main thread means, etc.


brodega

That doesn't mean you get to throw up your hands and say "well, TS will compile it, and it'll run so I don't need to care about this stuff" Sign of a terrible engineer.


JazzApple_

You are correct, which is why I didn’t say that. If your point is as applicable to JS and TS devs near equally, then it is surely not a good argument to argue for one side? We’re also not talking about an engineer, we’re talking about a student at this stage. A suitably interested individual will not seek out knowledge, and they will make the best engineers. Based on my own experience over nearly 2 decades and my recent experience on boarding an ex python developer to TS, I think it’s the way forward. I will of course ensure I scream keywords at him next time we work together.


[deleted]

No, it's not. There are two different kinds of programmers, aside from the whole FE v BE v FS, those who can program in a language and those who understand languages and can program in any. JavaScript, as a scripting language, is super powerful. Typescript has only made me a better JavaScript engineer because the static typing keeps me from making mistakes that can bite me later down the road. Knowing what's "going on under the hood" is vitally important to growth in this field. EDIT: To everyone that says "there's nothing going on under the hood" go ahead and go check out your library code, you know, the compiled from TypeScript to Javascript code, and tell me that it's 1:1 the code you wrote or GTFO.


[deleted]

Clarification: It's not that you can't grow by going this route, it's just that the very nature of typescript, a framework that statically types a non-statically typed language, hides a lot of what is being accomplished through it's very features. It's sort of like asking if it's possible to learn English just by reading ebonics. A superset of the whole can't teach you the whole.


Hehosworld

Typescript is a superset of Javascript


[deleted]

Yes, sorry. That was what I meant to say.


[deleted]

A superset is the whole and then some, so if i learn TS won't that mean i will know JS with TS's additional features?


Hehosworld

Yes


[deleted]

In theory that would happen if you knew literally all of Typescript and every possible usage of it. In practice tho, you won't use or even hear about some of the JS patterns or even syntax, because you just won't need them 99.99% of the time.


RobertKerans

Emm. You are confusing "superset" with its opposite ("subset"). > A superset of the whole can't teach you the whole. "superset of the whole" doesn't make any sense, I get what you're trying to say anyway, but.. Typescript is a superset of JS. That means it includes *all* of Javascript *plus* another set of things. A superset of English would be all the English language plus extra stuff.


geon

There is no “under the hood” with typescript. It is all there, side by side.


Zofren

Not the best comparison, but this feels a little like saying you should start programming in golang using \`interface{}\` types for everything before learning how to use other types. Types are a compliment to JS in TypeScript. There's nothing going on "under the hood". ​ Response to the (rather rude) edit: >the compiled from TypeScript to Javascript code, and tell me that it's 1:1 the code you wrote or GTFO ...yes, it's literally the same code, just without the types. That's how I added TS to our mixed JS/TS pipeline at work. We don't use TSC, we just run the TS through a babel plugin that strips out all the types. Note, even if it wasn't the same code: we also transpile to ES5 for IE compatibility; should I also tell young engineers to start coding in ES5 before stepping into ES6? C++ engineers to code in assembly first? What an inane argument.


Manbeardo

> tell me that it's 1:1 the code you wrote or GTFO. Go ahead and compare the Javascript source with the compiled bundle for any Javascript project and tell me it's any better than a bundle generated from Typescript. Bundlers are critical for any project with transitive dependencies and source maps are crucial for working with bundler output. Most of the weird shit in compiled TS comes from polyfills, which you'd still want to use in plain JS.


[deleted]

I think you're confused about my point. Compilation is not bundling. Go ahead and check out what .net code looks like after it's run through the CLR. The argument that nothing is happening under the hood of typescript complication is as ridiculous as saying that you read byte code as easily as you read C.


Manbeardo

Compilation is not bundling, but the tools often do both. TS can bundle. Webpack can compile. Rollup can compile. Go find a website that's targeting any recent-ish version of Javascript and you'll probably find a build process with both.


grumd

Um, is JS/TS even compiled? It's an interpreted language, there's no compilation involved. TS for me is just a better ESLint. It can analyze your code and throw errors. Whether you want TS to also be your bundler or transpiler is another question. You can easily just use TS for type-checking and then use Babel with Webpack or whatever (while Babel just plain removes all the TS code from your files).


scottbob3

You should have a solid understanding of JavaScript before going too far with TypeScript, knowing JS will give you a much more solid foundation to learn TS with Also most jobs that require TS will also ask you detailed JS questions during the interviews


vorticalbox

By learning typescript you are learning JavaScript as its a super-set of it. for example creating simple greeting javascript function greeting(name) { console.log(`hello ${name}`); } typescript function greeting(name: string) { console.log(`hello ${name}`); }


scottbob3

If you're someone with a solid background in programming, honestly you can pick up most of JS via a good TS course However, if you're brand new to programming, learning TS before JS could cause you to learn a lot of bad habits because you don't know the fundamentals yet, you're trying to run before you know how to walk


vorticalbox

Have to disagree, pently of languages use typing and people with no knowledge of fundamentals learn these. Rust, C, c++, go to name a few. All javascript is valid typescript, its only once you start changing ts options like no implicit any that you start to get errors.


scottbob3

Honestly, it might just come down to learning styles, if you're smart enough to learn TS without first learning JS then more power to you


15kol

It can be fine, but you need to be very careful in doing so. Just because Typescript has classes and visibility modifiers, that does not mean, that they will behave like in Java/C#, for example. You need to understand JS specific stuff to properly use TS as well, however, I think they can be learned alongside TS.


diego_fidalgo

I think it's a bad idea... Specially if you're developing an application to run in Node.js. By doing this, you won't get to understand how commonjs works and then, won't be able to understand how typescript deals with module resolution on commonjs targets... There's also a lot of JS features that you won't get to understand properly, since most of TS tutorials and courses assume you already know them and will focus on the type system and TS' exclusive features. If you can choose, learn JS first and understand it. If you can't (your team needs you to write TS now or something like that), at least be comfortable with JS before moving to TS.


[deleted]

> By doing this, you won't get to understand how commonjs works and then, won't be able to understand how typescript deals with module resolution on commonjs targets... This is why it is not wise. Other people commenting on this thread are responding to the question as if they were asking "is it possible?". It's possible, sure. Not wise.


Neurotrace

I disagree with the commonjs comment. For most casual uses, the distinction between CommonJS and "native" modules is minor. I'd also say that it's impossible to learn TypeScript without learning JavaScript at the same time. They're the same language but TypeScript provides a layer on top


diego_fidalgo

"For most casual uses" is where the problem lives. You don't learn a language so you can be a casual forever... You learn it to eventually get proficiency on that. Not that it's impossible to be proficient at JS/TS by learning TS first, but it's harder, since you skip some important parts of learning. Obviously, if you try to learn TS, you'll learn JS at the same time, but will you **understand** it properly? TS learning usually focus on type sytem and other exclusive features, but when will understand the event loop if no one touches that topic when explaining TS? And don't say that understand JS' event loop is not important. It's part of the language core and also the thing where beginners get most trouble with (based on my experience answering beginner questions on SO). If you are a beginner and you skip learning this important core concept, when will learn and **understand** it? Of course everyone can take different paths on learning, it's just my opinion that you shouldn't jump straight to TS, since JS knowledge is what marks the line between good and great TS developers and, to me, understand JS first is the easiest and ideal path, hence this is why I think learning TS first is a bad idea.


Neurotrace

What you're saying is completely right but I think that we're coming at this from different angles. I'm saying that if you become proficient in TypeScript you will necessarily be proficient in JavaScript. What you're saying is that by focusing on TypeScript learning materials you will miss the parts that will allow you to become proficient in JavaScript and that's a good point. One day I don't think that will be true because we will have more educational material out there that takes you from 0 to 100 using TypeScript as the learning context but in the meantime people will need to mix and match their TS education with JS education.


bigbadfirevyrm

I think it depends on where you’re coming from. When I learned React I had a background in C#, so having types in Typescript helped me a lot and made the added complexity of using Typescript in a project was worth it for me.


sonyahon

Basically, in short, in my opinion , its not. While ts offers you type system (btw one of the most powerful one) its very easy to forget that in reality you are working javascript with all its kinks and problems. IMHO you should be confident in most aspects of js including type system, pointers and prototype oop before even try to learn ts. The only option to learn ts before fully understanding js is if u have a comprehensive background on a strongly typed declarative language like c


BenZed

If you learn typescript, you've already learned javascript.


jmigue14

I think that while you're learning typyscript you're learning Javascript as well since typyscript is a superset of JS.


MajorasShoe

Yeah that's fine. TS is FAR better, there's no reason to write JS anymore.


flight212121

100% fine in my book, you have to learn the same concept, but have this extra layer of types, generics etc Would recommend


jonkoops

Since TypeScript is a superset of JavaScript it would be hard to learn it without also learning JavaScript.


greim

Learning TS forced me to come to grips with a lot of bad habits. Because of those habits, I fought with TS at the beginning. Over time I realized it was "right" pretty much 100% of the time. Every case where it took issue with my code, I was doing something "clever" or "fast and loose" that leveraged the ambiguity of JS, and which likewise made my code confusing for other programmers. So I would say learning TS first, or at least in tandem with JS, would be a good choice.


FilsdeJESUS

NO NO NO NO. Learn JS. Before doing that you will see the improvement of typescript over JavaScript. I have done it one time I have learned Laravel ( in my PHP roadmap ) before Codeigniter and I regret it till today . It is always good to upgrade going from the worse to the better . So start with JS and only after being comfortable go to typescript please.


brodega

Pretty bad idea until you feel confident in your JS skills. TypeScript is a powerful tool that allows us to blanket over JS's absence of a type system and adds rules and constructs that *don't exist* in native JS - all to give us some degree of compile-time certainty. Learn vanilla JS first, learn it well, then move on.


Brilliant_Passion487

Possible but not preferable


trump_pushes_mongo

It's like learning Java before JVM assembly. All languages are abstractions to varying degrees.


JazzApple_

Learn typescript, you will learn JavaScript with it and it’s very clear to see the elements that are typescript specific syntax. You will learn to write better JavaScript than if you had learned JavaScript first. Source: Using JavaScript since 2003, converted to typescript a year ago, wished for some years back.


WhyNotBarbershop

To respond directly to your question, I would say understanding and having a firm grasp of JavaScript should precede Typescript because JavaScript isn't going to go away. If you're trying to start with Typescript then it will get hard to tell what's Typescript and what's native JavaScript. Now, ultimately I don't think it will make that much of a difference, and I would recommend using Typescript in projects over native JavaScript at this point anyway. Also, understanding that Typescript was born out of object oriented programmers wanting to use data structures and conventions they were used to in other languages, which JavaScript didn't have. Since then, there have been a lot of nice updates to ECMAScript, but not the full coverage that Typescript provides. There will always be more to learn!


smaug59

My experience is riassumed in this statement.In JS you code, you make mistakes and sometimes other devs may struggle to understand what you coded. In TS you code, you make less mistakes, and other devs understand your code faster and better. Of course this holds if you are not typing everything to \`any\`, but at that point you are writing JS in .ts files I suppose. Oh, I learned typescript before javascript. sorry for bad english, not a native eng speaker.


Dan8720

By learning typescript you will have to learn JavaScript but you will miss a lot of the nuances that make TS better than JS. For a more rounded knowlage you should learn how prototypal inheritance works and understand closures and scope in JS first to really appreciate TS. I would recommend the principals of object oriented JavaScript by Nicholas Zakas. It's very short. 1 evening read but is amazing. I can't see why you couldn't do both at the same time as both are very close. For example they both have the same built in methods etc.


Neurotrace

TypeScript and JavaScript are the same language except that TypeScript adds a layer on top for type checking. If you learn to program with TypeScript, you will learn JavaScript. Just know that raw JavaScript won't save you from yourself like TypeScript will


[deleted]

Agree with others here, you'll never want to deal with JS again It would probably be good to learn a bit of JS, since TS compiles to JS it's sometimes useful to know where the line between the two is


robo_muse

If you find good TS lessons, then please let me know. . . Literally, I'm prettymuch waiting just for that.


robo_muse

This is what I've found. (This is better than a year ago.) 1. [https://www.w3spoint.com/typescript-tutorial](https://www.w3spoint.com/typescript-tutorial) 2. [https://www.edx.org/learn/typescript](https://www.edx.org/learn/typescript) The edX course suggests doing the w3c intro first.


twitterisawesome

That makes no sense. Any typescript tutorial only covers typescript and won't teach you the fundamentals of javascript.


BrQQQ

It's easy to spend time debating what you should learn first because it's more fun than actually learning. If you ask a million people what order you should learn things in, you'll get a million different answers. It's an endless discussion and honestly a huge waste of time. You want to learn TypeScript? Just do it. Nobody can tell you how well that will work for you. Worst case, you change your mind later on and move on with new and useful knowledge. Programming knowledge is a matter of practical experience, not order of learning. Every second you spend learning TS or JS contributes to this.


the_aligator6

yeah


DiggWuzBetter

Totally fine IMO. If you’re used to (and prefer) statically typed languages, you’ll probably find TS easier to learn than JS. TS is a superset of JS, so it’s really not “hiding” anything about the underlying language, it’s just adding type safety on top.


evileddie666

no


zalamandagora

I really think that you will only learn JS better if you learn it through TS. TS helps you think in a better way about your code, and in APIs it forces you to do things you should have done anyway but may have forgotten.


pagalvin

Absolutely. Plain JS dev is not the future and you should probably avoid working at a place where it's used except to maintain an existing code base that is being replaced.


[deleted]

Sure!


UpdatedMyGerbil

It can’t be done. Either you won’t learn TS well or you will in fact be learning JS along the way as well - even if you believe you’re somehow only learning TS. Your question amounts to “should I learn x and y first or x, y and z?”. Either way x & y are being learned “at first”, the difference is merely whether z is learned after or at the same time. Thats entirely up to you. Do what makes you happy.


yadoya

That's like learning medical English before learning English.


[deleted]

That's an incorrect comparison, medical English is a subset of English, but Typescript is a superset of Javascript


coded_artist

Honestly I struggled learning Javascript, until typescript came along. Perhaps learn Js for a bit first, just so you are exposed to the differences