0
votes

I am learning TypeScript and have built a very simple app that I would like to build using VSTS and then deploy as a web app on Azure App Service. My very simple build definition steps are as follows:

  1. "Node Tool Installer (preview)" to install Node 6.x
  2. "npm" to run 'npm install' for my dependencies (TypeScript, jQuery, Bootstrap)
  3. "Command Line" to run the 'tsc --project tsconfig.json'
  4. "Azure App Service Deploy" to deploy the app

The problem I am having is on step 3 when the TypeScript compiler is invoked... I get an error about the '--project' command line argument because the version of TypeScript that is installed on the Hosted build agent is v1.4 but I have developed against v2.5.3.

How can I get the right version of TypeScript compiled to run to compile the application? Seems simple, but I'm not finding any answers that don't involve a .NET project using MSBuild & NuGet (which this is definitely not: HTML, CSS, & TS transpiled to JS).

2

2 Answers

1
votes

Since TypeScript has been installed in the project during running npm install command. The simple way is that:

  1. Add script in package.json file to run tsc command (scripts section): "tsc":"tsc -project tsconfig.json"
  2. Add NPM task (Command: custom; Working folder with package.json: [package.json file path], such as $(Build.SourcesDirectory); Command and arguments: run tsc)
0
votes

By VSTS oficial website, nowadays you have "TypeScript 2.0.6 for Visual Studio 2015"

https://docs.microsoft.com/en-us/vsts/build-release/concepts/agents/hosted

Anyways, if the error persists or you want to use a newer version of Typescript, you can run the command from your local machine referring to the dependency found in package.json.

To access that Typescript library package, it's this easy:

node_modules/typescript/bin/tsc

you can even try to run that command locally, for instance, this command locally:

node_modules/typescript/bin/tsc --version

should tell you the version of the dependency of TS installed.

I have projects with TS hosted on Azure by VSTS, so it should be fine referring to the local version of TS.