5

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;

2 Answers 2

5

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;
}
Sign up to request clarification or add additional context in comments.

Comments

3

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;

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.