Recently, I came across a captivating package that caught my interest and I would love to incorporate it into my TypeScript application: https://github.com/dsherret/ts-nameof
However, upon attempting to import the nameof
function, I realized it was not being exported in the d.ts file as expected:
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;
}
I am now left wondering about how I can successfully import the nameof
function into my TypeScript module. The initial attempt of using import 'ts-nameof';
led to an error message stating
Uncaught ReferenceError: nameof is not defined
.