Proposal: Add `NoSubstitutionTemplate` to `StringLiteral` Definition

Andrea Giammarchi andrea.giammarchi at gmail.com
Wed Jan 9 19:40:04 UTC 2019


I dare saying tags are another issue here, 'cause "abc" === "abc", and with
an identity function such `const id = o => o`, `id("abc") === id("abc")`
but due latest changes to template literals, id`abc` !== id`abc` so it's
easily misleading in the tagged case.

On Wed, Jan 9, 2019 at 7:53 PM Jordan Harband <ljharb at gmail.com> wrote:

> import path specifiers are another.
>
> On Wed, Jan 9, 2019 at 10:16 AM T.J. Crowder <
> tj.crowder at farsightsoftware.com> wrote:
>
>> On Wed, Jan 9, 2019 at 5:36 PM FERREIRA, ERIC B
>> <EF183V at att.com> wrote:
>> > I contend that adding `NoSubstitutionTemplate`s to the definition of
>> > `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.
>>
>> I've been toying with defaulting to template literals for some time. :-)
>>
>> Interesting idea. Where specifically do you see benefits of this
>> change? The only places that immediately jump out to me are
>>
>> * "use strict", mentioned in your linked article
>> * Quoted property names in object initializers (aka "object literals")
>> -- oddly not mentioned in that article (it mentions JSON, but not
>> object initializers)
>>
>> That second one could be a bit of a footgun for people, who may trip
>> over this working:
>>
>> ```js
>> const obj = {`I have a space`: `bar`};
>> ```
>>
>> ...but this failing:
>>
>> ```js
>> const obj = {`I have a space ${x}`: `bar`};
>> ```
>>
>> ...because that's not a NoSubstitutionTemplate and so it needs to be a
>> computed property name.
>>
>> Are there other places?
>>
>> -- T.J. Crowder
>> _______________________________________________
>> es-discuss mailing list
>> es-discuss at mozilla.org
>> https://mail.mozilla.org/listinfo/es-discuss
>>
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20190109/73cace01/attachment-0001.html>


More information about the es-discuss mailing list