Skip to content

Type inference won't work with template literals #1355

Open
@ccpu

Description

@ccpu

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions