Skip to content

Backslash escaping in template strings are handled incorrectly? #2803

@dolphin225

Description

@dolphin225

Example: (TypeScript)

var a = `hello\world`;
var b = `hello\\world`;
var c = `hello\\\world`;
var d = `hello\\\\world`;

Is compiled to: (JavaScript)

var a = "helloworld";
var b = "hello\world";
var c = "hello\world";
var d = "hello\\world";

TypeScript Playground

Note that we need four backslashes in order to have a single backslash in the string value.

I tried the ES6 implementations in Chrome, Firefox and es6fiddle.net and they all treat backslashes in template strings the same way as in regular strings (i.e., two backslashes in the template results in a single backslash in the string value.).

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptFixedA PR has been merged for this issue

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions