darkbasic / angularcli-meteor

13 stars 4 forks source link

Cannot find interface defined in api/server/models.ts #1

Open rgal75 opened 6 years ago

rgal75 commented 6 years ago

Starting out from the project at master, I tried to add some more features and found that if I start using interface types then webpack is complaining that it cannot find the interface.

How to reproduce:

  1. Start from the angularcli-meteor project at master
  2. In app.component.ts at line 17, add the correct typing (Chat) to the callback parameter. (The Chat interface is already imported.)
    ...
    ngOnInit() {
    Chats.find({}).subscribe((chats: Chat[]) => {
      console.log(chats);
      this.chats = chats;
    });
    }
    ...
  3. Run npm run start

Result:

ERROR in .../angularcli-meteor-master/src/app/app.component.ts (17,38): Cannot find name 'Chat'.

Note

Thanks for your efforts to create this boilerplate. It's really useful.

darkbasic commented 6 years ago

Yeah, I noticed that but I still didn't have the time to investigate. I will probably start migrating the whole Ionic2CLI-meteor tutorial to angularcli in a couple of weeks, so I will have a look.

mucahittekin commented 6 years ago

@rgal75 I think you should remove baseUrl from src/tsconfig.app.json file.

rgal75 commented 6 years ago

@mucahittekin I tried that but unfortunately it does not work.

darkbasic commented 6 years ago

First of all: let's remove declare module '*' from src/declarations.d.ts which hides useful warnings for no reason.

The issue is that webpack aliases do not work with angular-cli and I don't know why. They had their own solution with awesome-typescript-loader, but they now removed it to switch to AotPlugin from @ngtools/webpack.

Unfortunately I still didn't manage to make it work: https://github.com/angular/angular-cli/issues/1465#issuecomment-337235127

darkbasic commented 6 years ago

For the moment I simply removed the alias and used relative paths.

rgal75 commented 6 years ago

This is what I also ended up eventually.