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

Type inference won't work with template literals #1355

Open
ccpu opened this issue Aug 7, 2022 · 1 comment · May be fixed by #2053
Open

Type inference won't work with template literals #1355

ccpu opened this issue Aug 7, 2022 · 1 comment · May be fixed by #2053

Comments

@ccpu
Copy link
Contributor

ccpu commented Aug 7, 2022

Thanks to @daanboer PR(#1265), type inference now works with this library, but I have discovered that it doesn't work with template literals:

export type Replace<
    Input extends string,
    Search extends string,
    Replacement extends string
> = Input extends `${infer Head}${Search}${infer Tail}` ? `${Head}${Replacement}${Tail}` : Input;

export type MyType = Replace<"FooBarBaz", "Bar", "">; // => FooBaz

The ability to use Inferred types with template literals would be great.

@arthurfiorette
Copy link
Collaborator

arthurfiorette commented May 27, 2024

Thanks for the report. Would you like to start a PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants