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.

Support for Property Accessors

See original GitHub issue

Hi - do you plan to support property accessors? i.e.:

new LinqRepository(Entity).getOne()
    .joinAlso(e => e["someChild"])

I’ve patched ts-simple-nameof locally to get it to work for me, by changing one of the regular expressions:

diff --git a/node_modules/ts-simple-nameof/src/nameof.js b/node_modules/ts-simple-nameof/src/nameof.js
index e084038..7c3e4d9 100644
--- a/node_modules/ts-simple-nameof/src/nameof.js
+++ b/node_modules/ts-simple-nameof/src/nameof.js
@@ -23,7 +23,7 @@ function nameof(nameFunction, options) {
     //   "function(x){return x.prop}"
     // FYI - during local dev testing i observed carriage returns after the curly brackets as well
     // Note by maintainer: See https://github.com/IRCraziestTaxi/ts-simple-nameof/pull/13#issuecomment-567171802 for explanation of this regex.
-    var matchRegex = /function\s*\(\w+\)\s*\{[\r\n\s]*return\s+\w+\.((\w+\.)*(\w+))/i;
+    var matchRegex = /function\s*\(\w+\)\s*\{[\r\n\s]*return\s+\w+(?:\[\"|\.)((\w+\.)*(\w+))/i;
     var es5Match = fnStr.match(matchRegex);
     if (es5Match) {
         return (options && options.lastProp)

I appreciate such a change may be counter to your goals for the package (or maybe it’s just a bad idea!).

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
MikeBKempcommented, Jul 28, 2021

@Huxpro

Thanks for letting me know about the change. Unfortunately I cannot get the RC to build (probably some of my dependencies are incompatible, and it would take some time to recreate my use case in a fresh project). However https://github.com/facebook/hermes/issues/114#issuecomment-887106990 certainly looks very promising and should fix my issue.

0reactions
Huxprocommented, Jul 27, 2021

@MikeBKemp

I’m writing a React Native app with the Hermes engine, and facebook/hermes#114 breaks ts-simple-nameof.

I don’t know anything about ts-simple-nameof but if your use case was blocked by https://github.com/facebook/hermes/issues/114, we are adding a special directive "show source" to make toString returning original source code. Would you mind try it with React Native 0.65-rc.3 and see if it helps? You can find more details at https://github.com/facebook/hermes/issues/114#issuecomment-887106990

Read more comments on GitHub >

github_iconTop Results From Across the Web

Property accessors - JavaScript - MDN Web Docs - Mozilla
Property accessors provide access to an object's properties by using the dot notation or the bracket notation. Try it.
Read more >
Properties - C# Programming Guide - Microsoft Learn
Properties can be used as if they're public data members, but they're special methods called accessors. This feature enables data to be accessed ......
Read more >
PHP RFC: Property Accessors
Implicit accessors, which allow finely controlling property access. They support both read-only and private-write properties. Explicit accessors ...
Read more >
AngelScript: Property accessors - AngelCode.com
Property accessors can be used to emulate a single property or an array of properties accessed through the index operator. Property accessors for...
Read more >
Cook County Assessor's Office: We are Here to Help
The Assessor's Office Wins National Awards for Transparency and Fairness · Missing Property Tax Exemptions? Homeowners can apply for Certificates of Error.
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