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...