Prelude
The question changed the example code but they originally had exported a module
and interface with the same name and tried to reference the module in a context where only the interface was valid. While it is not necessarily incorrect to share a name between two different declarations of separate language constructs, it did obscure the true issue they were experiencing (see original answer below).
Original Answer
If we clean up the naming of your types, we can figure out pretty quickly what's wrong here.
In TriggerEvent, we rename the interface Trigger to ITrigger:
export interface ITrigger {
// ..
}
export module Trigger {
//...
export function Serialise(restoredEvent: ITrigger) {
//...
}
}
Now, in ActionManager, we can see what went wrong:
import { Trigger as TriggerBase } from "./TriggerEvent";
export module ActionManager {
type Trigger = TriggerBase & (typeof Trigger);
// ^^^^^^^^^^^
// ERROR - Cannot use namespace 'TriggerBase' as a type.
var Trigger = TriggerBase;
var EventsByID = new Map<UUID, Trigger>();
var PrepreparedInputs = new Map<UUID, Trigger.Serialised>();
// ^^^^^^^
// ERROR - 'Trigger' only refers to a type, but is being used as a namespace here.
}
You cannot use a namespace (module) as a type. (see the docs). Before, since the interface and the module were named the same, TypeScript went with the context-appropriate option, the interface. Ergo, no errors there! Regardless, we still have the original error 'Trigger' only refers to a type... because a type is a type, and not a namespace (or module).
Finally, ActionManager.Trigger.Serialise(stuff); isn't working because Trigger isn't exported from the ActionManager module.
Solution
Since you can't assign a module to a type, reference the module directly in your PreparedInputs:
var PrepreparedInputs = new Map<UUID, TriggerBase.Serialised>();
And, as you did with TriggerEvent, export what types/variables you want to use outside a module:
// The interface was renamed to ITrigger in TriggerEvent.
import { Trigger as TriggerBase, ITrigger } from "./TriggerEvent";
export module ActionManager {
export var Trigger = TriggerBase;
export var EventsByID = new Map<UUID, ITrigger>();
export var PrepreparedInputs = new Map<UUID, TriggerBase.Serialised>();
}