1

I have the following code...

@Component({
    module: module.id, 
    selector: 'hero',
    templateUrl:'hero.component.html',
    styleUrls: ['hero.component.css'],
    directives: [HeroDetailComponent, MD_CARD_DIRECTIVES, MD_BUTTON_DIRECTIVES, MD_LIST_DIRECTIVES, MD_ICON_DIRECTIVES, MdToolbar, MD_INPUT_DIRECTIVES],
    providers: [HeroService],
    viewProviders: [MdIconRegistry]
})
export class HeroComponent implements OnInit{
...
}

//tsconfig.js
{
  "compilerOptions": {
    "target": "es5",
    "module": "commonjs",
    "rootDir": "src/ng2",
    "moduleResolution": "node",
    "sourceMap": false,
    "inlineSources": true,
    "inlineSourceMap": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "removeComments": false,
    "outDir": "public/ng2",
    "noImplicitAny": false
  },
  "exclude": [
    "node_modules",
    "typings/main",
    "typings/main.d.ts"
  ]
}

But when I run I get...

src/ng2/components/hero/hero.component.ts(15,13): error TS2304: Cannot find name 'module'.

UPDATE

I tried to do the steps according to this question

"globalDependencies": {
  "node": "registry:dt/node#6.0.0+20160608110640"
 }

but I still see...

Object literal may only specify known properties, and 'module' does not exist in type

UPDATE 2 after updating the bootstrap file to look like this...

import {bootstrap}     from '@angular/platform-browser-dynamic';
import {HeroComponent} from './components/hero/hero.component';
import { HTTP_PROVIDERS } from '@angular/http';
declare var module:any;
bootstrap(HeroComponent, [ HTTP_PROVIDERS ]);

I still see

src/ng2/components/hero/hero.component.ts(15,5): error TS2345: Argument of type '{ module: string; selector: string; template: string; styleUrls: string[]; directives: (typeof He...' is not assignable to parameter of type '{ selector?: string; inputs?: string[]; outputs?: string[]; properties?: string[]; events?: strin...'. Object literal may only specify known properties, and 'module' does not exist in type '{ selector?: string; inputs?: string[]; outputs?: string[]; properties?: string[]; events?: strin...'.

Here is the project

Community
  • 1
  • 1
Jackie
  • 21,969
  • 32
  • 147
  • 289

1 Answers1

1

Update

Ok, let's put that line in a typescript definition file and add a reference to that file within the bootstrap file. At the top of the your Angular launch script, add:

///<reference path="./path/to/custom.typings.d.ts"/>

You then need to create a file at the path referenced. In that file, add the line: declare var module:any;

Original Answer

In your Angular launch script (the script that calls Angular's bootstrap function), add the following line near above bootstrap:

declare var module:any;

I'm not sure why this error is happening since like you I configured my dependencies as suggested. Since I know it doesn't pose any problem, I just added the line to get the compiler to stop complaining

BeetleJuice
  • 39,516
  • 19
  • 105
  • 165