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

Revert changes for template literal types, keeping tests. #42588

Merged
merged 2 commits into from
Feb 3, 2021

Conversation

DanielRosenwasser
Copy link
Member

@DanielRosenwasser DanielRosenwasser commented Feb 1, 2021

We have reservations about inferring template string types by default, so this PR applies the revert for work discussed at #42589.

@typescript-bot typescript-bot added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label Feb 1, 2021
@DanielRosenwasser DanielRosenwasser marked this pull request as ready for review February 1, 2021 23:00
@typescript-bot
Copy link
Collaborator

This PR doesn't have any linked issues. Please open an issue that references this PR. From there we can discuss and prioritise.

@DanielRosenwasser
Copy link
Member Author

Will probably merge in an hour or two

@DanielRosenwasser DanielRosenwasser merged commit cce4bfb into master Feb 3, 2021
@jcalz
Copy link
Contributor

jcalz commented Feb 8, 2021

So #42588 undoes #41891, right? Just cross-linking them.

@pedrodurek
Copy link

I hope you can bring it back at some point 🙏

@DanielRosenwasser DanielRosenwasser deleted the undoTemplateLiteralTypes branch February 12, 2021 18:00
@DanielRosenwasser
Copy link
Member Author

Yeah, we had a lot of mixed feedback. I will say about half the team really wanted this and another half felt uneasy about it. We got feedback from existing projects that inferring template literal types by default was questionable at best.

Even though the original concern was about combinatoric explosions of string types, I think in the future we might be open to inferring literal strings when they can be constructed, but not necessarily template string types.

For example

function foo(x: "a" | "b")
  const str = `hello ${x}`; // "a" | "b"
}

but not

function foo(x: string)
  const str = `hello ${x}`; // `hello ${string}`
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
For Uncommitted Bug PR for untriaged, rejected, closed or missing bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants