none
Typescript compilation in Web site project

    Question

  • Hello,

    just wonder if is possible to compile .ts files in Web Site project (folder accessed via FTP - live web) without having to check 'Automatically compile TypeScript filest witch are not part of project'? (and ideally automatically send compiled .js over FTP to server)

    Reason for that is , that we also  have asp.net core + react + webpack + typescript project where vs is generating .js files every time i save some .tsx and these files are then preffered in webpack compilation (and therefore showed in browser debug panel instead of tsx)

    cheers

    PS:
    Microsoft Visual Studio Community 2015 Version 14.0.25431.01 Update 3
    Microsoft .NET Framework Version 4.6.01586

    Thursday, October 6, 2016 2:21 PM

All replies

  • Hi CzBuCHi,

    >>if is possible to compile .ts files in Web Site project

    In my VS2015 Enterprise, I could not add a .ts file to a Web Site project. But I could add .ts file to my ASP Web Application. Whether you Web Site project is Web Application project.

    When I publish the Web Application to FTP site, and open it from FTP, the .ts file has been changed into .js file. And I could not create a .ts file in this situation.

    >>ideally automatically send compiled .js over FTP to server

    If we open the site from the FTP site, and edit it and save, the .js file will be saved to FTP.

    So we could not compile the .ts file in Web Site project via FTP by now with VS. If I misunderstand your issue, please feel free to let me know.

    Sincerely,

    Oscar


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place. Click HERE to participate the survey.

    Friday, October 7, 2016 6:24 AM
    Moderator
  • to add *.ts file just add *.js file and then change extension ;-)

    i do not use 'Publish' - i just open line web site over ftp and edit it directly (database dependency prevents me to have local copy - specialy in case of running shop where orders needs to be in right order)

    in solution with is generated i have something like this:

    Project("{E24C65DC-7377-472B-9ABA-BC803B73C61A}") = "http://example.com", "ftp://user:pass@1.2.3.4/example.com/html", "{7ED62E83-1A07-4892-9B64-B54DD6739712}"
    ... EndProject

    im not editing generated *.js file - im editing original *.ts.
    VS is generating *.js for me if i check 'Automatically compile TypeScript ...'  to Temp\VWDWebCache\...)  - i need open it in VS and hit ctrl+S to send it to server

    when i dont have 'Automatically compile TypeScript ...' checked nothing is generated and there seems to be no context menu to do it manualy ...

    I know that web site dont have any project file to store files that are part of project so whe not consider every file in folder tree to be part of web site 'project'?

    i hope that explains it better :)

    cheers

    Thursday, October 13, 2016 4:58 PM
  • Hi CzBuCHi,

    Would you please share me your detailed steps that help me repro your issue in my side.

    Sincerely,

    Oscar


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place. Click HERE to participate the survey.

    Friday, October 14, 2016 2:18 PM
    Moderator
  • I don't know why you don't want to check the "Automatically compile TypeScript" checkbox. You have to check it.

    But in my case, this wasn't enough. For automatic compilation to work in a website project, I had to create a tsconfig.json file with the following configurations:

    {
        "compilerOptions": {
            "noImplicitAny": false,
            "noEmitOnError": true,
            "removeComments": false,
            "sourceMap": true,
            "target": "es5",
            "alwaysStrict": true,
            "module": "amd"
        },
        "compileOnSave": true,
        "exclude": [
            "node_modules",
            "wwwroot",
            "packages"
        ]
    }

    The "compileOnSave": true setting is the crucial one here. It's what triggers automatic compilation.

    Typescript version 2.1.5 on Visual Studio 2017


    • Edited by Ashraf Sabry Monday, May 8, 2017 7:54 AM Garbage inserted by Grammarly extension
    Monday, May 8, 2017 7:52 AM