Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
I don’t know typescript very well so let me make a guess. Others can tell if it is correct :)
It looks like tuple decomposition (destructuring?). And since js and ts makes no distinction between tuples and arrays, it looks like you are declaring a constant named "updateThing" and assign it the second value from the array that is returned by the useMutation function -
h3rp1d3v5232y
-
I found this:
https://tanstack.com/query/latest/...
Can only assume it means it wants the second field in the object? -
That looks like an array destructuring assignment.
useMutation returns an array, and you are declaring a constant updateThing with the second item in the returned array as its value.
You could also declare another const for the first item of the returned array, but if you don't need it, you can simply skip it by not providing an identifier, hence the comma. -
Akhetopnu82yit's a basic destructuring of array, it's like getting angry because you don't understand what a pointer is in C (while coding in C). It's not rocket science and you sound like a typical 'Im gonna do frontend but i dont want to learn the main frontend language (js).' type of person. And it's not 'typescript' syntax, it's javascript, typescript is literally just type annotations on top of javascript.
-
h3rp1d3v5232y@Lensflare only react and solid. I think the syntax is very neat.
Tracking changes in ide is much easier. -
I usually leave a trailing comma in the last thing extracted by destructuring from some object, and destructure one thing on each line, like so:
const {
thing,
otherThing,
yetAnotherThing,
} = thingsContainer
This way when you add or remove an item into/from the destructuring, there's only a single line change in version control, or one line change per thing added/removed.
Maybe this has some kind of similar rationale, but I don't understand the [, either, lol -
Do you hate front end, or just front end devs because they insult you for not knowing front end? ;-)
I also find it amusing that front end is often to mean "the visible side of web pages". As if that is the only place that front end occurs. -
@Akhetopnu The main language, you mean the ONLY available under-engineered pseudo-interpreted language that nowadays isn't bearable without ten thousand compilation steps from other over-engineered fuckeries ?
-
Akhetopnu82yYou don't need a thousand compilation steps, you have things like vite that work with practically no setup, with several readily available bootstraping templates which you then use with a simple 'npm start' etc. If you have a 2000 line webpack config then it's not exactly javascript's or even webpack's fault. What exactly is under-engineered in javascript? Pseudo-interpreted meaning? Javascript has JIT as you probably know, do you mean that it has a runtime with a REPL? Like python? Like f#? Like lisps or haskell? Like scala? Destructuring syntax is definitely not just for frontend, it's useful anywhere. It literally mirrors creating an array, Javascript is the 'assembly' of the web and if you don't like it then you have lots of transpile-to-js solutions to choose from. Getting worked up about a language isn't very productive. Javascript obviously has its problems because it's backwards compatible and incrementally improved. If it wasn't half the web would catch on fire. : )
-
@Akhetopnu under engineered means no effort was put in its initial development. It has been created for the web and isn't even a DSL, have counter intuitive behavior, and today only consists of syntax sugar poured all over the place just to make it stand still. Because of that it led to an insanely fucked ecosystem in which nothing is simple anymore, because you HAVE to have compile steps, 400MB of packages that reduces to 120KB after tree shaking, for what shouldn't be a compiled language in the first place. The web was meant as an accessible system for everyone (remember when anyone could share DOCUMENTS, not fucking so-called WEB APPS that are just a livid compilation of bloated inhumane spaghetti code), and now it's became a pain to work with. I'm not even talking about the nodejs side of things, which is the mother of all abominations and serve no purpose beside pleasing code monkeys with that js-everywhere nonsense.
Anyway, I'm glad vanilla JS and PHP are still legal -
@hippolyte what makes things worse is that "frontend" became a synonym for "web app".
What a complete farce!
Having apps in the web is not the problem. Using JS/CSS/HTML for that is. -
@Akhetopnu
"JS is the assembly of the web".
Look at all those JS purists who prefer to use it for everything directly and despise things like TS. -
@hippolyte What bothers me the most about the web is that you need this giant implementation to display common pages. It now needs html, css, js, webassembly, etc modules. So the barrier to entry is quite high code wise. Now the phones in our pocket need quite a bit of oomph just to run a search engine. Not that my being bothered by this will change this at all. It just seems like there is a simpler, better internet trying to get out of this mess.
-
arekxv10542yIts destructuring assignment:
https://developer.mozilla.org/en-US...
Its not a typescript thing but its part of javascript. -
h3rp1d3v5232y@bigmonsterlover https://github.com/hyperhype/...
React jsx works the other way around, jsx is compiled to hyper script like functions
What the fuck is this syntax in a typescript file, I'm having trouble finding documentation if anybody can enlighten or link me
const [, updateThing] = useMutation(UpdateThingMutation);
The [, throws me off
i fucking hate front end
question