Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

187
Views
How to work with types from monorepo in another project

I have a monorepo project which consist of 3 packages. Monorepo structure looks like this:

- packages/
  - common/
    - types.ts
  - ComponentA/
  - ComponentB/

As you can see, in common package I have one file which contains all types (some of them are shared) for both components. When I'm building e.g. ComponentA using Babel and Webpack, at the end all types are emitted in one single file main.d.ts which look like this:

declare module "common/types" {
    export type Foo = {
        width: number;
        height: number;
    };
}

declare module "ComponentA/src/main" {
    export * from "common/types";
}
...

In in main.js file of ComponentA I'm also exporting all types and types are specified in package.json

{
  "name": "ComponentA",
  "version": "1.0.0",
  "main": "dist/main.js",
  "types": "dist/main.d.ts",
  "license": "MIT",
  "files": [
    "dist/*"
  ],
...
}

Problem is, that when I wanna use types of ComponentA (e.g. type Foo) in another typescript based project, types are recognized in two modules like this:

import 'Foo' from 'common/types'
and
import 'Foo' from 'ComponentA/src/main'

I know that type Foo is declared in common/module in generated main.d.ts file but naming 'common/types` doesn't make much sense. How can I improve this? Thanks

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!