0

I need to find path to the file from which the class/interface is exported. Let's say i have a file builder.ts inside ./src folder with following content:

export class Builder {}

And i have index.ts in current directory, with following content:

import { Builder } from "./src/builder";

Later, i might need to know the path to the file, from which Builder class was imported, so i want to have some kind of function, that would take a class/interface/ and return the path to the file where the entity is defined. So i could write something like this in the index.ts file

const path = getPath(Builder)

And path variable should equal to "./src/builder". Is it possible to have this kind of function?

Hayk
  • 149
  • 1
  • 11

0 Answers0