2

I opened an Angular 2 website in Visual Studio 2015 update 3 as a website project. I added the "compileOnSave": true to tsconfig.json and restarted VS. I rebuilt the project and ran it however no .js files are being created. I am using Typescript 2.0.3. I see 'BuildOnSave..' messages when I edit a .ts file.

Any ideas why Javascript files are not being created?

Update tsconfig.json:

{
    /*"compileOnSave": true,*/
    "compilerOptions": {
        "target": "es5",
        "module": "system",
        "moduleResolution": "node",
        "sourceMap": true,
        "watch": true,
        "emitDecoratorMetadata": true,
        "experimentalDecorators": true,
        "removeComments": false,
        "noImplicitAny": false
    },
    "exclude": [
        "node_modules",
        "typings/main",
        "typings/main.d.ts"
    ]
}
Tony_Henrich
  • 42,411
  • 75
  • 239
  • 374

2 Answers2

1

Seems like you haven't included any files to compile.
There are different ways of specifying which files the compiler needs to compile, but you haven't used any of those, you only specified what to exclude.

You can use include:

"include": [
    "src/**/*"
]

Or you can use files:

"files": [
    "file1.ts",
    ...
    "fileN.ts"
]

More on those in the tsconfig.json docs page.

You can also use the rootDir or rootDirs compiler options.

Nitzan Tomer
  • 155,636
  • 47
  • 315
  • 299
  • There are many tsconfig.json files I have seen which don't include any of what you mentioned. Examples: https://github.com/GoshaFighten/Angular2DX/blob/master/tsconfig.json & https://github.com/AngularShowcase/angular2-sample-app/blob/master/tsconfig.json – Tony_Henrich Dec 09 '16 at 03:52
  • and according to the question's answer, the compiler defaults to including all files in folders and subfolders. http://stackoverflow.com/questions/34117191/tsconfig-json-only-build-ts-files-from-folder – Tony_Henrich Dec 09 '16 at 04:34
  • Fair enough. Have you tried compiling it yourself using `tsc` in the command line? – Nitzan Tomer Dec 09 '16 at 18:03
  • tsc works but I don't to compile manually. I think I have a solution for this by creating a project from scratch and copying files to it – Tony_Henrich Dec 10 '16 at 19:43
0

Visual Studio Code includes TypeScript language support but does not include the TypeScript compiler, tsc. You will need to install the TypeScript compiler either globally or in your workspace to transpile TypeScript source code to JavaScript

The easiest way to install TypeScript is through npm, the Node.js Package Manager. If you have npm installed, you can install TypeScript globally (-g) on your computer by:
npm install -g typescript

You can test your install by checking the version or help. tsc --version tsc --help

Finally make sure to click on "Show all Files" in solution explorer menu bar to see compiled JavaScript files

  • 1
    My post and the tag explicitly mention that I am using Visual Studio 2015. I am not using Visual Studio Code. – Tony_Henrich May 29 '18 at 18:16
  • Hi Tony_Henrich, sorry for the confusion, Anyways In Visual Studio 2015, in Solution Explorer, in the menu bar we have an icon called 'Show All Files' if this button is not selected VS wont show the .ts to .js compiled files, perhaps this may help. – Sungharsh J May 30 '18 at 21:50