Skip to content

Bug: string is not a stringΒ #60764

@HansBrende

Description

@HansBrende

πŸ”Ž Search Terms

string extends template bug wrong error conditional

πŸ•— Version & Regression Information

  • This is the behavior in every version I tried, and I reviewed the FAQ.

⏯ Playground Link

https://www.typescriptlang.org/play/?ts=5.7.2#code/FAFwngDgpgBAcgexgXhgbQGYEMA2BnKAXWFElgEk8BBAZRACcBLAOwHMAeGgPhRhpigAPEFGYATPDAAGAEgDeLDFHowA+gF8pMAPwwGAV1gAuGNnxQA3CXDQ+DFq0q17bdgBUBw0RJh4XrHlQ0JzomV1k5N00uQk8RcUlEHVNcAhgTAygSAGMEZj9fAAsEfRwxKhwAdywwPAAhKDd6QxNQhxD-dgByPC7AvWbLIA

πŸ’» Code

type No = [false]

type IsAString<S> = S extends `${infer _}` ? true : false;

type StringIsAString<T extends string> = [IsAString<`${T}`>] extends No ? false : true

const shouldAlwaysBeTrue: StringIsAString<'s'> = true;

πŸ™ Actual behavior

shouldAlwaysBeTrue reports the following error:

Type 'true' is not assignable to type 'false'.(2322)

πŸ™‚ Expected behavior

No error

Additional information about the issue

This is the most minimal reproduction of the issue I could come up with after whittling it down from a much more complicated scenario.

Interestingly enough, if I change almost anything about it, the issue goes away. For example, if I replace No with [false], issue goes away. If I take out one of the templates, issue goes away. Etc.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptHelp WantedYou can do this

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy