Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Typescript 2.0 @types not automatically referenced

Tags:

typescript

using TS 2.0 Beta I can't get the new @types working. somewhere in my code:

import * as angular from 'angular';

TS 2.0 @types:

npm install --save @types/angular
tsc

the compiler doesn't find the d.ts files though: Error:(1, 26) TS2307: Cannot find module 'angular'.

no issues with current (old) method of using the typings tool and global (before ambient) dependencies.

I expected the d.ts lookup to work automatically with 2.0 as described here:

https://blogs.msdn.microsoft.com/typescript/2016/06/15/the-future-of-declaration-files/

perhaps I am missing something?

like image 568
dmudro Avatar asked Jul 13 '16 09:07

dmudro


1 Answers

I was having the same issue with another file - tsc didn't find node_modules/@types/es6-shim. Explicitly adding types to tsconfig.json helped:

{
  "compilerOptions": {
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "module": "commonjs",
    "noEmit": true,
    "types":["es6-shim"],
    "sourceMap": true,
    "target": "es5"
  }
}
like image 161
Yakov Fain Avatar answered Oct 23 '22 07:10

Yakov Fain