4 ms·
TypeScript is 'not worth it' Svelte switches to JavaScript and JSDoc
- garbagecoder 3y agoI avoid TypeScript because I already feel the tidal forces on me emanating from Redmond. We are currently working on an education app in C# and it’s simple and delightful to do it and our front end is so easy to do. I also kind of like Typescript too, but as the author here points out, then you’re married to this tooling and … all of these autogenerated files. So for me I guess I’m saying the threshold is lower just because I already feel like I need to keep some diversity in our codebase.
- fullstackchris 3y agoand you dont think a framework like svelte is autogenerating files? all of these frameworks have some sort of build / generation step
- fullstackchris 3y ago[flagged]
- garbagecoder 3y agoI didn't downvote you despite the presumptive and condescending tone you took with my comment. Maybe that's why. All I said was I don't want to use only Microsoft stuff on any one project, I never said (a) I didn't like TS or (b) other frameworks don't autogenerate other files. You zeroed in on that one part.
- moogly 3y agoSvelte even has a compiler.
- jakelazaroff 3y agoI think a lot more is being made of this than it deserves. Here’s Rich Harris (Svelte creator) commenting on the last post about this that made it to the front page: https://news.ycombinator.com/item?id=35892250 https://news.ycombinator.com/item?id=35892250
- solarkraft 3y agoExtracted: > we are not abandoning type safety or anything daft like that — we're just moving type declarations from .ts files to .js files with JSDoc annotations. > As a user of Svelte, this won't affect your ability to use TypeScript with Svelte at all — functions exported from Svelte will still have all the same benefits of TypeScript that you're used to > Our commitment to TypeScript is stronger than ever
- gg-plz 3y agoThis headline is misleading to the point of being a lie, despite the body quoting the part explaining why it's misleading. Really bad. Author, OP, or Dang/mods should edit. Dupe of https://news.ycombinator.com/item?id=35892250 https://news.ycombinator.com/item?id=35892250 They're not changing away from TypeScript. They're changing from the TypeScript-style syntax for inline type annotations to the JSDoc-style syntax for type annotations in comments. They're still using TypeScript for type-checking, but now the source code can also run as-is. Dupe at <some URL>
- rektide 3y agoPrevious submission[1], which author rich_harris commented on[2]. He has a great breakdown of pros & cons. [1] https://news.ycombinator.com/item?id=35891259 https://news.ycombinator.com/item?id=35891259 [2] https://news.ycombinator.com/item?id=35892250 https://news.ycombinator.com/item?id=35892250
- deleted 3y ago[deleted]
- z3t4 3y agoCan anyone show an example of before and after ? eg. .ts vs JSdoc
- noahtallen 3y agoJSdoc syntax looks like this: /* * Function that adds * @param {number} a One number to add * @param {number} b Another number to add * @return {number} The added numbers */ function add(a, b) { return a + b; } Ts syntax looks like this: function add(a: number, b: number) { return a + b; } You can use JS doc in TS as well, to document all the values. You just don’t put the types in :)
- jchw 3y agoUnfortunately as far as I can tell that headline isn't really a very good summary of the situation, nor a generally accurate statement. Svelte wanted to ditch the need for a build step in testing. Most library authors already tolerate having a build step for multiple reasons, and have no need to go this route. If your builds are too slow, you'd just use a fast compiler like esbuild and reserve the tsc pass for CI/tests and local IDE type checking. (There are still some advantages of not needing a build step, but IMO most people don't mind it as long as it's fast.) If JS had a type syntax, this would be no issue at all. Unfortunately, who knows if that'll ever come to pass. As far as I can tell the Svelte developers are not claiming at all that you should abandon typechecking, which is what a lot of people seem to be reading out of this.
- user6723 3y agoSome of us who were working on lots of Node/Deno projects had already moved on to ReScript, and I would be touting what a great step forward ReScript is away from TS and JS, but a team I am on agreed to attempt fullstack dev with Rust and htmx with very light use of ReScript for the frontend. Since then this has been our stack and one I go to for personal projects. One of our team members is looking to replace the remaining browser-side ReScript portion with Rust (WASM), so we will be pure Rust until we are ready to switch to Austral. https://rescript-lang.org/ https://rescript-lang.org/ https://animaomnium.github.io/what-austral-proves/ https://animaomnium.github.io/what-austral-proves/
- tobyhinloopen 3y agoI didn’t read the article but after having used typescript for years i got sick of it and all my new projects just use regular js modules with jsdoc comments and I don’t mind it at all.
- zeroCalories 3y agoI am a big advocate for typescript, but I'm sympathetic to the maintainer's concerns. I've had similar concerns about how I'm complicating people's build process by requiring a specific compiler. Not a huge deal for internal projects, but every org has their own idiosyncracies, and requiring typescript could become a huge pain point that leads them to drop svelte. JSDoc can work just as well without the headache, but I've found that text editors don't work as well with JSDoc type checking.
- o1y32 3y ago"Requiring a specific compiler" That happens every day in other languages. Lots of C++ projects require Visual Studio on Windows, sometimes certain other tools (e.g. https://winscp.net/forum/viewtopic.php?t=25209 https://winscp.net/forum/viewtopic.php?t=25209). Other projects expect you to use the official compiler, because almost nobody ever tried using a non official compiler with that project and how see how things would go. I don't know how it is a problem if TypeScript compiler is required (by itself).
- zeroCalories 3y agoI think we're talking about two different problems. You don't need to switch your whole project to typescript to use typescript, I'm just talking about the headache that comes from mixing something like vanilla js, webpack, closure compiler, and typescript. Vanilla js with JSDoc tends to play well with everything, so I think it's well suited for a library.
- deleted 3y ago[deleted]
- math_dandy 3y agoI would have titled this “.ts files are ‘not worth it’; Svelte switches to .js files and JSDoc.’
- PedroBatista 3y agoUnpopular opinion that might be due to being an old curmudgeon by tech standards: TypeScript, the ES's and TC39s are a mistake since the beginning and ruined JavaScript. The root cause of all this is "JavaScript sucks and we want to build big complicated apps with it" and by "we" I mean big software teams working at big tech companies earning a small fortune every year. If I have to write TypeScript, then I might just write Java or even C#, since it's a lousy copy of those languages. ( and yes, I say that very loosely ). The modern ES[insert number] classes are weak and out of place and the module system is a complete joke and disaster. Truly! those people were either on drugs or are playing a joke on the "design by committee" phenomenon. Yes, Javascript is not a great language, but it won not just because of distribution but also because it as made to be simple to pick up. Have any of these people watched a beginner and not-so beginner try to pick up "modern JavaScript" or TypeScript? Even Java looks like Basic in comparison!. Thank God TypeScript and ES6 won over Dash/Dart from Google, but god damn it what an hollow victory. As for myself, this old curmudgeon, I just stopped caring and ignored all of this frontend cesspool. Waiting/hoping all of this rots away.
- frodowtf 3y ago> If I have to write TypeScript, then I might just write Java or even C# You might just write it in an object-oriented way... but OOP sucks. > Have any of these people watched a beginner and not-so beginner try to pick up "modern JavaScript" or TypeScript? What are you talking about?
- PedroBatista 3y agoOpen notepad or notepad++, add a library, write Typescript, save and run it in the browser. Go!
- frodowtf 3y agoClone an example project -> npm start. I consider this point done then. Don't know how beginners would feel about writing gradle tasks though. Don't know if they can cross-compile Java to the browser as well.
- xavor 3y agoJSDoc make js more verbose than Java