0

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 Answers 2

2

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)
Sign up to request clarification or add additional context in comments.

3 Comments

If I add "tsc": "tsc --version" to package.json and run "npm run tsc" from a local command line, this works. If I change it to "tsc": "tsc -p ." and attempt to run it, the output gets created in the output directory but I get a series of npm error messages that state the command failed.
After looking into the output a bit more, I think the problem is with the definitely typed library for jquery based on this error message: "node_modules/@types/jquery/index.d.ts(2957,63): error TS2304: Cannot find name Iterable". I'm assuming that this causes all of the "npm ERR!" lines... which will fail the build. Hopefully using an older version will resolve this (latest version doesn't).
End up finding this link which pointed me in the right direction. Just need to find out what the 'lib' option adds so I can better understand the problem. Thanks for the help @starain-MSFT
0

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

https://learn.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.

2 Comments

When attempting this locally, I get prompted by windows to choose the program to open a file. If I choose notepad, then the result is the content of the "node_modules\typescript\bin\tsc" file (the shell script that starts node and loads the '../lib/tsc' file) require('../lib/tsc.js'))
@KyKo there is something wrong in what you are trying. can you try with "node" as a prefix. node node_modules/....

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.