Proposal: Add `NoSubstitutionTemplate` to `StringLiteral` Definition

FERREIRA, ERIC B EF183V at att.com
Wed Jan 9 17:35:13 UTC 2019


Some teams opt to use exclusively template strings in their code (see template literals are strictly better strings<https://ponyfoo.com/articles/template-literals-strictly-better-strings> for some reasoning).

This is almost supported by ECMA, but for the fact that `StringLiteral`<https://tc39.github.io/ecma262/#prod-StringLiteral> is expressly defined as either a single quote or double quote string, excluding `NoSubstitutionTemplate`s<https://tc39.github.io/ecma262/#prod-NoSubstitutionTemplate>.

I contend that adding `NoSubstitutionTemplate`s<https://tc39.github.io/ecma262/#prod-NoSubstitutionTemplate> to the definition of `StringLiteral`<https://tc39.github.io/ecma262/#prod-StringLiteral> will bring the benefit of allowing teams to completely opt to use only template strings instead of mixing quote marks, while having very little risk or downside, if any at all.

`NoSubstitutionTemplate`s<https://tc39.github.io/ecma262/#prod-NoSubstitutionTemplate> by nature are completely defined at "compile" time, essentially being exact same in functionality as standard `StringLiteral`s<https://tc39.github.io/ecma262/#prod-StringLiteral>. Let's make it so in the grammar as well?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20190109/33ac1f99/attachment.html>


More information about the es-discuss mailing list