STEPS TO REPRODUCE: Here's a test case that runs in the JSC shell: >>> var foo = 123; var bar = `aaa bbb '${typeof foo'.`; 42; Unexpected EOF:1 NOTES: A useful error message occurs in this use case: >>> var foo = 123; var bar = `aaa bbb '${typeof foo ccc'.`; 42; Unexpected identifier 'ccc'. Expected a closing '}' following an expression in template literal.:1
> >>> var foo = 123; var bar = `aaa bbb '${typeof foo'.`; 42; There are a couple interesting things here. (1) The error comes from attempting to start parsing the nested template string: This is valid: ` ... ${ ... `nested` }` In the above, the nested template is `; 42;<EOF>`. (2) We could have errored out sooner, in cases like: foo.' (tokenizes a string) foo.` (tokenizes a template string)