DEV Community

Cover image for Future Javascript: Types may finally be coming to Javascript

Future Javascript: Types may finally be coming to Javascript

Johnny Simpson on April 04, 2022

With the promotion of Type Annotations to Proposal Level 1 Stage, Javascript is one step closer to being a more strongly typed language. Let's dive...
Collapse
 
jonrandy profile image
Jon Randy 🎖️

Those type annotations have no place being processed by the JS engine. That belongs in a browser extension and nowhere else

Collapse
 
ivan_jrmc profile image
Ivan Jeremic

They are not being processed, the engine looks at them same as it looks at // comments which is good because we don't need a transpile step.

Collapse
 
jonrandy profile image
Jon Randy 🎖️ • Edited

So what on earth is the point of them? Or a proposal? Or anything? If they are effectively just 'comments'?

Thread Thread
 
ivan_jrmc profile image
Ivan Jeremic

The same point TypeScript has, Typescript Types are also not used in the JS Engine they help you while Developing.

Thread Thread
 
jonrandy profile image
Jon Randy 🎖️ • Edited

To make the engine ignore the type annotations as if they were comments will require changes to the JS engine (yes, processing). These are changes that only benefit TS developers whilst developing. Adding extra load to the JS engine just for this purpose is plain stupid.

This belongs in a browser extension - which would essentially just be moving a compile-like step into the browser instead of it happening server side.

Let's not let the overblown tooling and complexity that has infected the JS development process in the name of "developer convenience" start dragging down the client side too.

Thread Thread
 
ivan_jrmc profile image
Ivan Jeremic

You clearly have no idea, browser extension wtf? LoL

Collapse
 
pengeszikra profile image
Peter Vivo

I use hybrid TS / JS application, so if JS also use other type declaration that is will be really confusing. By the way TS type definitions not by accident complex for handle ( near ) all type definition. I think that complexity handle in real time just slow down the browsers.

Collapse
 
leob profile image
leob

So they're sort of duplicating the work done by Typescript, or what? Now we'll have even more confusion and fragmentation (some people using full TS, others use "JS-the-poor-man's-TS"), or am I misunderstanding things?

 
ivan_jrmc profile image
Ivan Jeremic

If you can do everything in JS there is no need for TS to exist. (Which I hope will happen)

Thread Thread
 
emmanuelthecoder profile image
Emmanuel Aiyenigba

Well, you can't. Or atleast not yet. Let's see what the future holds.

Thread Thread
 
emmanuelthecoder profile image
Emmanuel Aiyenigba

Time shall tell!

Collapse
 
emmanuelthecoder profile image
Emmanuel Aiyenigba

Typescript has come to stay.

Collapse
 
ivan_jrmc profile image
Ivan Jeremic

Nor really the people behind TS made this proposal.

Thread Thread
 
emmanuelthecoder profile image
Emmanuel Aiyenigba

I know. Types coming to JS is never the end of TS.

Collapse
 
hellojavascriptinfo profile image
HelloJavaScript.info

First I would like to address the elephant in the comments below. Most people who write plain old Vanilla JavaScript have nothing to worry about when it comes to a type system in the browser. You can remain calm about these changes in the browser. Type systems are useful when you are in development mode. You will not see types if you don't use them and if you do you have a much better developer experience. Here is my rule when I am developing an application. If I am working with a team then use types and if I am working by myself it's up to me. For those of you who don't like TypeScript then you should stick to what you know. However, the future use of type systems will become part of your day to day job if you work with large team. Get use to it...