Skip to content

Inconsistent intersections of string literal types and pattern string mapping types #57192

Closed

Description

🔎 Search Terms

Literal type, string mapping type, intersection

🕗 Version & Regression Information

  • This is the behavior in every version I tried

⏯ Playground Link

https://www.typescriptlang.org/play?#code/C4TwDgpgBAYg9nKBeKBvKYBOcwC4oDOwmAlgHYDmUAvgNwBQ9okUAKgAzKwIDaARFhx8AurShQA9BKgB5ANZNw0VgEYu8OP0Fg+UAGRQABmAAkqIqUrUwh0eKmyFzZQCZ1vAdh36jp1ABk4AHcITABjAEMCCAAeC3IKAD5rWzFJaXlFFlYAZndNTyEfQJDwqNj4ykS7dKgAUUxsTAAaKCCI4AB+eiA

💻 Code

type Foo = { prop: string };

type T0 = Foo["prop"];  // string
type T1 = Foo["prop" & `p${string}p`];  // string
type T2 = Foo["prop" & `p${Lowercase<string>}p`];  // string
type T3 = Foo["prop" & Lowercase<string>];  // Error, wat?

🙁 Actual behavior

Error.

🙂 Expected behavior

No error.

Additional information about the issue

See here.

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

Metadata

Metadata

Labels

BugFix Available

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions