Skip to content
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

Template string type infers error when string intersect with object type #48034

Closed
XGHeaven opened this issue Feb 25, 2022 · 1 comment Β· Fixed by #48044
Closed

Template string type infers error when string intersect with object type #48034

XGHeaven opened this issue Feb 25, 2022 · 1 comment Β· Fixed by #48044
Labels
Bug A bug in TypeScript Help Wanted You can do this
Milestone

Comments

@XGHeaven
Copy link

Bug Report

πŸ”Ž Search Terms

Template string, Intersection type

πŸ•— Version & Regression Information

4.5.4

⏯ Playground Link

Playground link with relevant code

πŸ’» Code

const a = 'a'

type A = typeof a

type Mix = A & {foo: string}

type Origin1 = `${A}` // type is 'a'
type Origin2 = `${Mix}` // type is string

πŸ™ Actual behavior

Origin1 is 'a' and Origin2 is string

πŸ™‚ Expected behavior

Origin1 and Origin2 both are 'a'

@XGHeaven
Copy link
Author

XGHeaven commented Mar 2, 2022

And I found that I cannot use Mix in indexed object.

type Object1 = {[K in A]: number} // type is {a: number}, correct
type Object2 = {[K in Mix]: number} // type is {}, wrong

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Help Wanted You can do this
Projects
None yet
2 participants