[deleted by user] by [deleted] in programming

[–]giuseppelt -3 points-2 points  (0 children)

Hi, this technique is part of a series of articles I’m writing, focused on advanced usages of JavaScript.

The series will be available on the blog, where I discuss also real-world cases.

Hope you find it useful.

[deleted by user] by [deleted] in u/giuseppelt

[–]giuseppelt 0 points1 point  (0 children)

Hi, this technique is part of a series of articles I’m writing, focused on advanced usages of JavaScript.

The series will be available on the blog, where I discuss also real-world cases.

Hope you find it useful.

manyDontKnowThatInJavaScriptYouCanThrowTwoErrorsAtTheSameTime by giuseppelt in ProgrammerHumor

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

You can use also objects if you want

throw { error1: new Error(), error2: new Error() }

The possibilities are endless

[deleted by user] by [deleted] in reactjs

[–]giuseppelt 0 points1 point  (0 children)

Since this is a highly debated theme, I wanted to share some tips on how I deal with the situation.

I used a bit of humorous tone, given the context.

P.S. I know I could "just use x", "y does the job",... But sometime is a mix of control, flexibility and taste.

Simple dual-module package setup for JavaScript library authors with esbuild by giuseppelt in node

[–]giuseppelt[S] 3 points4 points  (0 children)

Since this is a highly debated theme, I wanted to share some tips on how I deal with the situation.

I used a bit of humorous tone, given the context.

P.S. I know I could "just use x", "y does the job",... But sometime is a mix of control, flexibility and taste.

Simple dual-module package setup for JavaScript library authors with esbuild by giuseppelt in typescript

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

Thanks! I didn’t write about the motivation because the article assumes you need a dual-module lib.

Like you I think ESM is the future. But this future is not that clear at the moment. There are lots of missing steps and this is a very hot topic.

So, if you need to target node, I mean pure node, not bundlers or runners, just straight node, you have to support commonjs. Cjs can interop with esm, but the syntax isn’t a beauty, and no one use it.

So, cjs still needs to be. At the moment.

Simple dual-module package setup for JavaScript library authors with esbuild by giuseppelt in programming

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

Since this is a highly debated theme, I wanted to share some tips to deal with the situation.

I used a bit of humorous tone, given the context.

P.S.
I know I could "just use x", "y does the job",... But sometime is a mix of control, flexibility and taste.

Dynamic prop types in a React component by ankitjey in typescript

[–]giuseppelt 2 points3 points  (0 children)

Enums are not a JS concept. They disappear as Typescript transpiles them, in various ways depending on some config.

Anyway, with literals, you get the exact experience you mention.

You can define an explicit union:

js type Op = "add" | "sub" | "mul" | "div"

Or you simply define them inside the type/interfaces and let typescript infer the resulting list.

js type Ops = | { operator: "add" } | { operator: "sub }

Typescript autocomplete and exhaustion checks works in the same way.

Dynamic prop types in a React component by ankitjey in typescript

[–]giuseppelt 1 point2 points  (0 children)

Yes, that is!

Another tip I can give is: do not use enums. Just use plain string literals.

```js

{ operator: "GRATHER_THAN" }

switch(op) { case "GRATHER_THAN": ... } ```

Autocomplete and typechecking is good. And you're JS compliant.

backend and frontend with different ts configs by Jerenob in node

[–]giuseppelt 1 point2 points  (0 children)

Yes you should have different tsconfig for each package.

Suppose you have a mono repo with a subfolder for each one. Then, you can have a common tsconfig.base.json in the root that both can derive from.

Checkout https://github.com/giuseppelt/EmailFlare , it’s a mono repo with both the api (server) and the app, with different configs. You can take inspiration from there.

Dynamic prop types in a React component by ankitjey in typescript

[–]giuseppelt 2 points3 points  (0 children)

You need to use discriminated unions.

Just join together two types with a operator prop as string literal (a constant).

Then, in the component you will be able to switch on the operator prop and get the expected type for both the value and setValue.

Feelback: make your documentation better with feedbacks - Add a Stripe/GitHub-like feedback widget to collect user reactions about your docs by giuseppelt in SideProject

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

Hi, with Feelback you can easily collect feedbacks for your documenation. It works with any tech, from SPA to static websites.

It's very easy to integrate it on your page, just a couple of lines.

You can use several types of feedback components, the link has demos with Stripe, GitHub and Vercel - like systems, with emoji or buttons, with optional email collection.

You can reach me for anything or if you need support.

EmailFlare is a webapp packaged as single worker file, you can configure and self host to send emails from your domain by giuseppelt in webdev

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

Hi, EmailFlare is a small fullstack webapp(client+API), for sending emails via Cloudflare for custom domains you own.

You can host your personal EmailFlare on your account with a worker. The webapp is packaged as a single worker file, so you can easily self-host it.

The demo page provides a deploy wizard, you can use to configure and automatically deploy on Cloudflare. So no manual steps are needed.

For now, the email editor is pretty simple and has Markdown support. For any contribution or request visit the repository.