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

Posted Answer1215

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[TypeScript] Configuring TypeScript Which Files to Compile with "Files" and "OutDir&q相关的知识,希望对你有一定的参考价值。

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;
}());

 

以上是关于[TypeScript] Configuring TypeScript Which Files to Compile with "Files" and "OutDir&q的主要内容,如果未能解决你的问题,请参考以下文章

ESLint - 为 TypeScript 配置“no-unused-vars”

转Configuring VM Acceleration on Linux

[转] EF Configuring a DbContext

MyBatis(3.2.3) - Configuring MyBatis using XML, Properties

Android SIMPLE: Error configuring

Configuring Beans in the Spring IoC Container