Using TypeScript in an existing Visual Studio Web Site project

前端 未结 8 2219
南旧
南旧 2020-11-29 06:16

I\'ve got an existing Visual Studio project that was setup as a \"Web Site\" project. You can create projects like this by going to File->New Web Site. This is a different

8条回答
  •  囚心锁ツ
    2020-11-29 07:04

    This one has been a bit of a moving target - but only because the TypeScript team have been improving how it all works. I have tried to cover as many scenarios as possible below, from the newest to the oldest.

    The very latest on this is that this should now work in the latest versions of Visual Studio (currently v1.4) even for web projects.

    I have taken these abbreviated notes from my much longer answer about adding TypeScript to an existing project.

    VS 2013 / 0.9.5

    If you are using the Visual Studio Extension for 0.9.5 or better along with Visual Studio 2013 you should find that it will automatically configure everything as soon as you add the first TypeScript file.

    Auto TypeScript-isation didn't work?

    The automatic config only adds a few lines - you could do that manually:

      
        
      
      
    

    VS 2012 / 0.9.x

    The following project file configuration should work:

      
        
      
      
        ES5
        false
        true
        AMD
      
      
        ES5
        true
        false
        AMD
      
      
    

    Even older set up?

    I have found the most reliable way to add TypeScript to an existing project is to add the following to the project file:

    
        
     
     
        
     
     
        
     
    

    You can add optional flags here too - such as --module amd:

        
    

提交回复
热议问题