-
-
Notifications
You must be signed in to change notification settings - Fork 104
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
overriding Route type when initializing UniversalRouter #185
Comments
@jazblueful, hi! - new UniversalRouter<Context, Route>(routes, options)
+ new UniversalRouter<Context, Result>(routes, options) so, the only way to extend Route type is to add an extended interface in your code and typescript will merge them. import { Route } from 'universal-router'
interface Route {
customProperty: any;
}
// ... I want to allow to redefine Route type in the next router version, see todo in #183 |
hi @frenzzy, However when I try to extend Route type this way I get: "TS2440: Import declaration conflicts with local declaration of 'Route'." |
It looks like merging imported and local interfaces was removed in TS 3.7 https://devblogs.microsoft.com/typescript/announcing-typescript-3-7-rc/#local-and-imported-type-declarations-now-conflict and only option for me is to wait for the next router version. |
Have you tried to add a 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 🤷♂️ |
Awesome! thank you @frenzzy :) |
I'm submitting a ...
I'm having trouble overriding Route type when initializing UniversalRouter:
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.
The text was updated successfully, but these errors were encountered: