I'm guessing what you want in src/Models/index.ts is:
export * from "./User";
export * from "./Home";
Then, assuming you have module resolution set up appropriately, you can write:
import { User, UserOptions } from "my-module/Models";
and User and UserOptions will refer to the class and the type alias from src/Models/User.ts, respectively. If src/Models/User.ts and src/Models/Home.ts declare a symbol with the same name, I believe the first export * statement wins.
Module resolution issue
If an import of my-module/ is giving you completions of src and dist, then you would need to import the full relative path to the .js and .d.ts files (which should be next to each other). I assume these files are under dist. If you don't like the dist in your import path, you have a few options, none of them great:
- Don't use
src and dist directories; arrange all files starting from the root of the project.
- Use a module bunder or loader that you can customize so that
import "my-module/Models" looks in the dist folder. If your bundler or loader doesn't already integrate with TypeScript, use TypeScript's path mapping options to make TypeScript's module resolution behavior mirror that of your bundler or loader.
- Redirect each import path individually to the proper files under
dist by manually creating either a pair of .js and .d.ts files that import the real paths or a package.json file with main and types fields that refer to the real paths.
.tsfile, not just a.d.tsfile. Its location needs to match the import path you want to use. I.e., you'd createsrc/Models/index.tsandsrc/View/index.tsfiles that import the necessary items from the source files shown in the picture and re-export them as named exports. I can provide the content of the wrapper.tsfile for you if you add the exports of your existing source files to the question.