I need to import interface, add property to id and export the new interface with the same name as original one. Then in all places where this interface is used I can only change import location.
import { Routes, Route } from '@angular/router';
interface Route2 extends Route {
description: string;
}
export declare type Routes = Route2[];
And then I'd like to (although it is not possible)
export Route2 as Route;
Import the original Route
under a different name and export the new one as Route
import { Route as OriginalRoute } from '@angular/router';
export interface Route extends OriginalRoute {
description: string;
}
You can do it with export type which allows you to provide an alias for the interface.
General example (Alias being the new name and SomeInterface the original):
export type Alias = SomeInterface;
Your specific scenario:
import { Routes, Route } from '@angular/router';
interface Route2 extends Route {
description: string;
}
export type Route = Route2;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.