News for hackers. Stuff that matters.

xodeus

Re:TypeScript is now officially 10 years old on Sunday October 09, 2022 @09:15AM (#33140675)
> TS catches me writing numerous bugs a day

I see this sentiment a lot but I honestly can't think of any non-trivial bugs that TS has caught for me. 99% of the bugs it catches I would see 1 second later when my page hot reloads and crashes.

Re:TypeScript is now officially 10 years old on Sunday October 09, 2022 @08:39AM (#33140451)
This comment has just triggered my PTSD from every Typescript project I've had to work on.
Re:TypeScript is now officially 10 years old on Sunday October 09, 2022 @08:00AM (#33140221)
I hope you're right, I've been waiting for Typescript to die for years
Re:Stranger Things, JavaScript Edition on Wednesday June 03, 2020 @11:34PM (#23412107)
But you're not getting the wrong answer, it's doing exactly what it should do. That one isn't really even a weird language quirk like the others. It's just assuming you're not aware that parseInt can take a 2nd argument
Re:The web as a GUI toolkit on Thursday February 13, 2020 @07:21PM (#22322753)
That plugin is the worst thing I've ever seen
Re:How Sydney destroyed its trams for love of the car on Thursday August 01, 2019 @02:57AM (#20581584)
I take the train as well, but only because it would take me just as long to drive + parking costs in the city are insane
Re:How Sydney destroyed its trams for love of the car on Thursday August 01, 2019 @02:27AM (#20581432)
I would 100% rather drive 25 minutes each way instead of sitting on a train for 40 minutes each way even if I could use my laptop/phone the whole time
Re:JavaScript Pattern Matching Proposal on Thursday April 26, 2018 @02:10AM (#16929221)
found the answer in the full proposal. Variables will always be assigned to, never checked for equality.

To me this is pretty average and seems like it will cause magic numbers/strings/etc if I can't use constants where it makes sense. The proposed solution is to do something like

  { status: 200 } if (x === foo) => // do something
which just seems (for this type of use case, maybe not all) like more boilerplate code for no real benefit over just doing something like

  if (res.status === 200 && res.x === foo) //do something
I would much prefer if there was some sort of special operator used to either check equality or to destructure when matching so it is obvious what the code is doing.
Re:JavaScript Pattern Matching Proposal on Thursday April 26, 2018 @12:35AM (#16928826)
If I do the following:

  let visFilter = 'foo';
  const newState = match (action) {
    {type: 'set-visibility-filter', filter: visFilter} => console.log(visFilter)
  }
What happens?

Is it checking if action.type === 'set-visibility-filter' && action.filter === 'foo' or is it destructuring the value of action.filter into visFilter?