Typescript not looking in the typings folder for .d.ts files

Not sure if this is more Typescript related of the configuration for it in the Ionic template.

Anyway, I just started a new application (ionic start sidemenu), and again (I have tried before) wanted to try getting type definitions for some external libraries. In this example I tried c3 and three and this time using typings rather than tsd.

The typing files are installed under the typings/global folder. I can correct import them into a page ts file, and vscode sees all the definitions.

The typings.json has the following…

   {
   "dependencies": {},
   "devDependencies": {},
   "globalDependencies": {
   "c3": "registry:dt/c3#0.0.0+20160608082756",
   "d3": "registry:dt/d3#0.0.0+20160727131401",
   "es6-shim": "registry:dt/es6-shim#0.31.2+20160602141504",
   "three": "registry:dt/three#0.0.0+20160802154944"
  }
 }

However, when I run ionic serve, I get the build error

  ✗ Error: Cannot find module 'THREE' from 'h:\dev\ionic2\MyIonic2Project\app\pages\page2' 

I have installed typscript 2.0 beta so I can run tsc --traceResolution to see where it is looking, and it never seems to look in the typings folder.

In the output it reported that neither c3 or THREE is found…

======== Module name 'c3' was not resolved. ========
======== Module name 'THREE' was not resolved. ========

Funny that only THREE is reported at the build.

Also add the following to the tsconfig.json,

 "filesGlob": [
 "**/*.ts",
 "!node_modules/**/*",
 "typings/global/*"
],

Unfortunately made no difference to the search paths.

Anyone have any idea what to do here?

Thanks in advance

Any feedback on this?
I’m having the same issue while migrating to RC0 using a newly created project.

RC0 don’t use typings anymore (see release notes)

RC0 use @types

https://www.npmjs.com/~types

To add a definition (like in this example localforage):

npm install @types/localforage --save-dev  --save-exact

When installed, the definitions are placed under node_modules/@types/…

2 Likes