DEV Community

loading...

JavaScript or TypeScript first?

koreymoffett profile image Korey Moffett ・1 min read

I have some JavaScript knowledge and lately I’ve been seeing a lot of talk about TypeScript and how amazing it is(I’ve never used it so I’m not sure) is it something I should learn before or after JavaScript? Or do I even really need to learn it
(I would like to do web development)

Discussion (17)

pic
Editor guide
Collapse
shadowtime2000 profile image
shadowtime2000

Learn it after Javascript. All Typescript is is an extension of Javascript to add some static type checking to avoid runtime errors. You don't need to learn it at all, in many cases Javascript is just enough. When you have something that is a little more complex with some messy code you may want to look into Typescript then.

Collapse
sumodevelopment profile image
Dewald Els

I would like to echo this statement. JavaScript should be the foundation web developers learn. Before react, angular, Vue, Svelte (insert tomorrow’s new framework) and even before TypeScript.

Understanding the fundamentals will make you a better developer in any framework 💪

Collapse
koreymoffett profile image
Korey Moffett Author

Thank you, I will keep that in mind.

Collapse
davidjones418 profile image
David Jones

If you write JS in VSCode or another editor with similar capabilities, then you are already getting a lot of benefits from TypeScript. You can jump to definition on web APIs and libraries that you’re using to see how the underlying types were authored, and try typing some of your own JS using jsdoc to see how you feel about types.

It might give you enough extra confidence in the code that you’re writing that switching to TS is worthwhile, you might be happy just documenting JS with simple types, or you might prefer the simplicity of writing JS without any kind of type system. I don’t think any of these is the wrong path, all are valid approaches with many proponents in the JS community.

Collapse
patarapolw profile image
Pacharapol Withayasakpunt

Don't forget to use // @ts-check, though.

Anyways, having to always write interface in @typedef is hell.

Collapse
davidjones418 profile image
David Jones • Edited

Yeah, if you get far beyond simple types in jsdoc it can get really messy and I tend to move types to a .d.ts file, although by that point I’m basically writing TS without a compile step.

You still get the autocomplete benefits of using type definitions without @ts-check, but you can leave some of your code untyped if you’re not concerned about correctness.

Collapse
jwp profile image
John Peters • Edited

If you learn Typescript first you will automatically know both. The only difference in getting started is whether or not Type annotations are used. For example:

//typescript and javascript are the same here, in both cases test is a default type on any
let test;
//this is typescript saying that test is a string.
let test:string;
Enter fullscreen mode Exit fullscreen mode

Of course , later on there's other advantages to use Typescript but that's a different topic.

Collapse
davidmaceachern profile image
David MacEachern

Have you looked inside the node_modules folder?

Collapse
noprod profile image
NOPROD ☄️ • Edited

Don't scare him with this folder haha

But yes you need to check :p

Collapse
patarapolw profile image
Pacharapol Withayasakpunt

Know some JavaScript; but consider not only TypeScript, but also something else, like Babel/Flow, Kotlin/JS or Transcypt; or any other variants.

TypeScript is not the only one.

Collapse
zenbeni profile image
Benjamin Houdu

TypeScript has more features and of course types, can be used in the same environments as JavaScript, so no downsides to use it in place of JavaScript except a more complex build pipeline. It adds more compile checks, and better maintainability in the long run, which is something so important for big projects that are going to live long.

Java developpers for instance love TypeScript more than JavaScript for most I've seen. The Deno runtime supports TypeScript natively, Terraform CDK for TS, Github actions in TS, it is going te be first citizen in many techs now.

At the end of the day, if you get used to use types, I personally think you would not go back to JavaScript once you use TypeScript.

Collapse
koolkishan profile image
Kishan Sheth

Master the fundamentals of JS first. Then search why to use TS. If you feel that TS would be beneficial to you then only learn it. At the end TS code get's compiled to JS only.
JS => Javascript
TS => Typescript

Collapse
janseniter profile image
Erick Jansen

JS first, TS later.

Collapse
onurgumus profile image
Onur Gumus

Use F# instead: fable.io/repl/ better than both.

Collapse
tehaisperlis profile image
Hazmi Irfan

Learn Javascript first so that you know what problem TypeScript is trying to solve.

Collapse
jonrandy profile image
Jon Randy

JavaScript first, TypeScript never :P

Collapse
zhnedyalkow profile image
Zhitomir Oreshenski

Js is a good start, basically vanilla js I recommend.