Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

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

Closed
ahejlsberg opened this issue Jan 26, 2024 · 0 comments Β· Fixed by #57197
Closed

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

ahejlsberg opened this issue Jan 26, 2024 · 0 comments Β· Fixed by #57197
Assignees
Labels
Bug A bug in TypeScript Fix Available A PR has been opened for this issue

Comments

@ahejlsberg
Copy link
Member

ahejlsberg commented Jan 26, 2024

πŸ”Ž 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.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Bug A bug in TypeScript Fix Available A PR has been opened for this issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants