Jump to content

Scared of Typescript


Pryme8
 Share

Recommended Posts

So I am doing research to get ready to start working in typescript (damn you guys) and the more I read the more I am becoming intimidated.   I have not found a good resource that makes sense on the nuances of TS vs JS does anyone have any good sites they can point me too that they used because the ones I am finding on google seem to all be gibberish.  Im sure just like myself some have been putting of contributing do to the fear of just doing it wrong and submitting a PR that is not correct.  I have read the contribution guide on pixelcoder and am confident in git and node, but still have no clue of the basics of TS or how to actually develop with it.

Some of the gaps I have are how does TS build into JS become functional on a page?  Do I need to manually run build commands and then include the built source into a page?  What is the best IDE for TS?  Is it hard to transition or will it be more clear once the dev environment is set up and I start hacking?   

I am like really really intimidated by this whole concept for some reason which is dumb because I have never had a problem learning a language in the past but this one seems to hit me in all the wrong places and because of how wired my brain is for JS it seems like I may have more trouble with this then others... like cant teach an old dog new tricks kinda mentality...

Any advice/resources that anyone else used to make the transition would be appreciated!

Link to comment
Share on other sites

At the basic level you can just code exactly like you do in JS but you can also specify what type of data you would expect in a function parameter or variable. Have you ever done a strictly typed language before, like c# or Java?

Lots of the 'gibberish' on using typescript comes from its association with angular 2/4, which is a library for developing front end web applications. You don't need this to use TypeScript at all.

The other side of TS, and more importantly for me, is the more 'classical' implementation of classes. I have worked with a number of languages in the past and c#'s syntax is my personal favourite. TS makes JavaScript like c#. Again, if you have done anything in OOP before, then you will pick this up quickly.

I brushed up using this course https://www.udemy.com/understanding-typescript/. Don't pay full price though you can get codes to get any udemy courses for $10. PM me if you decide to go with the course and need help getting it.

Link to comment
Share on other sites

It was a big jump for me to convert my game from JavaScript to TS and I did doubt the decision briefly during the process.  There is some extra syntax that takes some getting used to and some things may even not compile, but what I found was that the code was much more readable and runtime errors were found at compile time.  ie: declare an interface instead of coding properties/methods by convention.  I am absolutely sure that the weekend spent converting my project to TS has been saved over and over.

Using TSLint will help you get everything compiling and give good hints.  I'm using webpack and ts in watch mode like b10b also.

I learned TypeScript mostly from the TypeScriptLang website.  For example, start adding types to the parameters/return values of your functions and your code will show it's intention more:
https://www.typescriptlang.org/docs/handbook/functions.html

Link to comment
Share on other sites

I confirm... TS is worth it, just by the time saved in error detections

And it's quite simple. I would suggest you not to try learn everything from tutos, angular examples, etc but by just reading the BJS source code. That's why I did : get some BJS class, read it, modify it, compile it. That's so simple.

VSCode is the definitive tool for this : working with TS out of the box, compile on save, internal line command. Trust me, I'm a Linux user, so you won't hear me say much good about MS products very often ;-)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...