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

Structurize template literal types (TemplateLiteralType) #39

Open
kungfooman opened this issue Nov 16, 2023 · 0 comments · May be fixed by #46
Open

Structurize template literal types (TemplateLiteralType) #39

kungfooman opened this issue Nov 16, 2023 · 0 comments · May be fixed by #46
Assignees
Labels
typings Everything related to type declarations

Comments

@kungfooman
Copy link
Owner

Example:

/**
 * @typedef {"welcome_email" | "email_heading"} EmailLocaleIDs
 * @typedef {"footer_title" | "footer_sendoff"} FooterLocaleIDs
 * @typedef {`${EmailLocaleIDs | FooterLocaleIDs}_id`} AllLocaleIDs
 * @typedef {"en" | "ja" | "pt"} Lang
 * @typedef {`${Lang}_${AllLocaleIDs}`} LocaleMessageIDs
 */

These templates literal types produce permutations of all input unions, for example:

image

More info: https://www.typescriptlang.org/docs/handbook/2/template-literal-types.html

@kungfooman kungfooman self-assigned this Nov 16, 2023
@kungfooman kungfooman added the typings Everything related to type declarations label Nov 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
typings Everything related to type declarations
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant