angular - Use globalDependencies (Typescript tsd files) from Angular2 -


i'm trying use typescript tsd's definitelytyped in angular2 project (rc.0), global dependencies doesn't seem load properly:

typings install --save dt~hellojs --global --save npm install --save hellojs 

i've configurations:

typings.json:

"globaldependencies": {   "hellojs": "registry:dt/hellojs#0.2.3+20160423145325" } 

angular.cli.build.js:

module.exports = function(defaults) {   return new angular2app(defaults, {     vendornpmfiles: [       'systemjs/dist/system-polyfills.js',       'systemjs/dist/system.src.js',       'zone.js/dist/**/*.+(js|js.map)',       'es6-shim/es6-shim.js',       'reflect-metadata/**/*.+(js|js.map)',       'rxjs/**/*.+(js|js.map)',       '@angular/**/*.+(js|js.map)',       'angular2-moment/**/*.+(js|js.map)',       'moment/**/*.+(js|js.map)',       'hellojs/**/*.+(js|js.map)'     ]   }); }; 

system-config.ts

/** map relative paths urls. */ const map: = {   'moment': 'vendor/moment',   'angular2-moment': 'vendor/angular2-moment',   'hellojs': 'vendor/hellojs/dist' };  /** user packages configuration. */ const packages: = {   'moment': { main: 'moment.js', defaultextension: 'js' },   'angular2-moment': { main: 'index.js', defaultextension: 'js' },   'hellojs': { main: 'hello.all.js' } }; 

but, if use new dependency angular module, this:

import {component} "@angular/core"; import {formbuilder, controlgroup} "@angular/common"; import {router_directives, router} "@angular/router"; import {loginresourceservice} "../shared/services/resources/login-resource.service"; import {authservice} "../shared/services/auth.service"; import {approutes} "../app-routes";  @component({   moduleid: module.id,   selector: 'app-login',   templateurl: 'login.component.html',   directives: [router_directives],   providers: [loginresourceservice],   styleurls: ['login.component.css'] }) export class logincomponent {    userform:controlgroup;   errormessage:string;    constructor(formbuilder:formbuilder, private _loginresource:loginresourceservice, public router:router,               private _auth:authservice) {     this.userform = this.buildloginform(formbuilder);   }   // ...   example() {     hello.init({});   }  } 

i'm getting compiler errors:

error: typescript found following errors:   /users/fer2d2/dev/personal/web-projects/front-joinfinity/tmp/broccoli_type_script_compiler-input_base_path-xa8whw1k.tmp/0/src/app/+login/login.component.ts (62, 5): cannot find name 'hello'. 

if try import module import * hello "hellojs" or import hello = require("hellojs") fail persists.

how can use globaldependency angular2?

thanks in advance.

edit

with: import {hello} "hellojs" or import hello "hellojs" or import hello = require("hellojs")

i'm getting error:

error: typescript found following errors: /users/fer2d2/dev/personal/web-projects/front-joinfinity/tmp/broccoli_type_scrip‌​t_compiler-input_base_path-tkuubwei.tmp/0/src/app/+login/login.component.ts (7, 21): cannot find module 'hellojs'. 

it seems typescript or systemjs aren't loading globaldependencies tsd's propely.

finally solved problem:

in angular2, using , using angular-cli, have file called typings.d.ts imports typings installed via typings install. in file can see following import line:

/// <reference path="../typings/browser.d.ts" /> 

the browser.d.ts contains typings angular2 between other typings. if want use globaldependencies, typings add them file typings/index.d.ts. so, in typings.d.ts, must add following line:

/// <reference path="../typings/browser.d.ts" /> 

my problem seems related latest update of typings, 'ambient' replaced 'global' prefix dependencies.

https://www.npmjs.com/package/typings#updating-from-0x-to-10


Popular posts from this blog

php - How should I create my API for mobile applications (Needs Authentication) -

5 Reasons to Blog Anonymously (and 5 Reasons Not To)

Google AdWords and AdSense - A Dynamic Small Business Marketing Duo