dsherret / ts-nameof

nameof in TypeScript
MIT License
492 stars 23 forks source link

Resolve some property access expressions at compile time? #91

Closed dsherret closed 4 years ago

dsherret commented 4 years ago

From https://github.com/dsherret/ts-nameof/issues/42#issuecomment-455343611

It might be nice to inspect if certain property access expressions on the result of nameof calls could be resolved at compile time if able:

nameof.split<IState>(state => state.a.b.c).join("/");

Compiles to:

"a/b/c";

Problem: Someone may have overriden the behaviour of prototype methods like Array.prototype.join. Response: If someone is changing the behaviour of these prototype methods then that is their problem. Workaround: const array = nameof.split<IState>(state => state.a.b.c); const result = array.join("/");?

dsherret commented 4 years ago

This doesn't seem worth the added complexity.