New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@abstraqt-dev/nameof

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@abstraqt-dev/nameof

This is a transformer for the **TypeScript** compiler that adds a whole new **nameof** keyword.

latest
npmnpm
Version
1.0.4
Version published
Maintainers
1
Created
Source

This is a transformer for the TypeScript compiler that adds a whole new nameof keyword.

Example usage with WebPack and ts-loader:

In webpack.config.js:

  • Import the nameof transformer
        const nameOfTransformer = require("./node_modules/@abstraqt-dev/nameof/lib/transformer").default;
  • In the rules sction
        rules: [
        {
            test: /\.(ts|tsx)$/,
            loader: 'ts-loader',
            options: {
                getCustomTransformers: (program) => ({
                    before: [nameOfTransformer(program)],
                    after: []
                })
            },
            exclude: /node_modules/,
        },
  • In tsconfig.json add the library to the included declarations files
    {
        ...,

        "types": [
            "@abstraqt-dev/nameof"
        ],
        
        ...
    }

In your code now you can just use the nameof keyword:

    interface IFoo {

    }

    class Bar {

    }

    let foo = nameof<IFoo>();
    let bar = nameof<Bar>();

    console.log(foo); // "IFoo"
    console.log(bar); // "Bar"

FAQs

Package last updated on 06 May 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts