Skip to content

${string}${string} turns into stringΒ #57233

@DeepDoge

Description

@DeepDoge

πŸ”Ž Search Terms

"string"

πŸ•— Version & Regression Information

  • This is an unexpected behavior

⏯ Playground Link

Playground

πŸ’» Code

// gives `true`, because `${string}${string}` type turns into string type but it shouldnt and should give `false`
type _ = string extends `${string}${string}` ? true : false;

// Similarly should be false because first ${string} gets the empty space only empty space, and there is nothing left to satify second ${string}
type __ = "" extends `${string}${string}` ? true : false;

πŸ™ Actual behavior

`${string}${string}` type turns into string type.

πŸ™‚ Expected behavior

`${string}${string}` should stay as its.

Additional information about the issue

// gives `true`, because `${string}${string}` type turns into string type but it shouldnt and should give `false`
type _ = string extends `${string}${string}` ? true : false;

// Similarly should be false because first ${string} gets the empty space only empty space, and there is nothing left to satify second ${string}
type __ = "" extends `${string}${string}` ? true : false;

// What is correct
{
  // works without error as expected because empty space at the start satisfies ${string}
  const foo: `${string}@` = "@";

  // gives error as expected because first ${string} already uses the empty space at the start
  //  and second one has no empty space to use
  //  so before @ it expects at least one other character
  const bar: `${string}${string}@` = "@";

  // so this works as expected
  const baz: `${string}${string}@` = "a@";
}

// What is wrong
{
  // should give error but doesnt because `${string}${string}` type turns into string type
  //  `${string}${string}` should stay as its and foo should expect its setter value to satisfy at least one character
  const foo: `${string}${string}` = "";
}

Not sure if its a feature or a bug, but and its not consistent, and it looks like a bug, sound like a bug, acts like a bug.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Not a DefectThis behavior is one of several equally-correct options

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions