Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make atom-typescript recognize modules without relative path?

I'm following angular-meteor tutorial using angular2 and typescript.

Since I'm using atom, I added atom-typescript package and a tsconfig file to take advantage of type declaration files.

I'm trying to make atom-typescript recognize the import on client/parties-form/parties_form.ts:

import {Parties} from  'collections/parties';

But atom give me the following error : Cannot find module 'collections/parties'.

Error goes off when I import the module with relative path :

import {Parties} from '../../collections/parties';

But then meteor wont compile and gives me a Path reservation conflict error.

I'd like to be able to use the first kind of import without atom-typescript giving me any error and hence recognizing my type declaration files. What did I miss ?

My tsconfig.json file :

{
    "version": "1.5.0",
    "compilerOptions": {
        "target": "es5",
        "module": "commonjs",
        "declaration": false,
        "noImplicitAny": false,
        "removeComments": true,
        "noLib": false,
        "emitDecoratorMetadata": true
    },
    "filesGlob": [
        "./**/*.ts",
        "!./typings/**/*.ts"
    ]
}

Full version of the tutorial code can be found here.

like image 597
Florian F. Avatar asked Oct 19 '22 21:10

Florian F.


1 Answers

import {Parties} from '../../collections/parties';

This requirement is not specific to atom-typescript. Non relative paths for your own code outside node_modules is not supported in TypeScript. Track this issue for details : https://github.com/Microsoft/TypeScript/issues/5039

like image 168
basarat Avatar answered Oct 22 '22 02:10

basarat