简体   繁体   中英

Enable tsconfig.json to compileOnSave for .js files

I am using Visual Studio Professional 2015 Update 3, and TypeScript 2.8.4. I have a simple project with

Scripts/
└── Widgets/
    ├── main.ts
    └── tsconfig.json

In main.ts :

console.log("Hello, world!");

In tsconfig.json

{
    "compileOnSave": true,
    "compilerOptions": {
        "allowJs": true,
        "noImplicitAny": false,
        "noEmitOnError": true,
        "removeComments": false,
        "sourceMap": true,
        "target": "es5",
        "outFile": "dist/widgets.js"
    },
    "exclude": [
        "dist"
    ]
}

The compileOnSave settings works just fine like this. However, when I change main.ts to main.js it doesn't compile on save, despite the allowJs setting being set. Is there something I can do to have compileOnSave work for files with extension .js ?

This is not possible in Visual Studio 2015. It should work in Visual Studio 2017.

See https://github.com/Microsoft/TypeScript/issues/14536 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM