我正在尝试使用Aurelia& amp;打字稿。
我按照我在网上找到的最新指示。使用vs模板创建项目后,我在项目根目录中运行了jspm init,并将baseurl配置为wwwroot。我遇到的第一个问题是VS拒绝将jspm_packages作为项目中的文件夹。所以,我再次运行jspm并将packages文件夹更改为wwwroot / lib 这似乎有效,但打字稿不会让我导入任何Aurelia包。我下载骨架项目进行比较。我注意到两件事,骨架使用旧版本的Aurelia,而不是我使用jspm install时得到的版本。其次,使用.d.ts文件下载软件包。我怀疑丢失的.d.ts文件导致智能感知问题。
到目前为止,我一直无法弄清楚如何让jspm给我旧版本,我已经尝试更改package.json文件以匹配骨架应用程序中的内容,但是当我运行jspm install时,我总是得到最新的版本。
是否已从jspm软件包中删除了这些类型?这项工作的正确工作流程是什么?
答案 0 :(得分:5)
处理TypeScript类型的最佳做法是Typings模块,以前是DefinitelyTyped。首先,通过从命令行运行npm install typings --global
来安装Typings。
接下来,在项目的根目录中创建一个typings.json
文件,其中包含以下依赖项:
<强> typings.json 强>
{
"name": "my-project",
"globalDependencies": {
"aurelia-binding": "github:aurelia/binding/dist/aurelia-binding.d.ts#69d54dbebafe87738f89b8ac4109921544d202cb",
"aurelia-bootstrapper": "github:aurelia/bootstrapper/dist/aurelia-bootstrapper.d.ts#111ee4eb1e5df7af39305d190d635df7d93cb7e5",
"aurelia-dependency-injection": "github:aurelia/dependency-injection/dist/aurelia-dependency-injection.d.ts#dcb53d40d128f5ff89c6bafa587128583529bd68",
"aurelia-event-aggregator": "github:aurelia/event-aggregator/dist/aurelia-event-aggregator.d.ts#7a38c51dc9082175461e2d0b21a4c0a9242a8925",
"aurelia-fetch-client": "github:aurelia/fetch-client/dist/aurelia-fetch-client.d.ts#a97fa7b9484cd78d986b11e537394400c99d02fe",
"aurelia-framework": "github:aurelia/framework/dist/aurelia-framework.d.ts#e008c4a98147ae39556892a69e5c165947e293a7",
"aurelia-history": "github:aurelia/history/dist/aurelia-history.d.ts#21e1ecd279b5b6d7525103cf734318103aee5382",
"aurelia-history-browser": "github:aurelia/history-browser/dist/aurelia-history-browser.d.ts#19e095308a414ab561d3c5b327fcbc756e60f457",
"aurelia-loader": "github:aurelia/loader/dist/aurelia-loader.d.ts#5bc0bf9424946235bc6d63ce77f4a6b97b0b4742",
"aurelia-logging": "github:aurelia/logging/dist/aurelia-logging.d.ts#62417b8db6b82ef9c4dfe09eeca5cef6714e3b40",
"aurelia-logging-console": "github:aurelia/logging-console/dist/aurelia-logging-console.d.ts#a82125fb35a1efc6372c40b7cd5813cfbda1eb11",
"aurelia-metadata": "github:aurelia/metadata/dist/aurelia-metadata.d.ts#96c4c332fe4669e11b7570d3e8996cced9cf9042",
"aurelia-pal": "github:aurelia/pal/dist/aurelia-pal.d.ts#adc7e905abf4f76d1c71a19f740cb6bb45d5842e",
"aurelia-pal-browser": "github:aurelia/pal-browser/dist/aurelia-pal-browser.d.ts#ce3451eeeb2feb2c62ec30ec3f6a0122b4209282",
"aurelia-path": "github:aurelia/path/dist/aurelia-path.d.ts#762d6dd77200672080e6a24e6db9ab37b0dc6137",
"aurelia-polyfills": "github:aurelia/polyfills/dist/aurelia-polyfills.d.ts#e97d36f958436057ff277c00ce58a0edf42adfed",
"aurelia-route-recognizer": "github:aurelia/route-recognizer/dist/aurelia-route-recognizer.d.ts#2c89fa3ffd739262cc8f901514f314a25f21c9c1",
"aurelia-router": "github:aurelia/router/dist/aurelia-router.d.ts#39f05b6c85925829baa8be1256fc9ee9430e5854",
"aurelia-task-queue": "github:aurelia/task-queue/dist/aurelia-task-queue.d.ts#18ac85b517430a3ad8a390cc6bb114abad499bb1",
"aurelia-templating": "github:aurelia/templating/dist/aurelia-templating.d.ts#aad25d550f316ac2d7cac29c330059897c7d15bd",
"aurelia-templating-binding": "github:aurelia/templating-binding/dist/aurelia-templating-binding.d.ts#f90d1082b0aa3be71c23e26c1e152b22593a15b5",
"aurelia-templating-resources": "github:aurelia/templating-resources/dist/aurelia-templating-resources.d.ts#98f81efd2d7270742bfaa1f3c37d8a71a3936172",
"aurelia-templating-router": "github:aurelia/templating-router/dist/aurelia-templating-router.d.ts#68460e0398f896c5883be81588bdd5f3855f05c3"
}
}
最后,通过从命令行运行typings install
来安装类型。
我逐步介绍了这一点,因为这是一个棘手的事情,复制/粘贴的答案通常很有帮助。如上面的评论中所述,以下博文中提供了有关此更改的更多信息:http://blog.durandal.io/2016/06/10/where-did-my-typescript-go/