Downlevel emit for template strings should use 'void 0' not 'undefined' #38430
Labels
Bug
A bug in TypeScript
Fixed
A PR has been merged for this issue
Good First Issue
Well scoped, documented and has the green light
Help Wanted
You can do this
Milestone
TypeScript Version: 3.9.x, 4.0.x-dev
Search Terms: template string emit
Code
From
~/tests/cases/conformance/es2018/invalidTaggedTemplateEscapeSequences.ts
:Expected behavior:
ES5/ES3 emit:
Actual behavior:
ES5/ES3 emit:
In ES5,
undefined
is an identifier and not a keyword and can be redeclared. In ES3,undefined
isn't declared. In general we emitvoid 0
in these cases.This can be easily addressed by changing
createTemplateCooked
in~/src/compiler/transformers/taggedTemplate.ts
to returncreateVoidZero()
instead ofcreateIdentifier("undefined")
when a template contains an invalid escape sequence..Playground Link: link
Related Issues: #23801, #12700
The text was updated successfully, but these errors were encountered: