时,我有以下代码...找不到名称'module'。使用CommonJS的
@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"
]
}
但是当我跑我得到...
的src/NG2 /组件/英雄/ hero.component.ts(15 ,13):错误TS2304:找不到名称'module'。
UPDATE
我试图根据this question
"globalDependencies": {
"node": "registry:dt/node#6.0.0+20160608110640"
}
,但我还是看到做的步骤...
对象字面可以只指定已知特性,和'模块'不存在类型
更新2更新引导文件后,看起来像这样...
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 ]);
我仍然看到
的src/NG2 /组件/英雄/ hero.component.ts (15,5):错误TS2345:类型'{module:string;选择器:字符串; template:string; styleUrls:string [];指令:(typeof He ...'不能分配给类型为'{selector?:string; inputs?:string [];输出?:string [];属性?:string [];参数的事件? '。 对象字面量只能指定已知属性,而'模块'不存在于类型'{selector ?: string; inputs ?: string []; outputs ?: string []; properties ?: string []; events ?:〜应变...“
这里是project
试过了,但我似乎仍然有问题。有任何想法吗?查看更新 – Jackie
结帐我编辑的答案。也许该行必须位于打印稿定义文件中。 – BeetleJuice
我会尝试一下,我仍然可以使用systemJS作为我的transpiler吗? – Jackie