o..o
o..o

Reputation: 1921

Using Typescript type definition from another file

I have a Typescript definition ./src/@types/moduleA/moduleA.d.ts which contains:

declare module 'moduleA' {
  export interface Transaction {...}
}

And I want to use it in another type definition file ./src/@types/moduleB/moduleB.d.ts like this:

///<reference path="../moduleA/moduleA.d.ts" />

declare module 'moduleB' {
  export class MyClass {
    constructor(private transaction: Transaction) {}
  }
}

But I'm getting Cannot find name 'Transaction'.ts. Why? Do I have to import it as well?

Thank you

Upvotes: 5

Views: 2316

Answers (1)

o..o
o..o

Reputation: 1921

So for anyone searching:

only import { Transaction } from 'moduleA'; should be used.

Upvotes: 4

Related Questions