TypeScript: Identifiers with Astral Unicode characters are unsupported

TypeScript Version

3.5.1

Search Terms

utf8, unicode

Code

const ๐‘š = 4;
const ๐‘€ = 5;
console.log(๐‘€ + ๐‘š); // 9

Expected behaviour

The above is legal JavaScript, so 9 should be printed to the console.

Actual behaviour

The TypeScript compiler goes completely apeshit:

(click to see warnings)
test.ts:1:7 - error TS1127: Invalid character.

1 const ๐‘š = 4;
        

test.ts:1:8 - error TS1127: Invalid character.

1 const ๐‘š = 4;
         

test.ts:1:10 - error TS1134: Variable declaration expected.

1 const ๐‘š = 4;
           ~

test.ts:1:12 - error TS1134: Variable declaration expected.

1 const ๐‘š = 4;
             ~

test.ts:2:7 - error TS1127: Invalid character.

2 const ๐‘€ = 5;
        

test.ts:2:8 - error TS1127: Invalid character.

2 const ๐‘€ = 5;
         

test.ts:2:10 - error TS1134: Variable declaration expected.

2 const ๐‘€ = 5;
           ~

test.ts:2:12 - error TS1134: Variable declaration expected.

2 const ๐‘€ = 5;
             ~

test.ts:3:13 - error TS1127: Invalid character.

3 console.log(๐‘€ + ๐‘š); // 9
              

test.ts:3:14 - error TS1127: Invalid character.

3 console.log(๐‘€ + ๐‘š); // 9
               

test.ts:3:18 - error TS1127: Invalid character.

3 console.log(๐‘€ + ๐‘š); // 9
                   

test.ts:3:19 - error TS1127: Invalid character.

3 console.log(๐‘€ + ๐‘š); // 9

โ€ฆ and generates obviously unusable JavaScript:

var ;
4;
var ;
5;
console.log(+); // 9

More info

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 3
  • Comments: 15 (7 by maintainers)

Most upvoted comments

Yeah, disappointing, right? Gotta petition tc39 to specifically add emoji ideographs to the IdentifierPart and IdentifierStart productions.