Cannot find module from ./node_modules
Don't know if this is a expected bahaviour ? I thought loading node modules should be OK?
TypeScript Version:
1.8.0, 1.8.0-beta, also in 1.9.0-dev.20160217
Install
npm install object-assign
so we will have node_modules/object-assign/index.js installed.
Config
{
"compilerOptions": {
"allowSyntheticDefaultImports": true,
"allowJs": true
},
"files": ["entry.ts"]
}
Code
import * as assign from "object-assign";
Expected behavior:
should load the module from node_modules/object-assign
Actual behavior:
error TS2307: Cannot find module 'object-assign'.
typings install object-assign
And change import statement to
import assign from "object-assign";
solves this problem.
Is there any way to ignore error TS2307 in case where typings were not available for package installed from npm?
declare module "the-module-name";
Which package is missing type definitions? I'm working on a tool to generate these quasi-automatically and am interested to try it out
Thanks for quick response!
Should I declare it in typings\globals\[the-module-name].d.ts ?
For sure, your one line solution produce error TS1005: '{' expected.. I assume that your answer is an shortcut for writing whole typings for this module, am I right?
I am searching for quick solution for situation where I can not find typings, writing them from scratch is not what I expect.
I can not find typings for react-simple-dropdown and react-cookie.
Sorry, that syntax is specific to TS2.0.
It doesn't matter where you place the file as long as it's part of your compilation.
In pre-2.0 you can write the equivalent
declare module "react-cookie" {
var x: any;
export = x;
}