question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

overriding Route type when initializing UniversalRouter

See original GitHub issue

I’m submitting a …

  • bug report
  • feature request
  • other (Please do not submit support requests here (below))

I’m having trouble overriding Route type when initializing UniversalRouter:

interface MyRouteType {
  customProperty: any;
}

const router = new UniversalRouter<MyContextType, MyRouteType>(routes, {
  async resolveRoute(context, params) {
    if (context.route.customProperty) {
       console.log(context.route.customProperty);
    }
  },
});

My IDE is complaining that customProperty doesn’t exist on context.route

I fixed it like this: http://www.mergely.com/oC2xyDZh/, but I’m still new to typescript and I’m not sure if my fix is any good.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
frenzzycommented, Jan 30, 2020

Have you tried to add a universal-router.d.ts in your project source root with the following content?

declare module 'universal-router' {
  export interface Route {
    customProperty: any;
  }
}

Just found an article: TypeScript: Adding Custom Type Definitions for Existing Libraries

Also I will try to find time next week to update PR #183 and release v9, but it is not guaranteed 🤷‍♂️

0reactions
webicancommented, Jan 30, 2020

Awesome! thank you @frenzzy 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Configuring IPv4 Static and Default Routes (Solution) Topology
Step 1: Cable the network as shown in the topology. Step 2: Initialize and reload the router and switch. Part 2: Configure Basic...
Read more >
How to Advertise a Default Route - CBT Nuggets
Default routes ensure things get to where they need to be despite all the different networks and devices out there. Learn how default...
Read more >
Can't reload/refresh active route - angular - Stack Overflow
The first thing you will need to do is set the option within your app.routing.ts if you have one or the file where...
Read more >
Basic BGP Routing Policies | Junos OS - Juniper Networks
Each routing policy is identified by a policy name. The name can contain letters, numbers, and hyphens (-) and can be up to...
Read more >
Universal Routing 8.1 Deployment Guide
Warm Standby means that a backup application server is initialized and ready ... External Routing Point and a route type of Overwrite DNIS....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found