2

When I use namespaces in the same file, everything works fine, however, I would like to split all the classes into their files an then I'm getting import errors. This code is just an example, I need to extend class A more times and then it gets even worst.

namespace a {
    export abstract class A {
        protected abstract message(message: string): void;
        message(message: string): void {
            this.message(message);
        }
    }
}
namespace a {
 export class B extends A {
     public message(message: string) {
         console.log(message);
     }
 }
}

namespace a {
    export class Message {
        public static createMessage(): A {
            return new B()
        }
    }
}

import Message = a.Message;
const message = Message.createMessage();
message.message("My custom message");
MrHr
  • 21
  • 2
  • They can just be imported like any other class. Note that all the namespaces need their own imports. Have a look at this question: https://stackoverflow.com/q/30357634 – MagicLegend Dec 13 '18 at 10:39

0 Answers0