When importing a typing file ( .d.ts ) using the import x = require('...') template, the semantics change when package.json typings is used.
For example, the following declaration file is successfully imported when no package.json typings used, but generates error TS2656 ( Exported external package typings file is not a module ) when used with typings :
declare module 'mymodule' { export function myfunc(source: string): string; }
While the same file minus declare module {} successfully imported when used with package.json typings , it generates error TS2307 ( Cannot find module ) when used without writing typings .
export function myfunc(source: string): string;
Why change semantics?
It looks like if you are using the new npm typing function, you will have to support the npm and non-npm versions of your typing files.
I hit this while trying to use a typed project file within the project itself (TypeScript is not being viewed in the current package.json project for typings entries, it seems to limit the search to ./node_modules ).
Tested with TypeScript 1.7.5.
source share