Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Export the types from the events and titles modules #7009

Open
cedx opened this issue Jul 23, 2024 · 0 comments
Open

feat: Export the types from the events and titles modules #7009

cedx opened this issue Jul 23, 2024 · 0 comments
Assignees
Labels
area:fast-router Pertains to fast-router community:request Issues specifically reported by a member of the community. improvement A non-feature-adding improvement status:planned Work is planned

Comments

@cedx
Copy link

cedx commented Jul 23, 2024

🙋 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:

image

💁 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 RoutingEventSink and TitleBuilder interfaces
  • extend from DefaultRoutingEventSink or DefaultTitleBuilder classes

💻 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.
	}
}
@cedx cedx added the status:triage New Issue - needs triage label Jul 23, 2024
@KingOfTac KingOfTac self-assigned this Sep 5, 2024
@KingOfTac KingOfTac added improvement A non-feature-adding improvement status:planned Work is planned community:request Issues specifically reported by a member of the community. area:fast-router Pertains to fast-router and removed status:triage New Issue - needs triage labels Sep 5, 2024
@KingOfTac KingOfTac changed the title [FAST Router] Export the types from the events and titles modules feat: Export the types from the events and titles modules Sep 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:fast-router Pertains to fast-router community:request Issues specifically reported by a member of the community. improvement A non-feature-adding improvement status:planned Work is planned
Projects
None yet
Development

No branches or pull requests

2 participants