easy-tsnameof

Typescript nameOf function. Safe types

Usage no npm install needed!

<script type="module">
  import easyTsnameof from 'https://cdn.skypack.dev/easy-tsnameof';
</script>

README

Easy Typescript NameOf

Install

yarn add easy-tsnameof
npm install easy-tsnameof

How to use?

import nameOf from 'easy-tsnameof';

type NameOfTest = {
  test1: {
    test2: {
      test3: string;
    };
  };
};
const resultString = nameOf<NameOfTest>((o) => o.test1.test2.test3);
// test1.test2.test3
import { nameOfFabric } from 'easy-tsnameof';

type NameOfTest = {
  test1: {
    test2: {
      test3: string;
    };
  };
};
const f = nameOfFabric<NameOfTest>();
const resultString = f((o) => o.test1.test2.test3);
// test1.test2.test3