1

Let's assume you have a TypeScript project called "shubidu" and you are using Visual Code as IDE. "shubidu" well be a library, not an app. Also, assume that your TypeScript project has two TypeScript files "core-stuff.ts" and "addon-stuff.ts".

// content of "core-stuff.ts"

export default function sayHello(name: string) {
   console.log(`Hello, ${name}`)
}

-

// content of "addon-stuff.ts"

import sayHello from 'shubidu/core'

export default function helloWorld() {
   sayHello('World')
}

Both files shall be transpiled to ES5 into two different modules "dist/shubidu-core.js" and "dist/shubidu-addon.js".

Later this "shubidu" library will be used by other projects like follows:

import sayHello from 'shubidu/core'
import helloWorld from 'shubidu/addon'

[...]

When you compile the "shubidu" project, there will be an error in file ""addon-stuff.ts" because module "shubidu/core" is unknown.

To fix this you have to modify file "tsconfig.json" like follows:

// content of tsconfig.json

{ 
  [...]
  "compilerOptions": {
    [...]
    "paths": {
      "shubidu/core": "path/to/core-stuff.ts"    
    }
    [...]
  }
  [...]
}

Compilation is working now. The open problem is that the Visual Code IDE itself still says (in file "addon-stuff.ts") that the module "shubidu/core" is unknown. How can this be fixed???

Natasha
  • 516
  • 7
  • 24
  • 1
    As per this answer intellisense doesnt yet work with paths. So you may have to wait until an update fixes that https://stackoverflow.com/a/43330003/2082775 – uniquerockrz Jan 03 '19 at 07:44

0 Answers0