0

I'm working on a new nodejs 5.10.1 project using typescript.

I have tsc installed version 1.8.9

I created a new project that contains the following configuration files:

package.json

{
  "name": "mdb-analyze",
  "version": "1.0.0",
  "description": "",
  "main": "mdb-analyze.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "command-line-args": "^2.1.6"
  }
}

tsconfig.json

{
    "compilerOptions": {
        "module": "commonjs",
        "target": "es6",
        "noImplicitAny": false,
        "sourceMap": false
    },
    "exclude": [
        "node_modules"
    ]
}

typings.json

{
  "name": "mdb-analyze",
  "version": false,
  "dependencies": {}
}

and this is my main mdb-analyze.ts file:

import * as commandLineArgs from 'command-line-args';

var cli = commandLineArgs([
  { name: 'verbose', alias: 'v', type: Boolean },
  { name: 'fjso', alias:'f',type: String, multiple: true, defaultOption: true },
  { name: 'help',alias:'h',type:Boolean }
])

var params = cli.parse();
if (params.help || !params.fjso || params.fjso.length == 0) {
    console.info(cli.getUsage());
} else {

}

when I try to compile with tsc i get the following error:

mdb-analyze.ts(5,34): error TS2307: Cannot find module 'command-line-args'.

welp i've been told to use typings to load typescript definitions for the modules i want. but searching on typings doesn't show this module. i'm new to typescript, and very confused on what to do next.

any information regarding the issue would be greatly appreciated.

1 Answer 1

2

If there are no typings available you can write your own d.ts files containing necessary type declarations.

There are some samples for you: link, link

Hope this helps.

Sign up to request clarification or add additional context in comments.

3 Comments

thank you. where do i place the d.ts file after creating it? what's the flow ?
I am used to create a root folder named manual_typings and put all my custom d.ts files in there. No extra steps required.
where can i find information on how to create custom d.ts files ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.