Import function name from ts-nameof package which is not exported to d.ts

I found an interesting package and want to use it in a typescript application: https://github.com/dsherret/ts-nameof

But I cannot import the function nameof

. It is not exported to the d.ts file:

declare module "ts-nameof" {
    interface Api {
        ...
    }
    var func: Api;
    export = func;
}

declare function nameof<T>(func?: (obj: T) => void): string;
declare function nameof(obj: Object | null | undefined): string;
declare namespace nameof {
    function full<T>(periodIndex?: number): string;
    function full(obj: Object | null | undefined, periodIndex?: number): string;
}

      

How do I import the function nameof

into my typescript module?

for import 'ts-nameof';

I have an error Uncaught ReferenceError: nameof is not defined

.

+3


source to share


1 answer


Add this to tsd.d.ts

:

/// <reference path="../node_modules/ts-nameof/ts-nameof.d.ts" />

      



Make sure to enter the correct path to node_modules

0


source







All Articles