TypeScript error in Angular2 code: Cannot find name 'module'

前端 未结 11 1418
梦毁少年i
梦毁少年i 2020-11-30 03:13

I have defined the following Angular2 component:

import {Component} from \'angular2/core\';

@Component({
  selector: \'my-app\',
  moduleId: module.id,
  te         


        
11条回答
  •  时光取名叫无心
    2020-11-30 03:36

    Two key points:

    1. Register typings by running typings install dt~node --global --save. So you'll get the following section in typings.json:

      "globalDependencies": {
          "node": "registry:dt/node#6.0.0+20160608110640"
      }
      
    2. Add reference to the new module. Two ways:

      • Directly add a reference to a dependency in your TS

        ///

      • Add typings/index.d.ts in the files section of the tsconfig.json

        {
            "files": [
                "typings/index.d.ts"
            ]
        }
        

    See more here.

提交回复
热议问题