angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

use local share library will get error : Two different types with this name exist, but they are unrelated.

Open lichunbin814 opened this issue 9 years ago • 3 comments

Bug Report or Feature Request (mark with an x)

- [ ] feature request

Versions.

@angular/cli: 1.4.4 node: 6.11.2 os: darwin x64 macOS

Repro steps.

folder structure

  • root -- shared-layout -- my_project

I add my share library(shared-layout) by angular Cli from local to my node_module, then I use the declaration of Route in my_project from my_share_libary, it will get some error about Type 'Route' is not assignable to type 'Route'. Two different types with this name exist, but they are unrelated.

npm i ../shared-layout


/* shared-layout */
import { Route } from '@angular/router';

export interface LayoutRoute extends Route {
        data?: LayoutRouteData;
        children?: LayoutRoute[];
}

export interface LayoutRouteData {
    someProperty?: {
        someValue : number;
    };
}

/* my_project */
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { LayoutRoute } from 'shared-layout/src/shared/layout';

const routes: LayoutRoute[] = [
  { path: 'item', component: ItemComponent },
];

@NgModule({
  imports: [RouterModule.forChild(routes)],
  exports: [RouterModule],
})
export class AppRoutingModule { }

The log given by the failure.

[ts]
Argument of type 'LayoutRoute[]' is not assignable to parameter of type 'Route[]'.
  Type 'LayoutRoute' is not assignable to type 'Route'.
    Types of property 'matcher' are incompatible.
      Type 'UrlMatcher' is not assignable to type 'UrlMatcher'. Two different types with this name exist, but they are unrelated.
        Types of parameters 'route' and 'route' are incompatible.
          Type 'Route' is not assignable to type 'Route'. Two different types with this name exist, but they are unrelated.
            Types of property 'matcher' are incompatible.
              Type 'UrlMatcher' is not assignable to type 'UrlMatcher'. Two different types with this name exist, but they are unrelated.
                Types of parameters 'route' and 'route' are incompatible.
                  Type 'Route' is not assignable to type 'Route'. Two different types with this name exist, but they are unrelated.
                    Types of property 'matcher' are incompatible.
                      Type 'UrlMatcher' is not assignable to type 'UrlMatcher'. Two different types with this name exist, but they are unrelated.

Desired functionality.

I want to avoid error from my_proejct when I use file by locale shared library(shared-layout)

Type 'Route' is not assignable to type 'Route'. Two different types with this name exist, but they are unrelated.

Mention any other details that might be useful.

https://github.com/lichunbin814/TestAngularShareLibary/tree/master

Thanks for your help!!!!

lichunbin814 avatar Oct 27 '17 12:10 lichunbin814

Are you still able to reproduce this issue with the latest version?

mgechev avatar Dec 22 '18 02:12 mgechev

Closing it due to inactivity. If the problem is still reproducible with the latest CLI, please open a new issue following the template and sharing a minimal demo where we can reproduce it. Thank you! :)

mgechev avatar Dec 24 '18 20:12 mgechev

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.