2

Having error TS2304 during typescript build for all the references of module.id in all of my components definitions. Definition looks like this:

    @Component({
        selector: 'sd-app',
   =>   moduleId: module.id,
        templateUrl: './app.component.html',
        directives: [ROUTER_DIRECTIVES, NavbarComponent, FooterComponent],
        providers: [AuthService]
    })

Here is the error:

app\components\app.component.ts(15,15): error TS2304: Cannot find name 'module'.

Compilation completes and application works fine though.

Any idea how to get rid of this error?

Nexus23
  • 6,195
  • 9
  • 50
  • 67

1 Answers1

3

error TS2304: Cannot find name 'module'

Because TypeScript cannot see the variable module declared anywhere.

Quickfix

Create a globals.d.ts with the following:

declare var module:any;
basarat
  • 261,912
  • 58
  • 460
  • 511
  • Works like a charm. Thanks Basarat. I have put the globals.d.ts in my angular application root location which is the typescript files location for compilation as well. – Nexus23 Mar 31 '16 at 09:40