Cascading strings to numbers on shorthand object creation

How would it be cascading strings into number when we create an object with shortened syntax.

Instead of

const user = {name, surname, age: +age, email};

we could say

const user = {name, surname, +age, email};

What if I want to cast it to a BigInt, or a String, or something else?

@ljharb you are asking the right question but not under the right thread I guess. I only ask about string to number cascading.

But it would be great having easier syntax for string or bigint cascading. Turning numbers into string with an expression like a quote end of it

I think it would be very strange to create additional syntax weight for just casting to Number when so many other type conversions are also common.

1 Like

@ljharb I think it would be practical and aesthetic, nowadays most of people using state management systems and making primary key based comparison which is widely integer. It looks little annoying to watch while you define all your model in shorthand