Can I be happy writing TypeScript for the browser?...
# present-company
a
Can I be happy writing TypeScript for the browser? I made a Node project that imports Three.js, and Browserify takes almost four seconds to bundle it every time I make a change. Is this how it’s done?
i
Why are you using node to build a web project?
a
I don’t know, the TypeScript doc said ‘npm install typescript --save-dev’ and I just kept going 😂
d
This is why people keep reinventing web tooling! E.g. https://esbuild.github.io/
I think honestly the issue here is three.js moreso than typescript 😞 (I say this as someone who uses both a lot)
@alltom if you haven't done much frontend before... my condolences. I don't think I know of a way to use TypeScript without having to wade into the JS tooling ecosystem quagmire 😕
j
Modern web tooling is, famously, a shit-show. I empathize with you if you’re new to it, @alltom! But, fwiw, I’m used to more like a 1/4 second latency between saving a file and seeing an update in the browser. That’s using Vite, but an older Webpack-based setup wasn’t that different. So I think you can do better than 4 seconds. Most build systems have a distinction between a production build mode and a hot-reloading development mode. Do you know if you’re using the development mode?
i
I can second the Vite recommendation as a low(ish)-friction way to get started with TypeScript.
j
Have you considered bringing in Three.js from a CDN and writing plain JS code? Despite my many complaints with JS-as-a-language, I find this the most civilized way to interact with that ecosystem in the browser.
d
I cannot understand why Typescript even exists. Javascript is Javascript. I suspect it's company architects trying to impose some sense of control over developers.
I've seen the sad decline that happened with JS from nifty ecosystem to quagmire happen with Java before it. Something around architects and pay rates seem to be the influences.
t
@Duncan Cragg If you want to build a website, and you prefer using static typing, isn't that a good enough reason to use Typescript? I personally use it. I don't love it, but I prefer it over plain Javascript.
i
CoffeeScript: exists
Jokes aside — JS has long had a culture of choose your own syntax (and, to a limited extent, semantics) with things like Coffee, JSX, ClojureScript, and now TypeScript. So I think it's fair to say JavaScript is not just JavaScript — there's the browser and node runtimes, there's the transpiled languages, there's the npm ecosystem, there's the framework-centric culture, and more, all of them different, all of them opt-in, all of them desirable and offensive.
TypeScript is for the folks who want to build on those JS runtimes (and accrue all the benefits thereof) but also have the development aid of static typing. What more need it be?
a
That's all I want it for. I've maintained large JavaScript code bases, and the TypeScript ones were easier for me. ¯\_(ツ)_/¯ Vite is great! Thanks a bunch!