Skip to content

Typescript types for IDs #2033

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

Open
Le0Developer opened this issue May 12, 2025 · 0 comments
Open

Typescript types for IDs #2033

Le0Developer opened this issue May 12, 2025 · 0 comments
Labels
feature 🚀 New feature or request

Comments

@Le0Developer
Copy link
Contributor

Description

Hi, we are using TypeIDs extensively in our API for IDs. For example user_... or org_.... Previously we used Typescript like this:

type UserID = `user_${string}`
type User = {
  id: UserID;
}

To solve ID "confusion" at the type level.

We're trying to move to this package but all our IDs turn into string, losing the additional safety.

My proposed solution would be expanding the existing logic format codegen logic to check for format: typeid and generate the appropriate types.

I will try opening a pull request, but there does not currently seem to be a standardized way for declaring the typeid prefix in OpenAPI (see jetify-com/typeid#45).

@Le0Developer Le0Developer added the feature 🚀 New feature or request label May 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature 🚀 New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant