Type Script is not generating JavaScript in my Visual Studio Community edition 2015

前端 未结 6 1116
小蘑菇
小蘑菇 2020-12-10 13:39

I am using Visual Studio Community edition 2015 for development, I have added *.ts file to my project but its not automatically compiling.

相关标签:
6条回答
  • 2020-12-10 13:56

    I know you say you added the .ts file but did you right-click and select 'include in project'. This will add it to the list of files that Visual Studio will check for TypeScript transpiling.

    0 讨论(0)
  • 2020-12-10 14:01

    Some false-errors in my ts caused the issue, fixed by uncheck "Do not emit outputs if any errors are reported"

    (The false error is from an outdated DefinitelyTyped file, the generated js file does not have any error.)

    0 讨论(0)
  • 2020-12-10 14:04

    I regularly encounter this issue in VS 2015 and VS 2013. My solution is not a pretty one, but it works for me...

    1. Close Visual Studio
    2. Go to your scripts folder, delete all JavaScript files that have corresponding TypeScript files (only necessary to do this for TypeScript files that you have created for your project)
    3. Open Visual Studio, clean, and build

    If this doesn't work, open each TypeScript file, change one character, Save, re-build... hopefully the file will re-compile.

    If this still doesn't work, open a Node.JS command prompt, change directory to the scripts directory, run;

    tsc "yourfile.ts"
    

    If this doesn't work, you've got bigger problems.

    0 讨论(0)
  • 2020-12-10 14:08

    Maybe not having the option to expand the .ts file and see the generated .js can cause a confusion here.Try to compile your solution. Click on Show All Files and you must see all the .js generated in the same folder of your .ts files. Include your .js in the project if you want to have them visible as part of the solutions. Hope this helps

    0 讨论(0)
  • 2020-12-10 14:16

    Make sure that you highlight the project in the solution explorer and then click the icon at the top that says "show all files" after you have compiled the project. You will then see the .js and maybe a .js.map file (greyed out). Select the files and then right click and 'include in project' and things should be good from there.

    0 讨论(0)
  • 2020-12-10 14:20

    You need install Web Essential then restart the Visual studio -> clean Solution -> Rebuild it should work.

    0 讨论(0)
提交回复
热议问题