You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
TS infers the type string for the returned string, instead of the templated type.
π Expected behavior
No error!
The text was updated successfully, but these errors were encountered:
EdwardDrapkin
changed the title
Cannot define a matching template literal type to a template literal in a function declaration
Cannot define a matching template literal type to a defined template literal
Mar 8, 2021
We currently only produce template literal types from template literal expressions in as const contexts. We tried template literal types for all template literal expressions in #41891, but reverted it because it was too breaky. However, a happy medium would be to give template literal types to expressions that are contextually typed by string-like types. I can't imagine that breaking anything and it would solve this and other related issues.
Bug Report
π Search Terms
string, template, literal, type
π Version & Regression Information
This is the behavior in every version I tried, including Nightly
β― Playground Link
Playground link with relevant code
π» Code
π Actual behavior
TS infers the type
string
for the returned string, instead of the templated type.π Expected behavior
No error!
The text was updated successfully, but these errors were encountered: