A
A
Alexey Nikolaev2019-10-21 13:59:46
typescript
Alexey Nikolaev, 2019-10-21 13:59:46

How to import a type from another declaration file in Typescript?

Good day.
There are two declaration files. I'm trying to import one into the other, but it doesn't work.

// module.d.ts
import * as types from 'constants';

declare module '@vendor/module' {
  function createComplex(
    password: string,
    encryptOptions: types.KDF_ENCRYPT_OPTIONS
  ): Promise<any>;
}

// constants.d.ts
export type KDF_ENCRYPT_OPTIONS = {
  kdf: string,
  n: number,
};

tsc says Namespace '"constants"' has no exported member. How to properly export a type?
Thanks in advance.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Stockholm Syndrome, 2019-10-21
@StockholmSyndrome

import * as types from './constants';

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question