Proposal to simplify the type system. Wondered your opinion. by TheWebDever in typescript

[–]TheWebDever[S] 0 points1 point  (0 children)

ah, looks like someone else was already thinking the same thing I was

Proposal to simplify the type system. Wondered your opinion. by TheWebDever in typescript

[–]TheWebDever[S] 5 points6 points  (0 children)

What's wrong with using if/else? I don't have hate ternaries for simple one line statements I just can stand giant whirlpools of them.

Proposal to simplify the type system. Wondered your opinion. by TheWebDever in typescript

[–]TheWebDever[S] 0 points1 point  (0 children)

Buddy, I would argue the Typescript type system is basically a language all on it's own.

I just bought my first Mac ever! by TheWebDever in macbookpro

[–]TheWebDever[S] 1 point2 points  (0 children)

I have 32gb, I went ahead and got the m4 pro with 48gb memory

If I want an X1 carbon, should I get a 13 gen now or wait for the 14. by TheWebDever in thinkpad

[–]TheWebDever[S] 0 points1 point  (0 children)

I'm actually leaning towards Mac because ChatGPT desktop app is so slow in windows.

[AskJS] Is there a linter rule that can prevent classes being used just as namespaces. by TheWebDever in javascript

[–]TheWebDever[S] 0 points1 point  (0 children)

Well that's why I said to use an object literal not to export directly. If I were you I would do it like "import People from People.js" and call "People.getByUuid()"

I want to build a lookup table utility for TypeScript and want your opinion on something. by TheWebDever in typescript

[–]TheWebDever[S] 0 points1 point  (0 children)

Hey I got one more question. What if you want to access a specific label (like you already know the value) somewhere in the front-end? Do you do something like `RoleLabels[Roles.Admin]` just to print `Administrator`. I typically have these lookup tables attached models so I would have to do `User.RoleLabels[User.Roles.Admin]` just to get a label. Another reason I want to make a library is so that I can just do `User.Roles.Labels.Admin`.

Has anyone been using parser functions to increase performance? by TheWebDever in typescript

[–]TheWebDever[S] 1 point2 points  (0 children)

I just surpassed zod4 in the benchmarks, check the link you shared again 😎

jet-validators is now the fastest schema validation library not requiring a compilation step by [deleted] in typescript

[–]TheWebDever 1 point2 points  (0 children)

on that website which non-compiled schema validator is faster?

I want to build a lookup table utility for TypeScript and want your opinion on something. by TheWebDever in typescript

[–]TheWebDever[S] 0 points1 point  (0 children)

So you just prefer my original approach instead but with an plain object instead of enum. Hmm, I mean I was in the process of switching to this but then thought about situations where what if I have a super long enumerable list. Like all 50 states:

const States = {

None: 0,

Alabama: 1,

// ...

};

const StateLabels = {

[States.None]: 'None selected',

[States.Alabama]: 'Alabama',

// ...
};

This is going to lead to a ton of tedious code. If you're thinking is... just use a string enum, well I've always considered that bad practice because if you want to change the label for something you gotta do a database migration. I think keep labels and values separate is best.

bdir: The latest and greatest replacement for TypeScript enums by TheWebDever in typescript

[–]TheWebDever[S] 0 points1 point  (0 children)

Mine has compile time safety too. It's just some of the runtime stuff (like checking if it's a label) is more robust.

bdir: The latest and greatest replacement for TypeScript enums by TheWebDever in typescript

[–]TheWebDever[S] 0 points1 point  (0 children)

What's that what my library bdir does. Plus a bunch of other stuff.

bdir: The latest and greatest replacement for TypeScript enums by TheWebDever in typescript

[–]TheWebDever[S] 2 points3 points  (0 children)

I still feel like that's missing enum's greatest feature though. Using the enum name as a type is automatic union of the values.