3

I have a node/typescript project structured like so:

- node_modules // => these are loaded npm/package.json
- src
  - node_modules // => shared modules for my project, not on npm
    - lib.ts
  - app.ts
- package.json

I have a secondary node_modules folder for my private packages mainly so I can import them from anywhere in my project and not have to worry about relative paths (as suggested here) on imports.

This works great because instead of import * as lib from '../../lib' or var lib = require('../../lib'), I can import * as lib from 'lib'.

Typescript compiles/loads lib w/o problem, but VS Code intellisense complains that it "cannot find module 'lib'".

FWIW, here is my tsconfig.json

{
  "compilerOptions": {
    "experimentalDecorators": false,
    "emitDecoratorMetadata": false,
    "module": "commonjs",
    "target": "es2015",
    "rootDir": "src"
  }
}
Community
  • 1
  • 1
David Budiac
  • 811
  • 2
  • 9
  • 21
  • I suspect this is because my shared/private modules don't have typings definitions... but these modules are also written in typescript. Is there any property in the `lib` module `package.json` that I could use to tell vscode/typescript that this is a typescript module? – David Budiac Apr 06 '16 at 17:39

1 Answers1

1

I needed to modify the package.json of my lib to include a "typings" property:

{
  "name": "lib",
  "version": "0.0.1",
  "main": "lib.js",
  "typings": "lib"
}
David Budiac
  • 811
  • 2
  • 9
  • 21