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

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.

Activity

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

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