« first day (4930 days earlier)      last day (32 days later) » 

2:53 AM
||joke
 
What's the object-oriented way to become wealthy?
Inheritance
 
💰
 
 
6 hours later…
8:26 AM
has anyone experience with nextjs and mobx
 
 
1 hour later…
9:27 AM
I feel I almost cannot use the ssr at all: since the point where the stores are provided -which for layout store is the very top level- need to be client side rendered, and that makes all sub-pages also client side.
 
 
6 hours later…
3:54 PM
Hi guys. Can a type be extended in typescript?
 
As in with the extend keyword? Or do you mean you want to modify an existing type?
 
Yes
export type Result = {
   success: boolean;
   status?: string;
}
export type SuperResult extends Result {}
I get errors on extends and Results
 
To use extends you need an interface:
interface MyResult extends Result {
    dog: true;
}
 
hmm i just ran into an issue with interfaces in typescript
 
If you want to use type you need to do an intersection which is the same as an extends:
type MyOtherResult = Result & { cat: true }
 
3:58 PM
if (error instanceof ExecException) {} // error
 
Because instanceof is a run-time check. Doesn't work with compile-time constructs which is the types.
 
right
someone in one of the answers said that typescript doesn't have reflection
 
You'll have the same problem with type. You either need a concrete thing (so, probably a class), or do type narrowing and duck-typing.
@1.21gigawatts No, it's matte, not shiny :P
 
lol
so this will add the property and create a new type:
type MyOtherResult = Result & { cat: true }
 
@1.21gigawatts Yes. It's the same as extends Result { cat: true }
 
4:01 PM
why not use class all the time then? is it heavier or something?
 
@1.21gigawatts Not needed most of the times. Also, you would need to ensure all usages of the class are actually the class. Consider this code
Now, this is maybe a bit misleading - the reason the plain object is assignable to Foo here is because Foo doesn't have any methods. If it did, then the object won't "fit" as a parameter. However, you can probably see where the problem is if you want to encode data objects as classes. You need some discriminant to make sure what you're really working with is a class instance. Otherwise any object of the correct shape can be used instead. Which breaks the instanceof assumptions.
 
hmm that might explain why typescript hasn't added reflection. if it's doing object property checks then if they try to do real checks it might break past code
 
Especially dangerous if you're making some sort of network call that serialises/deserialises data. Because if you just deserialise from JSON, you get a plain object, not a class instance. And new-ing each and every thing is wasteful in terms of time you need to spend to make sure it's correct. Also future maintenance.
 
hmm i've started to try and make my project server side code and client side code use types and its been difficult
if i have Cat on the server and I want my json object typed on the client it isn't possible in my current project design
because the Cat class in the root and the web pages are in public and so when the browser loads it can't find the Cat class
 
You can do type guards to figure out if an object is a specific type. See the TS handbook on narrowing and type guards.
You can write custom type guards that look like this
 
4:12 PM
So would it be a good idea if JSON had class support? Maybe have it add a class parameter? ie JSON.parse(dataObject, ClassName)
 
Essentially, you can duck-type check to see if something fits.
@1.21gigawatts I'd not recommend it. But if you have a builder that takes plain objects and produces your class that'd be fine. You can also have a static builder method, something like class Foo { static fromData(data) { return new Foo() /* some initialisation */ } }
I'd probably personally have the class in a module then an encode/decode pair of functions, so they aren't part of the class itself but bundled alongside.
There are libraries that can do something like this for you. I've not tried them, though. Zod is popular to do the duck-type checks and validate the object you got is what you expected to get.
 
posted on April 15, 2024 by Ben Mason

Hi everyone! We've just released Chrome Beta 124 (124.0.6367.54) for Android. It's now available on Google Play. You can see a partial list of the changes in the Git log. For details on new features, check out the Chromium blog, and for details on web platform updates, check here. If you find a new issue, please let us know by filing a bug. Erhu Akpobaro Google Chrome

 
@VLAZ yes. a simple deserialize method or the like
The typescript link talked about javascripts quirkiness and all the things typescript does to get around it. would it be a good idea for browsers to add support for different languages, that have the features typescript adds? or is ecmascript getting to a point where if you can use the newest features you get the features typescript and other languages have?
because it seems like a lot of limitations come from JS being a prototype language and then having limits from that
 
4:28 PM
@1.21gigawatts The TS team is working with the ES people on trying to add types to the base language. They announced this a while ago (maybe closer to 2 years now). But literally only this is known - no deadlines, roadmaps, expectations or anything like that. The announcement was "we're looking into it" with no other information.
 
I appreciate their work but I'm asking because it seems like it might be better in the long run to have a full modern language support at the core
 
The features TS adds are just a compile-time support for checking the program for correctness. If you've already checked your code for correctness (which you can do with other things, not just TS - I've used Tern.js in the past. There is also Flow), then it doesn't really matter whether the browser supports TS or not.
 
iiuc the browsers use javascript engines
 
At best, if the browser loads TS, it can fail early on loading the script and figuring out you're assigning a string to a number or something.
But that's about the only thing you get from the browsers supporting TS. It's maybe few moments earlier failure than the JS code that does the same. But it's still at runtime for the user who is trying to use the web application.
 
