【发布时间】:2016-10-12 17:02:40
【问题描述】:
我有以下代码...
@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/components/hero/hero.component.ts(15,13):错误 TS2304:找不到名称“模块”。
更新
我尝试按照this question做步骤
"globalDependencies": {
"node": "registry:dt/node#6.0.0+20160608110640"
}
但我仍然看到...
对象字面量只能指定已知属性,类型中不存在“模块”
UPDATE 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/components/hero/hero.component.ts(15,5): error TS2345: Argument of type '{ module: string;选择器:字符串;模板:字符串; styleUrls: 字符串[];指令:(typeof He...' 不可分配给类型为 '{ selector?: string; inputs?: string[]; outputs?: string[]; properties?: string[]; events?: strin.. .'. 对象字面量只能指定已知属性,并且 'module' 不存在于 type '{ selector?: string;输入?:字符串[];输出?:字符串[];属性?:字符串[];事件?:字符串...'。
这里是project
【问题讨论】:
标签: typescript