0
I have a declared module:

declare module conflicts {

  export interface Item {}

  export interface Item2 {}

  export interface Item3 {}

}

I tried ti import this module in component like:

import * from '../../../_models/conflicts/conflicts';

Then use it:

let c = {} as conflicts.item3;

But it does not work

1
  • It should be: export declare module conflicts {} Commented Aug 18, 2018 at 10:30

1 Answer 1

2

The module declaration should look like the following:

export declare module Conflicts {

  export interface Item {}

  export interface Item2 {}

  export interface Item3 {}
}

The import should be:

import * as conflicts from '../../../_models/conflicts/conflicts';

Then, to use the import, do this:

let c = {} as conflicts.Conflicts.Item3;

Notes:

  • conflicts with a lower-case 'c' in the usage is basically the contents of the import.
  • Conflicts with a capital 'C' in the usage is the module itself.
  • Be sure you capitalize the 'I' of 'Item3' to match the interface declaration in the module.
  • In the as conflicts part of the import, you can really change conflicts to anything you want. This is just for setting how the import will be referred to in the rest of the file.
Sign up to request clarification or add additional context in comments.

2 Comments

Please do not post something as an answer that you believe or think it works. If you don't now either test it are try to write it as a comment.
Thanks for the feedback, @PinkieSwirl. I've now tested my solution and made some corrections. I'll be sure to do that before I post an answer in the future.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.