typescript - Cannot find name 'module'. when using commonjs -
i have 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 run get...
src/ng2/components/hero/hero.component.ts(15,13): error ts2304: cannot find name 'module'.
update
i tried steps according this question
"globaldependencies": { "node": "registry:dt/node#6.0.0+20160608110640" }
but still see...
object literal may specify known properties, , 'module' not exist in type
update 2 after updating bootstrap file this...
import {bootstrap} '@angular/platform-browser-dynamic'; import {herocomponent} './components/hero/hero.component'; import { http_providers } '@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...' not assignable parameter of type '{ selector?: string; inputs?: string[]; outputs?: string[]; properties?: string[]; events?: strin...'. object literal may specify known properties, , 'module' not exist in type '{ selector?: string; inputs?: string[]; outputs?: string[]; properties?: string[]; events?: strin...'.
here project
update
ok, let's put line in typescript definition file , add reference file within bootstrap file. @ top of angular launch script, add:
///<reference path="./path/to/custom.typings.d.ts"/>
you need create file @ path referenced. in file, add line: declare var module:any;
original answer
in angular launch script (the script calls angular's bootstrap
function), add following line near above bootstrap:
declare var module:any;
i'm not sure why error happening since configured dependencies suggested. since know doesn't pose problem, added line compiler stop complaining
Comments
Post a Comment