Microsoft/TypeScript

Template string downlevel to ES5 escapes more Unicode characters than necessary

Open

#10.498 aberto em 23 de ago. de 2016

Ver no GitHub
 (5 comments) (8 reactions) (0 assignees)TypeScript (6.726 forks)batch import
Experience EnhancementHelp WantedSuggestion

Métricas do repositório

Stars
 (48.455 stars)
Métricas de merge de PR
 (Mesclagem média 6d 17h) (9 fundiu PRs em 30d)

Description

TypeScript Version: 1.8.10

Typescript compiles template strings with Unicode characters incorrectly.

Code

var test1: string = 'test'; // Normal string (only English)
var test2: string = `test`; // Template string (only English)
var test3: string = 'тест'; // Normal string (Cyrillic)
var test4: string = `тест`; // Template string (Cyrillic)

Expected behavior:

There should be no significant difference in string representation, no matter language they are using. Since this is Unicode anyway. You can see expected behavior on standard, singleline strings. This behavior I would consider normal, expected.

var test1 = 'test'; // Normal string (only English)
var test2 = "test"; // Template string (only English)
var test3 = 'тест'; // Normal string (Cyrillic)
var test4 = "тест"; // Template string (Cyrillic)

Actual behavior:

Multiline (template) strings with none-English characters becomes encoded.

var test1 = 'test'; // Normal string (only English)
var test2 = "test"; // Template string (only English)
var test3 = 'тест'; // Normal string (Cyrillic)
var test4 = "\u0442\u0435\u0441\u0442"; // Template string (Cyrillic)

Link to official playground

Guia do colaborador