question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"name" is a reserved property.

See original GitHub issue

While trying to add a “meta” property parallel to value named name I was greeted to the full name of the token and not the value I placed there.

e.g.

{
    "a": {
        "b": {
            "c": {
                "value": "1",
                "name": "ds"
            }
        }
    },
    "d": {
        "e": {
            "f": {
                "value": "{a.b.c.name}"
            }
        }
    }
}

tokens:

    "a-b-c": "1",
    "d-e-f": "a-b-c"
}

My use case:

declaration

const path = require("path");
module.exports = {
    asset: {
        font: {
            "primary": {
                value: path.resolve(
                    __dirname,
                    "path/to/font"
                ),
                name: "Font-name",
                "content-type": "application/x-font-woff",
                charset: "utf-8",
                format: "woff"
            }
        }
    }
};

referencing

module.exports = {
    font: {
        family: {
            primary: { value: '{asset.font.primary.name}, sans-serif' }
        }
    }
}

replacing namewith something else works.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
didoocommented, Jan 19, 2019

@rjoaopereira my suggestion is not to mess too much with the expected format of the properties, but t confine all the meta-informations in just a few custom and very controlled fields.

For example, I would avoid this:

{
  "asset": {
    "font": {
      "primary": {
        "value": "123",
        "name": "Roboto",
        "content-type": "application/x-font-woff",
        "charset": "utf-8",
        "format": "woff",
        "deprecated": true,
        "documentation": "Blah blah blah"
      }

in favour of this:

{
  "asset": {
    "font": {
      "primary": {
        "value": "123",
        "meta": {
          "name": "Roboto",
          "content-type": "application/x-font-woff",
          "charset": "utf-8",
          "format": "woff",
        },
        "documentation": {
          "deprecated": true,
          "comment": "Blah blah blah"
        }

The risk of conflict with reserved words and future extensions of the default attributes attached to a property is reduced, and also makes everything semantically more organised.

My 2 cents 😃

1reaction
rjoaopereiracommented, Jan 18, 2019

in general terms, we never mutate the actual values of value and name, and instead create new keys on the object with Symbol('name') and Symbol('value') and then reference those in the formats?

That would be the idea.

So if you supply a name, it will also always be in original

It’s good to know but I prefer to use another key. You never know when the inner workings will change.

I guess using Symbols would negate the need for that.

I believe so.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Reserved Property Definition | Law Insider
Reserved Property means the Land beneath any mobile telephone switching office and other permanent structures (for the avoidance of doubt, other than a...
Read more >
Solved: Naming a property with a reserved keyword for name
Solved: Hi all, I need to write a contract to act as a schema for the rest messages which a legacy system sends....
Read more >
How do I use a C# reserve keyword as a property name - MSDN
according to situation i need to design a class where one property name has to be "return" but when i create a property...
Read more >
javascript - Using reserved words as property names, revisited
In ECMAScript, starting from ES5, reserved words may be used as object property names "in the buff". This means that they don't need...
Read more >
JavaScript Reserved Words - W3Schools
JavaScript Objects, Properties, and Methods ; Array, Date, eval ; hasOwnProperty, Infinity, isFinite ; isPrototypeOf, length, Math ; name, Number, Object ; String ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found