[TypeScript] Configuring TypeScript Which Files to Compile with "Files" and "OutDir"

This lesson shows how to configure the .tsconfig so you only compile the .ts files you want. It then shows how to configure which directory you'd like to compile the files to using "outDir".

 

tsconfig.json:

{
    "compilerOptions": {
        "module": "commonjs",
        "target": "es5",
        "noImplicitAny": false,
        "sourceMap": false,
        "outDir": "./dist"
    },
    "files": [
        "main.ts"
    ]
}

 

We added "outDir": Output compiled file to dist folder.

The files we want to compile is main.js.

 

And main.js will be the main entry file, so for example we have another ts file called two.ts, we can import into main.ts:

import './two';

class Person{

}

 

Then in the output file, we can see two.js is required into the module using common.js way:

"use strict";
require('./two');
var Person = (function () {
    function Person() {
    }
    return Person;
}());

 

posted @ 2016-06-09 02:25  Zhentiw  阅读(379)  评论(0编辑  收藏  举报