Skip to content

Trying to infer a substring in a template literal leads to the type not matching the templateΒ #55855

Closed as not planned

Description

πŸ”Ž Search Terms

template literal infer, literal infer, infer match

πŸ•— Version & Regression Information

This changed between versions 4.6.4 and 4.7.4. Doesn't no work in 5.2.2 nor nightly.

⏯ Playground Link

https://tsplay.dev/WzDbrN

πŸ’» Code

type InferDelimiter<
  T extends string,
  Delimiter extends string,
> = T extends `${infer Head}${infer Mark extends Delimiter}${string}` ? true : false;

type T1 = InferDelimiter<'foo.bar', '.'>;

πŸ™ Actual behavior

T1 is evaluated to false.

πŸ™‚ Expected behavior

T1 is evaluated to true.

Additional information about the issue

No response

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

Metadata

Assignees

No one assigned

    Labels

    DuplicateAn existing issue was already created

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions