Saturday 11 March 2017

Compiling TypeScript to JavaScript using Visual Studio Code

I am new to NodeJS and TypeScript and I want to begin by setting up my project folder. I already have my tsconfig.json

{
"compilerOptions": {
    "outDir": "./build",
    "module": "commonjs",
    "target": "es5",
    "noImplicitAny" : false
},
"files": [
    "./src/**/*.ts"
],
"exclude": [
    "node_modules"
]}

and package.json

    {
      "name": "crm",
      "version": "1.0.0",
      "description": "",
      "main": "app.js",
      "scripts": {
      "test": "echo \"Error: no test specified\" && exit 1"
      },
      "author": "",
      "license": "ISC"
    }

This is my simple directory structure:

    crm/
     |-src/
       |- main/
          |- app.ts

when I compile it using the tsc command, I expected that the compiled directory will be

    crm/
     |- src/
        |- main/
           |- app.js

but the result is

    crm
     |- build/
        |- app.js

there is no main folder that is created.

I dont know if the problem is on tsconfig.json or in the tsc command



via Gerald

No comments:

Post a Comment