6

Does anyone have a good strategy for adding TypeScript to a continuous integration system?

I'm planning on compiling it in my build and then running unit tests against it's generated JavaScript.

However, I'd like to add code standards checking for the TypeScript. Any ideas?

Thanks.

3 Answers 3

2

The TypeScript team are deliberately reserving judgement on the official coding standards because they want to see how people use the language in real life. Anecdotally, people seem to be following the JavaScript naming conventions, i.e. ModuleName, ClassName, functionName.

You can write your unit tests in TypeScript (tsUnit) or JavaScript (Jasmine, QUnit et al).

How you integrate it with CI depends a little on the framework and on the CI platform. I have integrated tsUnit tests with Visual Studio and TFS using the MS Script Engine to execute the tests. If you want more details on this particular set up I am happy to share.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, that's about what I was thinking. I'll keep my eye out to watch for they to publish guidelines for a coding standard.
1

One option is to set up TSLint and integrate it into your build process.

In my case (an Angular 2+ app), I added an npm task to run TSLint. Then the CI system (VSTS for me) executes that npm task. The CI system fails the build if TSLint detects any errors. The TSLint task I'm using comes from Angular's quickstart project. Here: https://github.com/angular/quickstart/blob/master/package.json [Notice the "lint" script]

Also note that TSLint's rules are configurable, so you can customize the coding standard to whatever you want to use.

Comments

0

Your question is vague; it's difficult to give a precise answer.

For integrating TS compilation into your build system, you'll want to simply invoke the TypeScript command line compiler (tsc.exe) on your .ts files. This will output the JS and you can run your unit tests against those.

Regarding TS code standards, I don't think there's any tooling available now that look at TS coding standards, seeing as how the language went public just a few months ago.

Comments

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.