Nice explanation for private fields! Been working with typescript classes for some time, and it's been really enjoyable! Great video
@whatplan4335 Жыл бұрын
Great video Classes are a really nice way to quickly define a type and constructor in one spot with not that much code
@gosnooky Жыл бұрын
Interesting. I've used the 'this' argument to create sort of an active record to classes that are serializable and validatable with class-transformer and class-validator, so I can call something like User.from({ id: 1, name: 'Bob' }) to pass a POJO that was JSON into an instance of the class. I never really understood how it works, but it does.
@dimitro.cardellini Жыл бұрын
Great video, thanks. Could you please record something about alternative approaches: factories and more exotic type classes?
@MindlessTurtle Жыл бұрын
Why do I get a bad feeling when using assertions and guards? Feels like building on shaky ground.
@doremicocoparis9410 Жыл бұрын
Actually works well, you are just making explicit your invariants. Doesn't solve bad designs or bugs for you, but when they happens you locate them MUCH MORE quickly (which gives you an opportunity to iterate on your design)
@otek_ Жыл бұрын
I know what you mean. The assertion predicate feels like it *could* be quite arbitrary and prone to going out of sync. For instance, if the type gets an additional field that would have to be included in your assertion's type predicate for it to remain valid, how would you know?
@doremicocoparis9410 Жыл бұрын
For this you need to use an other pattern, the exhaust never pattern for example
@valikonen Жыл бұрын
Very nice list. Also soft private fields can be accessed with: component['my_db_pass']. In angular we use a lot this approach in tests. It will be great to make a video for adding an external npm package and his types.
@nefthy2 ай бұрын
#2. private is not a security mechanism.
@PickleRiiiiiiick Жыл бұрын
Love it. Thank Andrew.
@gantoreno Жыл бұрын
Awesome video! Btw, what font are you using? Looks neat!
@andrew-burgess Жыл бұрын
Thanks! It's Mono Lisa!
@Noam-Bahar Жыл бұрын
@@andrew-burgess that's the best name for a font I've heard so far
@reverser41 Жыл бұрын
regarding your last tip, is there any way to make every instance method of a class to be called with instance, how can i make it throw or make invalid when getFullname() is called
@hansschenker Жыл бұрын
In Typescript every value is also a type. The type fortyTow = 42 has the value 42, {} is of type object , ...
@jenspalmqvist Жыл бұрын
But if you do 'let something: {}' you can assign everything except null and undefined to that variable, so be careful using that if you want the thing to be an actual object.
@andrew-burgess Жыл бұрын
Good reminder!
@0tickpulse173 Жыл бұрын
Your vim reminds me of nvchad
@andrew-burgess Жыл бұрын
Ha! I tried nvchad for a few days just recently, but switched to kickstarter.nvim. No magic, just a good base config.
@0tickpulse173 Жыл бұрын
@@andrew-burgess lol, im setting up kickstarter.nvim too currently
@kashmirtechtv294820 күн бұрын
Aren't we making the things harder unnecessarily?
@artemkotelevych2523 Жыл бұрын
js is a joke
@thedelanyo Жыл бұрын
p.getFullName.bind(p) ,,, I'll rather try avoiding `this` whenever possible 😂😂😂
@Luxcium Жыл бұрын
Yea Classes are _way better than all that hype about Functional programming…_ I love using classes to create my *Functors,* extend them into *Monad,* but it is cool also with a *Nothing* to create some *Maybe* and then also creating some *Left* and *Right* and *Either* the usual stuff… _Andrew_ 🦸🏻♂️ has a pretty interesting video about an *Optional* you must absolutely look into it, the homework 📚 to the reader is to use a class to implement the Option type of his other video 😅😅😅😅