angularjs – typescript:import jspm libraries
因此,我在将jspm包导入typescript时发现的大多数示例都假设我想使用Systemjs在浏览器中加载和解释它们.但是,我宁愿使用tsc来构建commonjs模块并只导入js代码,因为在我看来,这对我来说是更通用和错误的方法.
所以我的目录结构如下所示: src/index.ts jspm_packages/... config.js tsconfig.json 使用tsconfig具有以下内容: { "compilerOptions": { "target": "es5","module": "commonjs","noEmitOnError": true,"noImplicitAny": false,"rootDir": "src","outDir": "target/app","sourceMap": true,"experimentalDecorators": true,"emitDecoratorMetadata": true,"declaration": true },"exclude": [ "jspm_packages","node_modules","typings","target" ] } 出于测试目的,我使用jspm install npm:angular2安装了角度2,并尝试通过import {bootstrap}从’angular2 / platform / browser’导入我的index.ts; 运行tsc时,我收到错误 src/index.ts(1,27): error TS2307: Cannot find module 'angular2/platform/browser'. 现在我想知道,我可以使用打字稿知道jspm包吗?我觉得我尝试了一切,从tsconfig排除列表中删除了jspm_packages,切换到节点模块解析或systemjs模块生成.也许我还没找到合适的组合.关于下一步尝试的任何提示? 解决方法
我也在努力解决同样的问题,经过一些研究,我了解到目前还没有很好的解决方案.
解决方法: A)您可以复制依赖项并使用npm进行安装.自从从npm解析后,tsc不应该抛出任何错误. B)更改tsconfig.json并将angular映射到jspm路径.例如 "baseUrl": ".","paths": { "angular2/*": [ "jspm_packages/npm/angular2@2.0.0-beta.7/*" ],"rxjs/*": [ "jspm_packages/npm/rxjs@5.0.0-beta.2/*" ] } 有关完整示例,请参见https://github.com/frankwallis/plugin-typescript/tree/master/examples/angular2. 请注意,“baseUrl”和“paths”不是官方属性,仅适用于typescript编译器的beta版本. 目前正在跟踪此问题: (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
- scala – 在Ubuntu 18.04上安装sbt时出错:`gpg:keyserver
- 缓存 – 如何在使用docker / host卷时保留apt-cache归档目录
- Docker-compose使用主机环境变量
- scala – 在现有列的DataFrame中添加新列
- scala – java.lang.NoClassDefFoundError:org / apache /
- Bootstrap组件之输入框组
- angular – Typescript对象转换不起作用
- 如何使用Scala XML返回空NodeSeq?
- regex – 如何在bash脚本中存储“time”函数输出的子字符串
- 如何让Mathjax与Angular2一起使用?