Skip to content

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

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

typeFoo={prop: string};typeT0=Foo["prop"];// stringtypeT1=Foo["prop"& `p${string}p`];// stringtypeT2=Foo["prop"& `p${Lowercase<string>}p`];// stringtypeT3=Foo["prop"&Lowercase<string>];// Error, wat?

🙁 Actual behavior

Error.

🙂 Expected behavior

No error.

Additional information about the issue

See here.

Metadata

Metadata

Labels

BugA bug in TypeScriptFix AvailableA PR has been opened for this issue

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions