Skip to content

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

New issue

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

By clicking β€œSign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in 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