feat: Export the types from the `events` and `titles` modules
🙋 Feature Request
It's pretty common in my projects to customize/override the createEventSink() and createTitleBuilder() methods from the RouterConfiguration class. But the related types (i.e. RoutingEventSink, TitleBuilder, etc.) are not exported by the package.
So, I would like to be able to consume these types in my code.
🤔 Expected Behavior
Be able to import types from the events and titles modules:
import type {RoutingEventSink, TitleBuilder} from "@microsoft/fast-router";
😯 Current Behavior
A TypeScript error (i.e. TS2459) is raised:
💁 Possible Solution
Export the events.ts and titles.ts modules in the index.ts file:
export * from "./events.js";
export * from "./titles.js";
🔦 Context
I need in some projects to provide custom RoutingEventSink and TitleBuilder in order to customize the router behavior.
But the interfaces and classes from the events and titles modules are not exported, so I can't create types that:
- implement
RoutingEventSinkandTitleBuilderinterfaces - extend from
DefaultRoutingEventSinkorDefaultTitleBuilderclasses
💻 Examples
Currently, I use the following RoutingEventSink implementation to dispatch events. This implementation could be shorter if I could reuse the DefaultRoutingEventSink class.
class RoutingEventSink /* extends DefaultRoutingEventSink */ {
onNavigationBegin(): void {
dispatchEvent(new Event("router:navigating"));
}
onNavigationEnd(): void {
dispatchEvent(new Event("router:navigated"));
}
onPhaseBegin(): void {
// Do nothing.
}
onPhaseEnd(): void {
// Do nothing.
}
onUnhandledNavigationMessage(): void {
// Do nothing.
}
}