Search code examples
typescriptcommonjsjspmsystemjs

Problems resolving ts.d from systemjs


I'm using jspm and have installed a package. I have checked that the package.json defines 'main' and 'typings' since i have installed typescript 1.6 i expected to be able to import the typings at design time and the javascript at runtime per https://github.com/Microsoft/TypeScript/wiki/Typings-for-npm-packages

what is strange is this does not work. I get cannot find the module 'theModule'

import {x,y,z} from 'theModule';

but if i do a relative path it works fine

import {x,y,z} from '../jspm_packages/github/blah/blah/dist/theModule';

I have tried everything i can think of but i just cant seem to get this to work. Any idea what I might be doing wrong?


Solution

  • New module resolution in tsc 1.6 assumes that the definition is in node_modules folder - that is not your case.

    Therefore you need to make a hint where tsc should look for definition of the module.

    The easiest way how to reference the d.ts which defines global module and then use it.

    /// <reference path="../jspm_packages/github/blah/blah/dist/theModule.d.ts" />
    
    import {x,y,z} from 'theModule';
    

    As @DeanB_Develop mentioned in real projects use tsconfig and tsd.