Closed
Description
Bug description
Template literal strings can interpolate most scalar value types, including strings, numbers, booleans, etc.
However, trying to use a nullable string in a template literal currently leads to a compiler error.
Steps to reproduce
const x: string | null = "abc";
const s = `test: '${x}'`
ERROR TS2685: The 'this' types of each signature are incompatible.
:
2 │ const s = `test: '${x}'`
│ ~
└─ in assembly/index.ts(3,23)
:
644 │ toString(): String {
│ ~~~~~~~~~~~~~~~~~~
└─ in ~lib/string.ts(644,3)
The error is confusing, as it doesn't explain why there's an incompatibility, and there's only one value the user is putting in the template literal.
AssemblyScript version
v0.27.36