Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

introduce branded types #1141

Closed
setchy opened this issue May 24, 2024 · 3 comments Β· Fixed by #1223
Closed

introduce branded types #1141

setchy opened this issue May 24, 2024 · 3 comments Β· Fixed by #1223
Assignees
Labels
enhancement New feature or enhancement to existing functionality

Comments

@setchy
Copy link
Member

setchy commented May 24, 2024

πŸ“ Provide a description of the new feature

https://egghead.io/blog/using-branded-types-in-typescript

Could be useful for types such as URL, Hostname, Token, ClientID, ClientSecret etc

βž• Additional Information

No response

@setchy setchy added the enhancement New feature or enhancement to existing functionality label May 24, 2024
@dammy95
Copy link
Contributor

dammy95 commented Jun 8, 2024

Hi @setchy – I'm currently looking into this, but wanted to validate my initial approach before I start properly. Here is my current plan below:

  1. Create Branded Types for URL Hostname, Token, ClientID, ClientSecret. The base types for all 4 items should be of type string.
  2. The branded types can then be added to the types.js file in the src directory.
  3. Taking hostname as an example here, we would replace all occurrences of hostname: string with hostname: Hostname (where Hostname will be a new branded type).
  4. Repeat step 3 for URL, Token, ClientID, and ClientSecret

Let me know if you have any additions (or subtractions) to this approach πŸ˜„

@setchy
Copy link
Member Author

setchy commented Jun 8, 2024

hi @dammy95 - well summarized. That's what I had in mind πŸ˜„

@dammy95
Copy link
Contributor

dammy95 commented Jun 8, 2024

Perfect – I'll get started on this then πŸ‘πŸΎ

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or enhancement to existing functionality
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants