A
A
Alexander Belov2017-01-06 00:18:43
JavaScript
Alexander Belov, 2017-01-06 00:18:43

How to configure Typescript tsconfig.json to automatically generate .js files?

In the Angular2 project, .js files are no longer automatically created on saving .ts files.

{
    "compileOnSave": true,
    "compilerOptions": {
        "target": "es5",
        "module": "commonjs",
        "moduleResolution": "node",
        "sourceMap": true,
        "emitDecoratorMetadata": true,
        "experimentalDecorators": true,
        "lib": [
            "es2015",
            "dom"
        ],
        "noImplicitAny": false,
        "noEmitOnError": true,
        "suppressImplicitAnyIndexErrors": true
    },
    "exclude": [
        "node_modules",
        "typings/main",
        "typings/main.d.ts"
    ],
    "filesGlob": [
        "./app/**/*.ts",
        "!./node_modules/**/*.ts",
        "src/custom_typings.d.ts",
        "typings/browser.d.ts"
    ],
    "files": [
        "./app/app.component.spec.ts",
        "./app/app.component.ts",
        "./app/app.module.ts",
        "./app/app.routes.ts",
        "./app/contacts/contacts.component.ts",
        "./app/distro/distro.component.ts",
        "./app/home/home.component.ts",
        "./app/main.ts",
        "./app/releases/releases.component.ts",
        "./app/releases/releases.service.ts"
    ]
}

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry Pavlov, 2017-01-06
@dmitry_pavlov

Have you looked at the instructions here ?

D
dmz9, 2017-01-06
@dmz9

someone has to watch the files, watcher. watcher is usually part of the assembler.
for example the gulp collector.
therefore, in order for it to start watching files and converting to .js after changing files (that is, after saving), you need to run it from the console in the folder where the gulpfile.js file is located (if gulp is used).
it happens that the development environment (IDE) itself can run the collector after file changes, but for this you need to integrate gulp into it, specify its executable file. in each in its own way.
so there is no magic - if the collector did not start, then it did not recompile the files either.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question