So, I'm new to TypeScript and I wanted to convert a really small NodeJS project I was doing in plain JavaScript to TypeScript. In that project, I use some npm modules that have a definition under the @types scope, but others don't.
So, I figured I'd create these declarations for myself in my project, without having to change those third-party modules. However, no matter where I put the .d.ts file, TypeScript does not seem to recognize it.
src/typings.d.ts
import stream = require( 'stream' );
import http = require( 'http' );
declare module "flatten" {
function flatten ( ...arrays : any[] ) : any[];
export = flatten;
}
declare module "got" {
//...
}
And then when I try to use the module flatten, for instance:
src/manager.ts
import flatten = require( 'flatten' );
//...
I get the error:
src/manager.ts(1,27): error TS2307: Cannot find module 'flatten'.
My tsconfig.json looks like this:
{
"compilerOptions": {
"target": "es6",
"module": "commonjs",
"noImplicitAny": true,
"sourceMap": true,
"outDir": "lib/"
},
"include": [
"src/**/*"
],
"exclude": [
"node_modules",
"**/*.spec.ts"
]
}