Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Can't use nullable strings in template literal #2918

Copy link
Copy link
@mattjohnsonpint

Description

@mattjohnsonpint
Issue body actions

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

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.