Result of Object.create(null)
may be passed to template literal
#32135
Labels
Awaiting More Feedback
This means we'd like to hear from more people who would be helped by this feature
Suggestion
An idea for TypeScript
TypeScript Version: 3.5.1
Search Terms: template string, template literal, Object.create(null)
Code
`${Object.create(null)}`
Expected behavior:
TypeError
, as the object passed to the template string has notoString
method in the prototype chain (as it has no prototype chain at all).Actual behavior: Everything goes well in the compiler, but JavaScript reports runtime error (ex.
TypeError: Cannot convert object to primitive value
in Chrome).Playground Link: https://www.typescriptlang.org/play/index.html#code/AYEg3g8gRgVgpgYwC4DoECc4EMlwBQB2ArgDYkCUAvsEA
Related Issues:
#30239
#1108
The text was updated successfully, but these errors were encountered: