-
-
Notifications
You must be signed in to change notification settings - Fork 17
Allow only value types in string interpolations #44
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
Comments
if the class definition has a Might need to add in some functionality in the reflection to traverse through the extended classes to see if |
The default JS behavior for template strings is to always call ToString(result of evaluating expression) https://tc39.github.io/ecma262/#sec-template-literals-runtime-semantics-evaluation Implementing a logic that would allow only non-native toString could be confusing. TypeScript itself doesn't want different rules of template strings and + operator. See microsoft/TypeScript#7989 and linked issues I can see two possible solutions. 1) implement an optional strict rule that would allow strings only, everything else would need to be explicitly casted with .toString() 2) follow how TypeScript currently does this, i.e. don't implement this rule at all |
I think I'm leaning to the later; technically its is not syntactically incorrect to do this. So long as the access expression to the variable is correct and assignment is okay. Then I think anything else is currently out-of-scope. |
I think if anyone actually did print off an object like above then they will clearly see the result and given it is technically not-incorrect to do so, I won't be spending time on it yet. |
Uh oh!
There was an error while loading. Please reload this page.
It could prevent unintentional implicit casting, for example to
"[object Object]"
.The text was updated successfully, but these errors were encountered: