Wie verwende ich Namespaces mit externen TypeScript-Modulen?

Ich habe einige code:

baseTypes.ts

export module Living.Things {
  export class Animal {
    move() { /* ... */ }
  }
  export class Plant {
    photosynthesize() { /* ... */ }
  }
}

Hund.ts

import b = require('./baseTypes');

export module Living.Things {
  //Error, can't find name 'Animal', ??
  export class Dog extends Animal {
    woof() { }
  }
}

Baum.ts

//Error, can't use the same name twice, ??
import b = require('./baseTypes');
import b = require('./dogs');

module Living.Things {
  //Why do I have to write b.Living.Things.Plant instead of b.Plant??
  class Tree extends b.Living.Things.Plant {

  }
}

Dies ist alles sehr verwirrend. Ich möchte eine Reihe externer Module tragen alle Typen mit den gleichen namespace Living.Things. Es scheint, dass dies überhaupt nicht funktioniert-ich kann nicht sehen Animal im dogs.ts. Ich habe das schreiben der vollständige namespace-name b.Living.Things.Plant im tree.ts. Es funktioniert nicht, mehrere Objekte kombinieren im gleichen namespace in die Datei. Wie mache ich das?

InformationsquelleAutor der Frage Ryan Cavanaugh | 2015-05-20

Schreibe einen Kommentar