it's come a long way
how far does it need to go still?
typescript and jabascript?
 
4:50 PM
jabbascript hmm, skyrim reference?
anyway, do anyone here have experience or tips for reverse engineering some obfuscated javascript?
it's such a pain, I don't know if it's worse than doing it for assembly or not.
 
5:02 PM
@NordineLotfi if you load it in the browser i think it formats it pretty print style. also, i think that vscode has ways to pretty print. that might be the best you can get bc you won't have named members
in my experience, it's often easier to rewrite or write from scratch than reverse it or learn it and ask questions. you are on stack overflow dude
 
@NordineLotfi Well, not worse, I'm pretty sure. Still not pleasant. You can find deobfuscators online. Some just pretty print the code. Others try to give meaningful names to variables. The latter part doesn't work great but it's better than not having it. It might rename a to personName, for example, if it figures that's ultimately what is written to it. Or similar.
 
5:25 PM
does javascript allow you to call await on a non async function?
  await this.showIcon();
  function showIcon() { // normal function }
 
Yes. You can away any value. Even await 5 or whatever. It mostly doesn't do anything.
It's the same as await Promise.resolve(5) and the only observable effect is that it would pause the function, yield to the execution, then pick back up almost immediately. Usually, that shouldn't really make any difference.
 
can you cancel an awaited call?
 
@1.21gigawatts true, but sometimes there are some cool stuff you can find in obfuscated code...mostly this is just me being curious I guess
 
say i have myAsyncCall() and it has a lot of await calls in it and i want to cancel that. is there a way?
 
@VLAZ yeah, I tried a couple, but as you mentioned they all mostly aren't perfect, but as you said, it's better than nothing hmm
 
5:34 PM
@NordineLotfi 100% that's how you learn or how we learned back in the day
 
:o yeah you're right
 
if you find obfuscated code it probably isn't... it is probably minified
 
yeah, it is, but it is so deeply minified, I can only understand roughly, like a quarter of it if I really squint
 
lol
well, some libraries i've come across weren't obfuscated and i could only understand a quarter of it. there was an ide / text editor that was open sourced and i couldn't follow it. 30 classes. i had 20+ years of experience. i might understand it now
 
5:50 PM
@1.21gigawatts Not really. There is no generic mechanism. You can implement cancellation, though. See how fetch() does it with AbortController developer.mozilla.org/en-US/docs/Web/API/AbortController
As of recently, this is the modern way to cancel most async stuff. Using AbortController itself. You'd have to make sure your function accepts an abort signal, and you then need to respond to that signal to cancel the operation
 
i knew fetch had an abortcontroller. ...i didn't know that i could implement my own. thanks
how or where does using backticks add a new line?
var message = `${folder}/${filename}";
 
6:07 PM
msg = `line1
line2
line3`
It works as a multiline string.
But IMO, it's not great. If you have any nesting, then the string also gets nested. And there is no pretty way to resolve this.
||> function foo() {
	return `line1
	line2
	line3`;
}

console.log(foo());

function bar() {
	return `line1
line2
line3`;
}

console.log(bar());
 
@VLAZ Please don't post unformatted code - use the up arrow to edit your post, then hit Ctrl + K to format the code in that post. See the faq. You have 25 seconds to edit and format your message properly before it will be removed. Please separate code blocks from your actual question. Put your question in 1 message and then your code in a 2nd and format it.
@VLAZ undefined Logged: [ '"line1 \n line2 \n line3"', '"line1 \n line2 \n line3"' ] Took: 3ms
For posting large code blocks, use a paste site like like gist.github.com, hastebin.com, pastie.org or a demo site like jsbin.com
@VLAZ undefined Logged: [ '"line1\n\tline2\n\tline3"', '"line1\nline2\nline3"' ] Took: 0ms
 
both are ugly if you just want a simple unnested message.
You can use tagged templates but it's also not great. You need to do the trimming yourself.
 
6:26 PM
posted on April 15, 2024 by Matt

The Dev channel is being updated to OS version: 15849.0.0 Browser version: 125.0.6411.0 for most ChromeOS devices. If you find new issues, please let us know one of the following ways File a bugVisit our ChromeOS communitiesGeneral: Chromebook Help CommunityBeta Specific: ChromeOS Beta Help CommunityReport an issue or send feedback on ChromeInterested in switching

 
7:08 PM
posted on April 15, 2024 by Daniel Yip

The Stable channel has been updated to 124.0.6367.60 for Windows and Mac as part of our early stable release to a small percentage of users. A full list of changes in this build is available in the log. You can find more details about early Stable releases here. Interested in switching release channels?  Find out how here. If you find a new issue, please let us know by filing a bug. The

posted on April 15, 2024 by Ben Mason

The Beta channel has been updated to 124.0.6367.60 for Windows, Mac and Linux. A partial list of changes is available in the Git log. Interested in switching release channels? Find out how. If you find a new issue, please let us know by filing a bug. The community help forum is also a great place to reach out for help or learn about common issues. Daniel Yip Google Chrome

 
i'll just keep using quotes
 

« first day (4930 days earlier)      last day (32 days later) »