@types 404找不到angular2

时间:2016-12-31 00:27:03

标签: angular typescript systemjs esri

更新

我在这里添加了代码https://www.dropbox.com/s/g3k4phhqffleeh0/jsapi4-angular2.zip?dl=0,有人请求帮助:(

======

我有一个角色2项目,我分叉并开始工作。

在我真正需要安装某些类型并使用它们之前,一切都很棒且很花哨。 Intellisense选择了打字并找到它们。建筑也不是问题。但是SystemJS似乎无法找到这种类型。我一直在争取这个约10个小时,似乎无法找到解决方案:(。请帮忙。

Screenshot of chrome console

systemjs.config.js

/**
 * System configuration for Angular 2 samples
 * Adjust as necessary for your application needs.
 */
(function (global) {
System.config({
transpiler: 'typescript',

paths: {
  // paths serve as alias
  'npm:': 'node_modules/'
},
// map tells the System loader where to look for things
map: {
  'app': 'app', // 'dist',

  // angular bundles
  '@angular/core': 'npm:@angular/core@2.0.0/bundles/core.umd.js',
  '@angular/common': 'npm:@angular/common@2.0.0/bundles/common.umd.js',
  '@angular/compiler': 'npm:@angular/compiler@2.0.0/bundles/compiler.umd.js',
  '@angular/platform-browser': 'npm:@angular/platform-browser@2.0.0/bundles/platform-browser.umd.js',
  '@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic@2.0.0/bundles/platform-browser-dynamic.umd.js',
  '@angular/http': 'npm:@angular/http@2.0.0/bundles/http.umd.js',
  '@angular/router': 'npm:@angular/router@3.0.0/bundles/router.umd.js',

  // angular testing umd bundles
  '@angular/core/testing': 'npm:@angular/core@2.0.0/bundles/core-testing.umd.js',
  '@angular/common/testing': 'npm:@angular/common@2.0.0/bundles/common-testing.umd.js',
  '@angular/compiler/testing': 'npm:@angular/compiler@2.0.0/bundles/compiler-testing.umd.js',
  '@angular/platform-browser/testing': 'npm:@angular/platform-browser@2.0.0/bundles/platform-browser-testing.umd.js',
  '@angular/platform-browser-dynamic/testing': 'npm:@angular/platform-browser-dynamic@2.0.0/bundles/platform-browser-dynamic-testing.umd.js',
  '@angular/http/testing': 'npm:@angular/http@2.0.0/bundles/http-testing.umd.js',
  '@angular/router/testing': 'npm:@angular/router@3.0.0/bundles/router-testing.umd.js',

  // other libraries
  'rxjs': 'npm:rxjs@5.0.0-beta.12',
  'angular2-in-memory-web-api': 'npm:angular2-in-memory-web-api',

  'esri': 'http://js.arcgis.com/4.0/esri'
},

// packages tells the System loader how to load when no filename and/or no extension
packages: {
  app: {
    main: './main.js',
    defaultExtension: 'js'
  },
  rxjs: {
    defaultExtension: 'js'
  },
  'angular2-in-memory-web-api': {
    main: './index.js',
    defaultExtension: 'js'
  },
  '@types/highcharts': {defaultExtension: 'ts'}
}
});
})(this);

tsconfig.json

{
  "compilerOptions": {
    "target": "es5",
    "module": "system",
    "moduleResolution": "node",
    "sourceMap": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "removeComments": false,
    "lib": [ "es2015", "dom" ],
    "noImplicitAny": false,
    "suppressImplicitAnyIndexErrors": true,
    "typeRoots": ["jsapi4-angular2/node_modules/", "jsapi4-angular2/typings/"]
  },
  "exclude": [
    "node_modules/zone.js",
    "node_modules/concurrently",
    "node_modules/lite-server",
    "node_modules/typescript",
    "node_modules/typings",
    "node_modules/reflect-metadata",
    "node_modules/rxjs",
    "node_modules/tslint",
    "bower_components",
    "typings/main",
    "typings/main.d.ts"
  ]
}

esriSystemLoadBrowser.js

// load esri modules needed by this application
// into a System.js module called esri
console.log("Loading esri modules: ", esriLoadConfig.modules);
start = performance.now();
esriSystem.register(esriLoadConfig.modules, function () {
  // then bootstrap application
  end = performance.now();
  time = end - start;
  console.log('Loaded esri modules', time / 1000.0);
  System.config({
      transpiler: 'typescript'
  });
  System.import('app/main').then(function () {
    console.log('app/main imported');
  }, function (error) {
    console.log("System import error:", error);
  });
});

1 个答案:

答案 0 :(得分:0)

在tsconfig中的compilerOptions中,尝试将typeRoots替换为明确列出无法找到的类型定义文件名称的类型:

types:[...]

另外,请使用"module": "commonjs"