koral koral - 1 year ago 101
TypeScript Question

Typescript: export interface with different name

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;

Answer Source

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;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download