SystemJS打字稿打字冲突 [英] SystemJS Typescript typing conflict

查看:250
本文介绍了SystemJS打字稿打字冲突的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前在寻找到Angular2,从AngularJS背景的过程。在那件事我也期待到SystemJS和打字稿。结果
 结果
不过,我已经得到了越来越使用打字稿分型和SystemJS Angular2运行的问题。使用打字稿没有按预期工作,但只要我尝试加载从Angular2打字任何模块,SystemJS似乎无法来解决任何分型。结果
从我读过的分型附带的angular2.dev.js,所以只要我进口,我应该没事?结果
 结果
错误有一定的相似性 https://github.com/systemjs/systemjs/issues/610,但不幸的是他的解决方案并没有为我工作。

I'm currently in the process of looking into Angular2, coming from an AngularJS background. In that matter I'm also looking into SystemJS and Typescript.
 
However, I've got an issue getting Angular2 running using Typescript typings and SystemJS. Using Typescript without any typings works as expected, but as soon as I try to load any modules from the Angular2 typing, SystemJS can't seem to resolve it.
From what I've read, the typings are shipped with the angular2.dev.js, so as long as I import that, I should be fine?
 
The error has some similarity with https://github.com/systemjs/systemjs/issues/610, but unfortunately his solutions didn't work for me.

不幸的是我的SystemJS经验以及打字稿是空的,我只是想建立一个系统的学习与。所有的库是最新的,和刚刚安装了故宫。产生的构建是由前的NodeJS preSS服务器承载,而打字稿文件以及其分型都没有。

Unfortunately my experience with SystemJS as well as Typescript is null, and I'm just trying to set up a system to learn with. All the libraries are up to date, and have just been installed with npm. The resulting build is hosted by a NodeJS express server, while the Typescript files as well as their typings are not.

我得到的错误是:

GET http://localhost:8000/angular2/angular2 404 (Not Found)

下面是我的'的index.html'的头提取物:

Here's a head-extract of my 'index.html':

<head>
    <script src="assets/js/lib/traceur.js"></script>
    <script src="assets/js/lib/system.src.js"></script>
    <script src="assets/js/lib/Rx.js"></script>
    <script src="assets/js/lib/angular2.dev.js"></script>

    <script>
        System.config({
            packages: {
                assets: {
                    format: 'register',
                    defaultExtension: 'js'
                },
            }
        });
        System.import( 'assets/js/boot' )
            .then( null, console.error.bind( console ));
    </script>
</head>

&NBSP;

该boot.ts打字稿文件(我只加了引导(),使angular2实际上被纳入编译):

The boot.ts Typescript-file ( I've only added the bootstrap(), so that angular2 actually gets included into the compilation ):

import { bootstrap } from 'angular2/angular2';
bootstrap();
console.log( 'test' );

和TSC编译后生成的boot.js:

and the resulting boot.js after tsc compilation:

System.register(['angular2/angular2'], function(exports_1) {
    var angular2_1;
    return {
        setters:[
            function (angular2_1_1) {
                angular2_1 = angular2_1_1;
            }],
        execute: function() {
            angular2_1.bootstrap();
            console.log('test');
        }
    }
});

//# sourceMappingURL=boot.js.map

tsdconfig.json:

tsdconfig.json:

{
  "compilerOptions": {
    "target": "ES5",
    "module": "system",
    "moduleResolution": "node",
    "sourceMap": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "removeComments": true,
    "noImplicitAny": false
  },
  "exclude": [
    "node_modules"
  ]
}

任何帮助AP preciated很多,有自己的一些不错的假期! :)

Any help appreciated a lot, have yourself some good holidays! :)

推荐答案

据我,你必须设置您的index.html成特定的方式我已经找到最佳的设置为启动是的 https://github.com/pkozlowski-opensource/ng2-play/blob/master/index.html

According to me you have to setup your index.html into particular manner i have found best setup for startup is https://github.com/pkozlowski-opensource/ng2-play/blob/master/index.html.

我的index.html是

my index.html is

<script src="node_modules/angular2/bundles/angular2-polyfills.js"></script>
    <script src="node_modules/es6-shim/es6-shim.min.js"></script>
    <script src="node_modules/systemjs/dist/system.src.js"></script>

    <script>
        System.config({
                    defaultJSExtensions: true,
                    map: {
                        rxjs: 'node_modules/rxjs'
                    },
                    packages: {
                        rxjs: {
                        defaultExtension: 'js'
                      }
                    }
                });
    </script>
    <script src="node_modules/angular2/bundles/angular2.dev.js"></script>
    <script src="node_modules/rxjs/bundles/Rx.js"></script>
    <script src="node_modules/angular2/bundles/router.dev.js"></script>
    <script src="node_modules/angular2/bundles/http.dev.js"></script>

<script>
    System.import('dist/bootstrap');
</script> 

进一步了解更多信息,我只是写下这个名单别人,这可能帮助别人

further for more info i just write down this list for someone else this may help to someone

import {Component, View, Directive, Input, Output, Inject, Injectable, provide} from 'angular2/core'; 

import {bootstrap} from 'angular2/platform/browser';

import {CORE_DIRECTIVES, FORM_DIRECTIVES, NgClass, NgIf  NgForm, Control, ControlGroup, FormBuilder, Validators} from 'angular2/common';

import {RouteConfig, ROUTER_DIRECTIVES, ROUTER_PROVIDERS, Router, LocationStrategy, HashLocationStrategy} from 'angular2/router';

import {Http, HTTP_PROVIDERS, RequestOptions, Headers, Request, RequestMethod} from 'angular2/http'

这篇关于SystemJS打字稿打字冲突的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