Are you serious? How do you want to tell millions of people, "Hey please install this Browser Extension" if you really want to strip it out the place to do it is with a build script but not an extension in the browser lol.
So now you don't want browsers to accept this syntax? Make your mind up.
If TS developers want this syntax to be accepted in the browser as an aid to their development process (bear in mind that these annotations would be stripped in production code as it makes no sense to bloat the bundles with code that the engine will ignore) then it's not really a big issue for them to have a browser extension to allow it. The majority of people using the browsers are not developers, and this has no benefit to them whatsoever. There are already browser extensions to assist with React development and many other things - how would this be any different?
Unless JS actually implements type hinting using this syntax, then there really is no point modifying the JS engines to allow and ignore it, just to make the lives of a minority of browser users' lives easier.
The idea is that by putting types as comments into Javascript, we create a base for all strongly typed Javascript packages like TypeScript and Flow. That way simple types can be standardised. That's useful in itself, and also acts as a stepping stone to a strongly typed standard version of Javascript.
If we did that in a browser extension, then Javascript files would be invalid if we wrote them with annotated types and didn't have the extension installed.
If we did that in a browser extension, then Javascript files would be invalid if we wrote them with annotated types and didn't have the extension installed.
Yes, but this wouldn't be an issue as only developers would be sending this kind of code while they were developing, and they would have the extension installed. Production code would be back to normal JS. Presumably, you'd want to strip comments out of production code anyway... so types in comments, or types as TS syntax really aren't that much different. Swings and roundabouts.
Back to my original question - why the proposal if they're just going to be put in as comments? It would be farcical to suggest any actual implementation of type hinting in JavaScript would have the hints in comments. Also, wouldn't suddenly switching to putting types in comments (instead of the existing TS syntax) really piss off a whole load of TS developers? You'll end up with a mess - some devs doing it the old way, some day it in comments, or some unholy mix of the two.
It's simply because adding types to Javascript wholesale would break half of the internet. It would be a massive language change and would affect many components of Javascript. This change is a slow step in that direction, but it's non-committal. This can be implemented with no damage to already existing websites, and then tc39 can decide how to proceed from there. It's incremental steps.
The main benefit to this is of course it reduces the need to compile. Currently TypeScript requires you to compile your files into standard Javascript so they can be run in the browser or on a Node.JS/Deno server. With this, there is no need to compile anymore. TypeScript files are valid Javascript, the types are just ignored.
Therefore TypeScript can still enforce its rules and checks, and take out the compile step - meaning a faster overall development time for developers.
So the proposed change really affects TS then (making the compiler read type info from comments) - complicating development further (as mentioned above)? Honestly, all this faffing around would be gone if developers just accepted JS for the language it is, and work with it instead of fighting against it. I've been coding for 38 years (26 professionally) and - quite honestly, when I first came to JavaScript it was a breath of fresh air after working within the straitjacket of strongly typed languages.
That's why it's annotated, and not enforced. Annotated types mean you can still write your Javascript with types, and it'll be valid Javascript, or you can write it without types, to get the flexibility you describe.
Dude you seem a bit stoned reading from your comments. But I don't understand your unnecessary complain with a proposal for types in javascript. To be honest I agree with you to say that the type annotations would not be meaningful for the javascript language itself if "treated like comments", which actually is my complain here. Having type check in runtime would open the doors for something like multiple dispatch for functions which would be wonderful for implementing ad-hoc polymorphism and being able to simply overload functions... I really think you are either being unreasonable or just really stoned. This browser extension thing was hilarious...
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Are you serious? How do you want to tell millions of people, "Hey please install this Browser Extension" if you really want to strip it out the place to do it is with a build script but not an extension in the browser lol.
So now you don't want browsers to accept this syntax? Make your mind up.
If TS developers want this syntax to be accepted in the browser as an aid to their development process (bear in mind that these annotations would be stripped in production code as it makes no sense to bloat the bundles with code that the engine will ignore) then it's not really a big issue for them to have a browser extension to allow it. The majority of people using the browsers are not developers, and this has no benefit to them whatsoever. There are already browser extensions to assist with React development and many other things - how would this be any different?
Unless JS actually implements type hinting using this syntax, then there really is no point modifying the JS engines to allow and ignore it, just to make the lives of a minority of browser users' lives easier.
The idea is that by putting types as comments into Javascript, we create a base for all strongly typed Javascript packages like TypeScript and Flow. That way simple types can be standardised. That's useful in itself, and also acts as a stepping stone to a strongly typed standard version of Javascript.
If we did that in a browser extension, then Javascript files would be invalid if we wrote them with annotated types and didn't have the extension installed.
Yes, but this wouldn't be an issue as only developers would be sending this kind of code while they were developing, and they would have the extension installed. Production code would be back to normal JS. Presumably, you'd want to strip comments out of production code anyway... so types in comments, or types as TS syntax really aren't that much different. Swings and roundabouts.
Back to my original question - why the proposal if they're just going to be put in as comments? It would be farcical to suggest any actual implementation of type hinting in JavaScript would have the hints in comments. Also, wouldn't suddenly switching to putting types in comments (instead of the existing TS syntax) really piss off a whole load of TS developers? You'll end up with a mess - some devs doing it the old way, some day it in comments, or some unholy mix of the two.
It's simply because adding types to Javascript wholesale would break half of the internet. It would be a massive language change and would affect many components of Javascript. This change is a slow step in that direction, but it's non-committal. This can be implemented with no damage to already existing websites, and then tc39 can decide how to proceed from there. It's incremental steps.
The main benefit to this is of course it reduces the need to compile. Currently TypeScript requires you to compile your files into standard Javascript so they can be run in the browser or on a Node.JS/Deno server. With this, there is no need to compile anymore. TypeScript files are valid Javascript, the types are just ignored.
Therefore TypeScript can still enforce its rules and checks, and take out the compile step - meaning a faster overall development time for developers.
So the proposed change really affects TS then (making the compiler read type info from comments) - complicating development further (as mentioned above)? Honestly, all this faffing around would be gone if developers just accepted JS for the language it is, and work with it instead of fighting against it. I've been coding for 38 years (26 professionally) and - quite honestly, when I first came to JavaScript it was a breath of fresh air after working within the straitjacket of strongly typed languages.
That's why it's annotated, and not enforced. Annotated types mean you can still write your Javascript with types, and it'll be valid Javascript, or you can write it without types, to get the flexibility you describe.
So much yak shaving just to avoid adapting your mindset to using a language that doesn't have strict typing. I'll never understand it.
This proposal just feels like TS creators trying to dig themselves out of a hole that they created for themselves
Dude you seem a bit stoned reading from your comments. But I don't understand your unnecessary complain with a proposal for types in javascript. To be honest I agree with you to say that the type annotations would not be meaningful for the javascript language itself if "treated like comments", which actually is my complain here. Having type check in runtime would open the doors for something like multiple dispatch for functions which would be wonderful for implementing ad-hoc polymorphism and being able to simply overload functions... I really think you are either being unreasonable or just really stoned. This browser extension thing was hilarious...