ChrisRich
ChrisRich

Reputation: 8736

TypeScript include non .ts files in compilation directive

For some reason only .ts files are included:

{
        "compilerOptions": {
            "module": "commonjs",
            "target": "es6",
            "noImplicitAny": false,
            "sourceMap": true,
            "outDir": "dist",
            "baseUrl": ".",
            "types": ["node", "mocha"],
            "paths": {
                "*": [ "src/main/*", "generated/*" ]
            }
        },
        "include": [
            "**/*.yaml"
        ],
        "exclude": [
            "node_modules",
            "dist",
            "build"
        ],
        "compileOnSave": false
    }

Why is it not picking up the yaml files? They are needed for my Swagger API spec.

Upvotes: 1

Views: 3108

Answers (2)

jason-warner
jason-warner

Reputation: 111

Finally this issue has been fixed by @bencergazda as he has created typescript-cp that works exactly like you would have hoped.

It even works in parallel with typescript and requires no real configuration as it reads your tsconfig.

I installed it globally on my machine as it is available on npm and just ran "tsc" to do the initial copy build, then I add script with "tsc -w && tscp -w" to have typescript work in parallel with typescript-cp.

Upvotes: 0

adanilev
adanilev

Reputation: 3408

I think it's because include is telling the TypeScript compiler what files to compile, not what files it should include in the final bundle.

In other words, you're telling tsc what files to "include" in the input to its compilation process.

To include anything other than .ts, .tsx or .d.ts files in your output, seems you need to use a build tool like gulp or webpack.

Upvotes: 1

Related Questions