MCPcopy Index your code
hub / github.com/IRCraziestTaxi/ts-simple-nameof

github.com/IRCraziestTaxi/ts-simple-nameof @v1.3.3

Chat with this repo
repository ↗ · DeepWiki ↗ · release v1.3.3 ↗ · + Follow
25 symbols 30 edges 7 files 0 documented · 0% updated 11mo ago★ 512 open issues
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

ts-simple-nameof

Parses a class name or a dot-separated property name from a lambda expression and provides some level of type safety using type parameters.

Simple Property Parsing

ts-simple-nameof is very simple. It's not smart. It simply stringifies the supplied lambda expression and parses the property or properties following the first dot after the lambda's argument.

// Returns "posts".
nameof<Comment>(c => c.user); // returns "user"
// Returns "user.posts".
nameof<Comment>(c => c.user.posts);

Assertion operators

With strict null checking, sometimes properties that may be null will throw errors when passing a lambda to this method unless the non-null assertion operator (!) is used. Therefore, this method strips out ! and ? operators from the parsed property name.

class Parent {
    public child?: Child;
}

// Throws error "Object may be 'null'." with strict null checking enabled.
nameof<Parent>(p => p.child.prop);
// Mitigates error and returns "child.prop".
nameof<Parent>(p => p.child!.prop);

Class Names

ts-simple-nameof now also returns the name of a class.

// Returns "User".
nameof(User);

Installation

To add ts-simple-nameof to your project using NPM:

npm install --save ts-simple-nameof

Extension points exported contracts — how you extend this code

Core symbols most depended-on inside this repo

Shape

Class 10
Method 9
Function 4
Interface 2

Languages

TypeScript100%

Modules by API surface

test/nameof.spec.ts19 symbols
src/nameof.ts4 symbols
src/interfaces/nameof-options.interface.ts1 symbols
src/interfaces/nameof-options.interface.d.ts1 symbols

For agents

$ claude mcp add ts-simple-nameof \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page