How would I export imported namespaces which were generated in typescript?

202 views Asked by At

My project is a microservices project which generates some typescript from .proto files (not relevant). I'd like to create a local npm package that exports what's in these files, in addition to some helper functions that utilize the types/etc... in these files.

I tried:

// package/index.ts
const ns = require('./generated/namespace');
cosnt helper = (a: string) => ns.someHelper(a);
module.exports = { ns, helper };
// package/generated/namespace
export namespace ns {

    class SomeClass extends SomeType {
        // etc......
    }

    interface ISomeType {
        id?: (number|null)
        // etc...
    }

    // and so on...
}

// another_container/index.ts
import { ns } from '@our/package';

When I do that, and bring it into another container, I get this error:

Property 'ns' does not exist on type 'typeof import("/path/to/another_container/node_modules/package/dist/index")'.

Is this even possible?

0

There are 0 answers