HNHacker News
TopNewBestAskShowJobs

rodneon

5 karma · joined December 3, 2018

submissionscomments
rodneon··on Ask HN: Convince me that TypeScript is better than JavaScript
This is only a problem when you remove properties from an object. Ok, in this particular case, I buy your theory... but I'll ask again: is all the added cruft really worth this small safety? I mean, when you say "when the types of objects (...) are known"... isn't this the kind of stuff that tests are supposed to catch? You check to see if the object being passed into a function has all the properties it needs to have. Right? And if you need that kind of safety, couldn't you just enforce the use of constructors for "important" objects, and use instanceof to check for proper usage? All while using the constructs provided by JavaScript itself?
rodneon··on Ask HN: Convince me that TypeScript is better than JavaScript
> potential runtime errors (...) before they (...) happen in production

I seriously can't think of an example of this. If all testing is done properly, from unit testing to integration, etc, the compile time safety for front end development is just a nuisance. Runtime errors will happen, that's what tests and error tracking are for.

To put it differently, are all of these reasons that you cited worth turning this:

// ==========

import React from 'react';

const Welcome = ({ name }) => <h1>Hello, {name}</h1>;

// ==========

into this?

// ==========

import * as React from 'react';

interface WelcomeProps { name: string }

const Welcome: React.SFC<WelcomeProps> = ({ name }) => <h1>Hello, {name}</h1>;

// ==========

In the second example, gone are the years of making Javascript an elegant and straightforward language, adorned by the intuitive syntactic sugar that is JSX.

rodneon··on Ask HN: Convince me that TypeScript is better than JavaScript
Those have been my thoughts exactly, except I might need to buckle down and use Typescript because the devs at work favor it. I don't want to hate coding in Typescript, which is why I posted this Ask HN. I still wouldn't use it on any projects where I have full control. But, if I need to use it, I might as well try to see the bright side of it.

On the other hand, all this "safety" that Typescript imparts just gets in the way of productivity. It's a language to show off to your boss, not to get shit done.

rodneon··on Ask HN: Convince me that TypeScript is better than JavaScript
Mainly create-react-app, styled-components, react-styleguidist (which uses react-docgen). I'm okay with writing .d.ts files for my React components, but trying to develop these components in this ecosystem... oof.
rodneon··on Ask HN: Convince me that TypeScript is better than JavaScript
The refactoring bit is almost convincing enough for me. I'm a front-end developer with a strong background in JavaScript and React. They say Typescript is a superset of JavaScript, but I disagree. I feel like I can't write JavaScript anymore when Typescript is in the mix. React component declaration gets messy and ugly. Just the other day I tried to use "document.something"... nope, can't do that, because there's no explicit interface for "document". It feels like every simple thing takes one or two extra steps with Typescript, and sometimes those steps take me all day to resolve!