'How to group export members in Typescript?

In my package, I have multiple dependencies. I am trying to create a single entry point for all dependencies.

Dependency 1 (Exists in NPM)

export interface A {}
export type B = {}
export function C() {}

Dependency 2 (Exists in NPM)

export interface A {}
export function B() {}

Entry point (In my package)

export * as dependency1 from "dependency-1"
export * as dependency2 from "dependency-2"

I have done this to avoid collision. But, the issue is when I try to access any type or interface, it doesn't work.

Consumer

import { dependency1, dependency2 } from "./entry";

// works like a charm
dependency1.C()

// Shows error: "A" is not a property of `dependency1`
const a1: dependency1.A = {...}

// Shows error: "A" is not a property of `dependency2`
const a2: dependency2.A = {...}

How do I resolve this? Any other alternative I can try?

tsconfig.json

{
  "compilerOptions": {
    "target": "es5",
    "lib": [
      "dom",
      "dom.iterable",
      "esnext"
    ],
    "allowJs": true,
    "skipLibCheck": true,
    "esModuleInterop": true,
    "allowSyntheticDefaultImports": true,
    "strict": true,
    "forceConsistentCasingInFileNames": true,
    "noFallthroughCasesInSwitch": true,
    "module": "esnext",
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "noEmit": true,
    "jsx": "react-jsx"
  },
  "include": [
    "src"
  ]
}


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source