Live data from Hacker News

Starting a TypeScript Project in 2021

metachris.com

161–170 of 190 posts

Re: Starting a TypeScript Project in 2021

#161

Ever since watching Jonathan blows talk "Preventing the collapse of civilisation", I've been mulling over things like this. It feels like we have this defacto set of commands you have to run to start a new Node/Typescript project, without much understand of what it does. Then you get complier or lint errors and then spend ages googling around for the answer that tells you to change a specific flag. This isn't a compl…

Is it really that hard?

> npm init > npm i --save-dev typescript

Add "build":"tsc" to your package.json "scripts" Add a tsconfig.json file

> npm run build

Finito - you've compiled a TS project to JS

Re: Starting a TypeScript Project in 2021

#162
post #106

Ever since watching Jonathan blows talk "Preventing the collapse of civilisation", I've been mulling over things like this. It feels like we have this defacto set of commands you have to run to start a new Node/Typescript project, without much understand of what it does. Then you get complier or lint errors and then spend ages googling around for the answer that tells you to change a specific flag. This isn't a compl…

I can't even imagine how painful it must be for a curious kid to get started in programming these days. I feel so lucky to have started with a little 8-bit computer with a built-in BASIC interpreter. You turned it on and could start typing your program right away.

A ton easier!

Sure, reading the two inch thick book on programming your TI-83+ was informative, but God help you if you got stuck.

Now we've got Scratch (visual programming), Arduino (push button C compilation!), and StackOverflow full of the answer to most any problem of stacktrace you encounter.

I don't have to read a tome for hours or wait a day or two for a response on a creeky BBS. Much easier.

Re: Starting a TypeScript Project in 2021

#163

Ever since watching Jonathan blows talk "Preventing the collapse of civilisation", I've been mulling over things like this. It feels like we have this defacto set of commands you have to run to start a new Node/Typescript project, without much understand of what it does. Then you get complier or lint errors and then spend ages googling around for the answer that tells you to change a specific flag. This isn't a compl…

Is it really that hard? > npm init > npm i --save-dev typescript Add "build":"tsc" to your package.json "scripts" Add a tsconfig.json file > npm run build Finito - you've compiled a TS project to JS

tsc doesn't bundle, or resolve imports, or transpile for cross browser though, does it?

Re: Starting a TypeScript Project in 2021

#164
post #90

Earlier quoted context omitted.

Honest question though, what abstraction do you use in place of React? I don't disagree that it's pretty obtuse, despite loving working in it. I miss being able to look up the source of Backbone.js and gain a real understanding of why something was happening. Maybe I'll get to that point in React, but it seems much harder to grasp what the source is doing.

I miss Backbone too. You could just step through the code in the debugger and it was so compact. With React you can’t really do that. It’s always following an error message saying: “look near this component” which is often deep in the hierarchy of some third party package’s component hierarchy that is transpiled into a single line with no source maps. I think there is a huge benefit in making things easy to step-thro…

That’s because Jeremy Ashkenas is a beast. Coffeescript started modern JavaScript.

Re: Starting a TypeScript Project in 2021

#165
post #36

TSLint is deprecated in favour of ESLint. See https://palantir.github.io/tslint/ .

We should let linters written javascript die IMO. ESLint is soooo slow. My hope is that the ecosystem will slowly shift to deno, and we just gonna use `deno lint` ( https://deno.land/manual/tools/linter , based on swc, written in rust) for linting from then on. What tslint does in 6 seconds, `deno lint` does in 0.2 seconds.

Hmm... a multi-threaded language would be nice. Always surprised when I see a single pegged core for eslint, prettier, or babel.

Workers are coming to Node... so soon.

Re: Starting a TypeScript Project in 2021

#166

Earlier quoted context omitted.

Is it really that hard? > npm init > npm i --save-dev typescript Add "build":"tsc" to your package.json "scripts" Add a tsconfig.json file > npm run build Finito - you've compiled a TS project to JS

tsc doesn't bundle, or resolve imports, or transpile for cross browser though, does it?

Using something like Parcel means it's usually as easy as adding parcel serve or parcel build to package.json and it handles the transpile, module resolution, bundling, tree shaking and hot reload for development.

Re: Starting a TypeScript Project in 2021

#167

I’m curious about the value of eslint for TypeScript. I’ve not really found myself wanting from the coverage provided by tsc.

To us, the biggest value is auto-refactoring the code to comply w/ styleguides and rules. There are many great rules in eslint that cover most known anti-patterns. For a start, just grab the .eslintrc.json from the microsoft/typescript repo.

We've hooked up "eslint --fix" and "prettier --write" to "npm run fix".

One command before committing and you comply with all our coding rules. Easy, peasy. We tie the combined checks into "npm run check", and run this in CI/CD, so we know only compliant code is merge. Check!

Most other lang tools _won't_ do this. Take PMD or Checkstyle for Java. They'll just fail your build, but won't make your code compliant.

Finally, if you decide you want to add a new code convention to your repos, it's just a one liner: "npm run fix". It doesn't get much easier.

Re: Starting a TypeScript Project in 2021

#168

Earlier quoted context omitted.

When you're trying to debug a JavaScript error do you use Chrome's built in JavaScript debugger, or do run Chrome in GDB? Or perhaps you get out your oscilloscope and try attaching it to your CPU? Debugging at multiple levels of abstraction is nothing new. The fact that there are debugging tools at the React level does reduce complexity. It means you don't need to understand the details of how React is implemented. Y…

It's a bit unfair to expect a framework not to provide new abstractions. That's required almost by definition. In React's defense, it's far from "impenetrable." In fact, its API exposes less than a dozen attachment points (considering render + lifecycle methods or their hook equivalents). It's a small and stable interface on top of a simple tree structure and an intuitive reconciliation algorithm. Most of the time yo…

React used to be simple, but now its indeed pretty much "impenetrable". Hooks are a strange API. Timeslicing and suspense add a lot of complexety for the benefit of very few. The processes for hooks-like funcitonality (algebraic effects) are supposed to be happening at TC39 (ESNext) level, but I can't see anything going on on that front; instead we have workaround hacks to make the API "look" like algebraic effects.

Things just need to improve there, one way or another...

Re: Starting a TypeScript Project in 2021

#169
post #15

Ava ( https://github.com/avajs/ava ) gets too little love from the blogging machinery. It's a breeze to use with TS, faster than Jest (YMMV of course), and I love the snapshot output over any other snapshot producing unit test tool. Use with NYC for coverage is a breeze.

Came here to mention how slow and sometimes awkward ts-jest is. I'll have to try out Ava and the others. I think jest is a great asset over mocha/jasmine/sinon/chai but it gets awkward in the typescript realm. Also thinking about how since it really isn't type aware (especially for mocks) that it loses some points compared to the ecosystems like mockito, nsubstitute, etc.

I was surprised that every Jest+TypeScript guide says to use ts-jest. I already have my IDE, the TypeScript watcher, and ESLint parsing/compiling all the code! I don't want to add fourth one :-P

I ended up just pointing Jest at my build output folder and that works. There are a couple minor annoyances but whatever.

(I actually started with Ava because it more directly supports using the existing build output, but I ran into another issue and had to switch back to Jest: https://github.com/avajs/ava/issues/2385)

Re: Starting a TypeScript Project in 2021

#170

In 2021, I think it's safe to start a TypeScript project with Deno.

Has anyone experimented with making a custom version of Deno that has its TS files built-in? I want to give my user exactly one binary that they can run to use the tool I'm writing, as if I'd compiled it in C/go.

Custom version? Isn't `deno compile` what you want?
Post reply on HN