Search code examples
typescriptaureliajspm

Setting up Aurelia, TypeScript, & Asp.Net Core RC2


I'm trying to set up a new project using Aurelia & Typescript.

I followed the most current directions I could find online. After creating the project using the vs template, I ran jspm init in the project root and configured the baseurl to wwwroot. The first problem I ran into was the VS refused to as jspm_packages as folder in the project. So, I ran jspm again and changed the packages folder to wwwroot/lib.
That seems to work, but typescript won't let me import any of Aurelia packages. I download the skeleton project to compare. I noticed two things, the skeleton uses an older version of Aurelia than I get when I use jspm install. Second, the packages download with the .d.ts files. I suspect the missing .d.ts files is causing the problem with intellisense.

So far, I've been unable to figure out how to get jspm to give me older version, I've tried changing the package.json file to match what's in the skeleton app, but when I run jspm install, I always get the newest version.

Have the typings been removed from the jspm packages? What's the correct workflow for getting this working?


Solution

  • The best practice for handling TypeScript typings is the Typings module, formerly DefinitelyTyped. First, install Typings by running npm install typings --global from the command line.

    Next, create a your typings.json file in the root of your project, with the following dependencies:

    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"
      }
    }
    

    Last, install types by running typings install from the command line.

    I included the step-by-step because this is a tricky thing, and copy/paste-able answers are often helpful. As noted in the comments above, more information about this change is available in the following blog post: http://blog.durandal.io/2016/06/10/where-did-my-typescript-go/