Is Learning TypeScript A Waste Of Time?
Вставка
- Опубліковано 11 лип 2024
- TypeScript is quickly taking over JavaScript with more and more projects being built with TS each day. This may seem scary if you only know JavaScript, but you can actually start using TypeScript right now even if you have no experience with it. In this video I will talk about why you don’t need to learn TypeScript and how you can write TypeScript code in less than a day of studying.
🌎 Find Me Here:
My Blog: blog.webdevsimplified.com
My Courses: courses.webdevsimplified.com
Patreon: / webdevsimplified
Twitter: / devsimplified
Discord: / discord
GitHub: github.com/WebDevSimplified
CodePen: codepen.io/WebDevSimplified
⏱️ Timestamps:
00:00 - Introduction
00:29 - You get some TypeScript features even in JavaScript
02:16 - Basic TS Project
04:40 - React TS Project
06:21 - Large TS Project
#WebDevelopment #WDS #TypeScript
I love using typescript! TypeScript integrates well with React, with the type definitions and other tools which makes it a very good choice for building scalable React applications!
I'm able to shift a lot of data out of the Context API now because prop drilling isn't as insanity inducing with PropTypes
@@pan-galactic-gargleblaster Absolutely! :D
Do you even know what a scalable React application is? If you did you would realize Typescript doesn't make it scale rofl
@@troy5370 The delusion is insane
@@troy5370 exactly lol
For React projects with multiple components that should have strict property types to ensure nothing will break TS is essential and time saving..
You putting a fake type on a javascript variable doesn't ensure it won't break omg you people are brainwashed. At runtime it indeed can break and the type can be still changed. Typescript doesn't make Javascript magically unable to change type at will.....
andy please tell me some good project only in frontend so I can improve my resume
Make a crud app, with react, typescript, integrate it with fire base and go a step further and use redux to persist user login info in local storage. This will look good on your resume and 100% make you stand out from other candidates
@@abdiastar6451 If you do the above it shows your way behind the technology curve and learning obsolete patterns. Redux lol...Persisting that info in local storage is the most unsafe place to do this kind of work and would show the employer you know nothing about security and would compromise a project.This is comical
@@utkarshsinghalus3085n
Every time i re watch one of your video, i learn a new thing, Thank you for the amazing work
Great video. I was "forced" to learn ts as the project I was contributing to was written in it. I was kinda taken aback to see prop types are like 99% of the use case.
Very good topic! actually deciding on whether to learn ts
I'm a strong believer in type safety having programmed in C++ for over 20 years, which is a strongly typed language. It was quite unnerving to learn JavaScript, where variables can flip their type seemingly at will whenever it happens to be convenient. It seemed at first that I was programming in a fun house of mirrors. But I've resisted TypeScript not because it's scary but because my brain is a FIFO of limited size, and cramming too much into it at once will only cause other stuff to fall out the other end. Front end development for me is way too complicated and if it wasn't for Kyle and Kevin I'd still be in the weeds. But they've safely guided me through my first web application which is nearing completion. So I'm finally comfortable enough with JavaScript, HTML, and CSS that, although still not expert, I'm ready for new challenges and TypeScript will definitely be part of that.
The learning curve for web development and C++ is just so different. I feel like C++ is more complicated, but less to learn than web development where you have dozens of languages, frameworks and other tools to learn. This can be overwhelming.
have u tried TS already? sounds like you have a solid foundation of knowledge, you should really try it, at first you I'll feel like you're going a bit slower, after that you'll never look back lol
Interesting how a C++ with 20+ years of experience can find learning front-end unnerving. I always thought C languages (with the exception of C#) were incredibly difficult to learn. On the other hand, I used to love JS for everything as its freedom was unmatched... until I had to work on a medium project of my own with new frameworks I just started to learn, then I understood the "JS is the language that lets you shoot yourself in both feet before telling you that something might be wrong".
Pretty sure you'll pick this in no time!
Damn, I never used TS on my projects. Now I have the confidence to use TS. Thanks, Kyle!
Thank you Kyle, I was kind of scared with TS. But yeah the best way to build projects and eventually you'll get better at typescript. Thanks again :)
Great video!!! Thank you so much! I really love Typescript, and specially I love the initial philosophy which it born, helping a lot in development adding type safety... but I believe that Typescript miss the direction in some point! Crazy coded complex types like those that you indicate in the Firebase library is the part that adds unnecessary complexity and, for me, simply adds no value... only more cognitive load in large projects. When I see a type coded like that, having a hard time TRYING to understand what it does (specially when must be fixed because a bug introduced by another developer), is when I love the JS simplicity and readability, and return to code in JS, but using JSDoc (as other user posted) to enforce types. Once again, thank you so much for this video!!
I'm java dev. recently I'm trying to do front end staff as well. As my programing background is on strict typed language, ts is relieving language for me
Could you please make a video to show how to make a webextension in typescript? I had problems with types for working with a mutation observer in a content script to change the appearance of a video player to make it more accessible.
Thank you very much. Just to clarify please what are the 3 things?
how to implement typescript on existing react project component by component , instead of all at once ?
Having a strong 20 years+ experience in both Java & JavaScript I would say TypeScript makes JavaScript more Java like.
And it adds a additional code and kills all advantages of JavaScript
I’m a big fan of typescript. I use the T3 stack and having types for everything makes things easier in a full-stack app imo. I can’t imagine going back.
It took just one small project to convince me to never go back to JavaScript. TS drastically cuts the debugging time (depending on the project, of course). But, I think it's understandable, since I do some C# stuff, so maybe I'm just used to static typing. I like when IDE is yelling at me :)
your final phrase is a whole kink
I am in love with tutorials on JS when you need to use the tool on TS. I love it
querySelector is a generic function in react, you can cast it as a div like querySelector('selector');
Does the same but looks a bit cleaner 😉
new to me
typescript is sooooooo useful, at work, we switched over to using typescript for all of our projects. and we have definitely lessened our debugging time. BUT; can you do a crash course on how to use usecontext with typescript.... its complicated.
Imagine redux, I'm having a hard time with it.
do you publish your firebase types anywhere?
I'm trying to require an npm module I use, but require has to be installed? After this, the node_module doesn't even work, so what's going on? Does typescript have their own module store? Too complicated for me to learn, when I can try jsdoc comments.
Love your content
I don't use typescript on the front-end, only on the back-end. The question I ask is, if you use the typescript just to type the components, why should you use the typescript that brings another compilation process, if there is the PropTypes of Javascript?
typescript makes it easier to refactor and you can't use prop types to type an api request afaik
What are your thoughts about the difference between type and interface? Is there any situation when is better to use interface rather than type, thanks!
- interfaces can only define objects
- With JavaScript, in OOP, when you want to do inheritance it is not possible to extend more than one class. But with the reserved keyword "implements" in Typescript, we can add several interfaces to a class
- Unlike `types` interfaces can be redefined, properties are thus merged
This is what comes to me. Sorry if it's not clear, but English is not my native language
really encouraging!
4:02 what is the point of the # in front of the variables?
I've kept trying but giving up on typescript because of problems like your firebase issue. Always one or two things that require extremely complex custom type definitions. If one thing doesn't work, you can't complete the project. Would love a tutorial showing how you would approach something like your firebase problem.
There is always a solution without having to abandon TypeScript completely. In the beginning it is extremely annoying to work with TS, but once you get used to the common TS compile errors that you get, you quickly learn how to fix them.
The code may be more verbose, but the main benefit is that you catch errors in compile time rather than runtime. The goal is to make things fail early.
These issues can happen. Check the errors you are getting, and then debug any code related to those issues, if you can’t figure it out, a simple google search would never hurt, if that doesn’t work, then you may be able to ignore types for some lines of code. I wouldn’t recommend this unless there was no other choice, and the code with type issues you have a full understanding of how it works and it has already been tested thoroughly.
Yeah while these guys are trying to figure out the TS syntax and the new FOTM TS changes I would have already shipped and made $$$$. Go tell your boss it takes you longer than most developers because your writing in two languages that helps no one but makes you feel good inside
@@troy5370 I work in an organization which understands the complexity of software engineering which isn't just about shipping fast. Secondly, skilled engineers are not slowed down by TS as you are assuming. Rather, TS helps them.
How long until TypeScript is integrated into Vanilla JS?
99% of typescript is javascript, the other 1% is learning how to create super convoluted types to get the best autocomplete
We use it to help cast our responses from a rust backend. Serde sends a specific object, and me have matching types to help determine the response without validation
My main problem with typescript is, once you go typescript, you can't use normal non typed javascript library out of the box. You have to do some shenanigan to make it works.
Kyle: Last week end of React
-Now end of Typescript
One year later
Kyle : End of developer 😅
here after devin , how accurate prediction
This almost seems like writing VBA code with "Option Explicit" turned on. Without it turned on, it could be a nightmare to troubleshoot if there are bugs.
I have a Love/Love relationship with TypeScript and I have have been pleased with the Love/Love relationship I have with NodeJS and VsCode I am probably just a rare example of people who is completely in love relationship every one else seems to have been forced into an arranged marriage like an unwanted wedding 💍 I feel lucky to have this passion when I read the comment and read all the horror stories of people who have no choice but to learn TypeScript never stating learning something was so easy… it is obviously 🙄 just because it doesn’t get complicated until you get hooked it is just a terribly complicated language sometimes but it is just so easy to get the basics of it…
Thanks for giving me the confidence to learn typescript and convert my projects to typescript
Hi kyle
can i ask you a question ?
after learning js should i learn Vue or React ?
Personal choice. More job opportunities in react, but you might find a shop that uses Vue takes developer wants into account more than one that sticks to the status quo.
@@piffeSo i'm gonna choose react Thank you so much
I would choose React for the reasons already mentioned plus the React community.
Svelte is better than both, more jobs in react
Hey Kyle, huge fan of you..Please create a video on Apollo client refresh token flow using asynchronous function to fetch access_token
Hey Kyle, in your opinion is it better to use a type or an interface?
Typescript says to use interfaces over types except for a few cases
I was also wondering why he use no interfaces.. just types.
@@goonswarm007, what's the advantage of using interface over types?
can I learn type script and skip java script. I'm worried I will need to know javascript for JSnode
I have a love/hate relationship with TS, strong typed code makes life easier for large applications but some of JS's power is lost in translation and TS could have a better implementation.
My one question:
All javascript libraries are obviously javascript friendly, but not all are Typescript friendly...
So won't building my project using Typescript sometimes limit which libraries I can use?
I know there are often type definitions for the libraries, but it just adds one more possible point of resistance, and I don't want to have to write type definition files for a library I could have just pulled in a used in normal javascript?
You can just include a declaration file (.d.ts) in your project and put `declare module 'module-name'` in it. That will let you use it without types. Everything will just be 'any'.
What library worth using doesn’t have type checking?
sometimes yeah you will add a library that doesn't have type definitions but at least for me it is very rare to do so and not worth to replace type safety just because of that one library. there are cases and cases, but 99% of the time i'll use typescript
Thanks for the replies guys. Makes a lit of sense then...
If a library doesn't come with type definitions, often times the community will have provided them separately and you can just 'npm install -D @types/librarywithouttypes'. The @types scope has types for hundreds of libraries.
LOVE BRO )) THANKS
4:20 Does not look like a function that RETURNS a function to me! But it looks like a function that ACCEPTS a function as a parameter. Easier to understand when you read the code below it, and you understand this is also conform how the Promise works. The resolve function is a callback, called by the Promise after finishing an asynchronous operation.
I can't imagine working on a serious project without type safety. Be it TypeScript or something else.
How to make catchy titles
le WDS:
I love TypeScript, I'm teaching my student TypeScript now.
For web development, I prefer TypeScript + SvelteKit instead of React (even I have more than 5 years exp in React).
well, fun fact i used smartphone to code and manage to create some simple useful website, and a few bots for telegram. i dont use typescript because there is no vs code on smarthpone yet :(
Love all of your videos, but is that a white Jackson Dinky behind you? You must like heavy metal 🤘
People new to TS like to complain about the extra steps with setup, having to add type annotations to function parameters, but it saves time in the long run. An insane amount of time. TS actually saves tons of time.
This is indeed true. You don't need to know typescript to be able to use typescript.
I just changed all my file extension from .js to .ts. Now I'm using typescript...
Now I just need to make my app work again.
Ngl typescript makes working on projects enjoyable, especially on the FR when frameworks, build tools, ect are constantly changing.
Aside, it’s worth it. Imo you won’t see the value of TS until you work with a large codebase on a team, build a real app into production and/or library.
It’ll provide you discipline and the compiler will help you catch errors in DEV vs pulling your hair tryna find the simplest error which you noticed at runtime.
But first learn JS before learning typescript. It’s now labeled as language but technically it’s just JS with static type checking (a superset of JS), so if you know JS TS won’t be anything crazy.
Peace and much love yal. And always keep learning and keep MOVING FORWARD.
I know it says it's simplified, but I feel like it might be worth it to explain that complex ts file you just glossed over at the end
Thanks!
It's bad engineering. Don't even worry.
Thanks for keeping it real
I just started my web development journey less than 3 years ago. I'm sticking to vanilla Javascript + React for the coming years. (With a hint of NextJS, hehe)
@@biggestthreattoyourexistence 😂😂
Don't. Switching to Typescript is a lot easier than trying to figure out React in plain JS, and it saves you a lot of time writing code. Benefits happens in less than a day.
@@biggestthreattoyourexistence It most definately is.
Simply TS is just JS +:
- Types, declared for data type safety.
- Generics : for modification of data inside Types.
I agree to an extent, but when you're using a library that doesn't have types, it is really really really really annoying. And until you end up having that problem, you really don't have anything to worry about. But I think that you may be underestimating how annoying that is for the beginners. I'm not sure how common it is for others, this happened to me on my first big project, So then I had to learn more typescript all at once.
Any decent enough library should have type definitions. If it doesn't, you might wanna switch to others.
@@tasin5541 Some choices aren't up to me lol
Thank you, Kyle.
I think it's actually cleaner to use generics with document.querySelector instead of casting it as a type.
document.querySelector('.whitespace') as HTMLDivElement;
Can you please do a crash course to explain what react developers need to know about TS? You are the best!
ua-cam.com/video/TiSGujM22OI/v-deo.html
YES PLEASE
If you want to do react with typescript, you simply have to know typescript, as you just write javascript in react. A better video request would be like what EXTRA stuff a react developer has to know about typescript, beyond "vanilla typescript".
He just told you lol
@@matija-ziberna I want this guy to explain TS because he has is good at it
The time you spend learning typescript will be returned to you in times in the process of coding later.
Yes. Just get started.
Man , that white Jackson in the back is dope 💛
Finally decided to learn TS, it slowed me down a bit at first but man, it was totally worth it.
@@bismuth00ado you even know what you're saying?
why you just use types and not interfaces too?
I learned typescript because of angular. Forces you to use. Good and bad and comes down to preference. Does not make you a better developer
Better developer, no. It makes your code less messier and more readable though, so that automatically tranapiles to a better development experience
I also personally don't like typescript, but it's very easy to learn. If you're already familiar with a strictly typed language, you can learn Typescript in a day. So, we should learn it so that it might be helpful in interviews or in companies where they use it 👍
if you think its easy you dont know ts good enough
@@andTutin you are assuming they only have prior experience with javascript and ignoring they could have already been using a statically typed language for years. don't be that person
thx
If you are coming from non typed languages like php or plain js, you first have to understand the difference between “hey it works” and “hey it will work long term”.
Learning typescript for javascript coders is juste 1 or 2 days... why dont just learn it...
Isn't it sad? We'd gone through entire circle from type-strict (Algol/C/whatever) to type-lazy (AWK/Tcl/whatever) to typeless, then type-specified again. I need some Ada code to relax. 😉
Having coded a lot in Pascal, C is only moderately typed to me, but I started with BASIC. So..., that was some crap... Anyway, yeah my journey was cyclic as you say. So when it came time to learn JS, having VS Code was all I needed to not make type errors. Now I am learning typescript so I can read other people's code. Lol.
@@albirtarsha5370 Do what you've said (in definitions) and do what you mean (in code). That's exact definition of assembly language. 😉
One of the thing that typescript scare me is that its ridiculously hard to understand syntax.
I had familiar working with strongly typed languages before like Java or C# or Go but I had never seen like such below
----
interface UseFetchOptions extends AsyncDataOptions, ComputedFetchOptions
----
☝this is from a fetch library within Nuxt 3 that I have been using recently. By the time I was debugging and try to understand it, I immediately refuse to continue digging after seeing that.
WE need advanced MERN/PERN TYPESCRIPT FULLSTACK app please
This tutorial has spurred me on to re-start my abandoned efforts to learn TypeScript. Thanks, Kyle
{2023-02-11}
I like when things yells at me what's wrong.
This is not about what I wanted to hear about TS and haloloyaa, no, this is always what I felt about Typescript and I was feeling a little odd from people that without any thinking just evaluate your ability to code in the FE based on ur knowledge of TS, I remember once I got rejected because one of my side-projects I was showing case its codebase in the interview was written in Vanilla JS. 🤧
Typescript is a must have
is TypeScript the Python of JS ?
The Java of JS
Typescript is a waste of time. All you streamers pushing this nonsense is a joke. Javascript is a dynamic language and you guys keep trying your best to force it to be compiled eliminating several inherit features. Typescript makes your code hard to read, is convoluted and they keep updating it putting more and more confusing syntax into it so normal javascript looks like a foreign language. The only thing your doing with Typescript is obfuscating source code because your used to a compiled language. Most of you streamers including you just use when you don't know how to type a complex type or object. Its a joke
Exactly. But sadly, just take any documentation for ie Tanstack Query/Tables and everything is written in TS.
I aggree with you 100 % and people are making dynamic language like javascript so limited just because the think it has to be.
It’s like when somebody found a fixed width and desktop only websites (best viewed in IE at 1024x768) and later discovered “responsivity” while in a fact whole web was responsive since the beginning.
I thing TS came for people coming from Java world because they had to specify the types and were nervous they can’t have anything like that in JavaScript, without realizing it’s not needed.
Like when somebody is looking for a shift for manual transmission car when driving automatic…
MIcrosoft pushes out money for people to make ads for it I guess. Just like they do with all their other crap software. They want us to use teams, sharepoint and other really bad software.
Not a fan of passing props to a react component and having to use Typescripts verbose syntax, when you're still deciding on exactly what you want/need to pass
Totally not a waste of time, but a must. Modern hire companies hite web develop preferring better knowledge of TS over years you've spent developing in plain JS.
Sometimes it feels like you made these videos for me personally. Are you watching me Kyle?
Too many people get turned off from TypeScript because they get into overly complicated things, or try to make weird types like using utility types like Pick. Just basic types and string unions is enough. The most complex thing you'd need to know is discriminated unions.
You get pretty much the same help from just using JSDoc. You won't get any assistance in terms of checking if the input types are actually correct, but in most cases it is entirely sufficient as your IDE will scream at you if you try to input something that isn't the desired value. So in order for JSDoc to fail you basically have to intentionally screw over yourself.
Or add // @ts-check at the top of the file
@@thecoolnewsguy That still requires documentation and you also need a tool to validate with to get maximum effectiveness.
Yes! I strongly feel so....i like pure js.
I have never considered something time I spent learning as a waste of time. If the alternative is some mindless activity such as doom scrolling or binge watching of some daft tv show, how could learning be wasteful? Always be learning, because, why not? It is not going to make you a worse person, I suppose
It's not a waste of time. It's super beneficial, and starting is easy. Everyone should be using it.
Ikr, my entire debugging process is 95% resolved because of TS
willl never go back :P
short answer: NO
long answer: NOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO
3 features of TypeScript to know so you can get 95% of the benefits when using it:
1. How to create types
2. How to assign those types to variables or arguments in a function
3. How to create and use generics
No. Saved you a video. Typescript is a sanity check, and to ignore a sanity check that will keep getting more popular is insane.
You didn't watch the vid. He wants you to use typescript. The video is about how typescript is usually taught/introduced to people, and how extremely counterintuitive that is. Theo of t3 made a similar video recently. Its an excellent point that all pro type safety webdevs should consider evangelizing.
The gist of the video is that you only need little TS knowledge to cover many TS use cases.
Thx guys, won’t watch the video, counting on yours tldv
@@abstrktionLair You need to reread the title
Typescript might be great (ONLY) for development of libraries that have public API's, even that there are many ways to do what ts do in that case without using ts. (libraries that have public API's was present far away before the invention of ts)
Other than this, typescript is, (in my opinion), a time and resource wasting .
JsDoc is fantastic....The code is shorter, more clean and very clear to every one.. No need to learn new modified js syntax.. You just define what you do think it needs to be defined
When using JsDoc... even the the beginners can understand the code .. and you will not find the beginners-non-sense code resulted after transpiling typescript to js...
You might face the case mentioned here in where your project uses a library that does not support typescript.. then you find your self in a situation where you need to rewrite those types in order to be able to use this library in your project other wise the compiler will start complain instead of compiling .. This is a complete time wasting
Also after transpiling ts code to js code .. all that ts disappears .. ts might help coders in some cases but not the final code users
Thats why recent shift in the development landscape has seen some developers and teams moving away from TypeScript and towards JavaScript with JSDoc. This shift has been notably championed by the Svelte team, who have decided to migrate from TypeScript to JavaScript in the Svelte 4 codebase.
Thats why Learning TypeScript is in fact A Waste Of Time
And Thats why JsDoc is fantastic
drop a like to ack , make playlist on devops or dsa
The fact that this is still a point of debate, says a lot about frontend devs...
Yes mostly says that some people mistake how bad they are at coding with language features or lack of them
Typescript is the same as Javascript but making use type more :)
Add typescript to your existing vue project and tell me how "awesome" typescript is
No, it's not. If you know JS don't wait and learn TS. It's actually really simple once you understand the basics.
There isn't even much to learn, it's still javascript... with types :)
you dont have to specificy what you return if you dont have a return in the first place, ts already knows its void
I just ended a 4 hour typescript course yesterday then i saw this video 😂
it won't go to waste
@@YuriG03042 yeah I was just shocked when saw the title
I’m a web developer since early days, when visual editors like Golive came and React, CSS or gosh, jQuery were nonexistent.
Anyway, I see a reason for Typescript to look for a job, as many job offers require knowledge of React and TS.
But personally, I write my code in JS (and JSX, obviously). Really see no need for typed language which is just another layer above JS. What for? I know what I’m writing and what comes into, most of the time I really need flexibility of non typed variables - ie. I have a few UI components and whole UI for ie settings is dynamically generated by what’s coming from API.
I think TS is just another thing making messy web development even more messy, making layer above layer of the layer. I get the concept, I know what typed languages are and why, but for web development where you really are not compiling something it’s not needed most of the time.
But who know, I’m probably old fart who doesn’t know a shit.
I get your point, sometimes I miss the dynamic nature of JS especially for data coming from the server, most of the times though, it is best to have a type safe approch.
You can keep the "dynamic" part of JS in your TS code though...
Ppl who find TS difficult, learn some basics & just jump right in and start a new project. Don't try to learn everything under the sun before starting a TS proj. You will be overwhelmed & It's really unproductive imo.
I dont find it difficult, just a waste of time, and another project that Microsoft is trying to ruin.
These comments are actually hilarious. I'm sorry guys, but if you're not using TypeScript, you're doing anything important with JavaScript.