3 ms·
You're kinda preaching to the choir here on HN, where many people feel the same way (not me personally, but generally speaking). That's fine, you can still use
by solardev 2y ago
You're kinda preaching to the choir here on HN, where many people feel the same way (not me personally, but generally speaking).
That's fine, you can still use Typescript with vanilla JS and not use any frameworks. Typescript shouldn't result in unnecessary code in production. It's just developer hinting during dev, but it gets removed during the build.
If you don't want to use a build tool at all, you can also use JSDoc formatting to provide some basic type and parameter information. Your IDE can still use that to provide hints.
It's totally up to you. If it's a solo dev codebase that only you ever see and you don't want to type it, then don't :) If you do end up wanting to share the code though, Typescript makes it a lot easier for other devs to use because they can instantly see when something is wired up wrong during development.
- Farer 2y agoI totally get what you mean. I'm also someone who finds compiling or building unnecessary when running JavaScript in the browser. It feels like we end up studying and dealing with issues that aren't directly related to actual development. I really like TypeScript as well. In fact, the back-end of this project is developed with .NET 8.0, and since TypeScript gives off a similar vibe to C#, I genuinely enjoy using it. I've already made the web front-end open source: https://github.com/Farer/breathingworld_client_web https://github.com/Farer/breathingworld_client_web Even though I’m using Vanilla JavaScript for personal preference and to minimize performance issues, I’ve also been concerned about potential challenges when collaborating with others in the future. I’m currently looking for collaborators, but it hasn’t been easy. Honestly, I might be going against the trend, but that’s a possibility I’m aware of.
- wruza 2y agoIf you wanna try ts frontend with no friction, start with Vite, a modern dev and build tool for frontend. It’s mostly zeroconf, everything just works.
- Farer 2y agoOh, I briefly looked over Vite but haven't actually used it yet. This is a good opportunity to seriously take a look at it. Is the final HTML and JavaScript code generated clean and without unnecessary bloat? As always, minimizing the resources that a first-time visitor has to download is one of my main goals as well.
- wruza 2y agoVite minimizes prod builds by default. Generates three bundles, html, js, css. Plus sourcemaps. Can’t tell if any of it can be turned off. As of bloat, it depends on your tsconfig (ts part, not vite). If you set ts up to modern standards (es20xx), it emits code basically verbatim. If you’re gonna support ancient browsers, it will have to emit some es-to-es boilerplate. See tsconfig.json reference for details. Everyone - editor/lsp, tsc, vite, eslint - look into this file. Typescript’s general idea is to just erase types, but they added some es version practicalities cause otherwise that would create a whole “pipeline” yet again for a common use case.
- Farer 2y agoOh, I see. Have you used other frameworks like React or Next.js, Svelt and so on ? If so, do you think Vite has clear advantages compared to those frameworks?
- wruza 2y agoVite is a “bundler”, a dev/build tool. You can vanilla js with it as usual. It takes your index.html and sucks in a whole dependency tree to shake it and either produce a production bundle or run a dev server. Being aware of ts, vue, react, sass, etc out of box is its bonus points. Vite vs React vs Next is crates vs oranges vs boxed oranges. I know react but never touch it. React, vue, svelte are “state management”. I’m using mithril.js with POJOs for my frontends. Vanilla everything gets messy in interactive apps, and I come up with a poor man’s mithril usually, then rewrite for it.
- Farer 2y ago