DEV Community

Cover image for 14th weekly post, constant assertions and signatures. Also, storytelling in design.
LongYC
LongYC

Posted on • Originally published at longyc.com

1

14th weekly post, constant assertions and signatures. Also, storytelling in design.

Items of the week

  1. TypeScript - const assertion can prevent literal types from being treated as more general types, e.g. const config = {light: "ON"} as const; will have light as the literal type "ON" instead of string, making it compatible with type {light: "ON" | "OFF"}. It'll also make light readonly. More explanation can be found on the official documentation page.

  2. JWT - it can be signed asymmetrically with a key pair or symmetrically with a shared secret. The latter means all parties involved use one secret for both signing and signature verification, which means any party with the shared secret could have signed the JWS - something to be taken into consideration during implementation.

  3. Design & storytelling - good stories are engaging and help build empathy, adapting them to your audience and backing up the points with data could be helpful in getting buy-in during a design process. NN/g has an article on 6 rules for persuasive storytelling.

Note of the week

On the week 41 of 2021, I found out about a portable game console powered by a microcontroller - PicoSystem, an interesting product considering it is sporting the RP2040 just like a Raspberry Pi Pico. That's all for this week's post, thank you for reading and if you have got any feedback, do let me know by leaving a comment. Have a nice day!

Top comments (0)

11 Tips That Make You a Better Typescript Programmer

typescript

1 Think in {Set}

Type is an everyday concept to programmers, but it’s surprisingly difficult to define it succinctly. I find it helpful to use Set as a conceptual model instead.

#2 Understand declared type and narrowed type

One extremely powerful typescript feature is automatic type narrowing based on control flow. This means a variable has two types associated with it at any specific point of code location: a declaration type and a narrowed type.

#3 Use discriminated union instead of optional fields

...

Read the whole post now!