Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,4 @@ node_modules
# TypeScript
*.js
typings
tsconfig.json
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ cache:
- typings
language: node_js
node_js:
- '0.10'
- '0.12'
sudo: false
19 changes: 11 additions & 8 deletions index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/// <reference path="node_modules/typescript/bin/typescript.d.ts"/>
/// <reference path="typings/typescript/typescript.d.ts"/>
/// <reference path="typings/chalk/chalk.d.ts"/>
/// <reference path="typings/node/node.d.ts"/>
import chalk = require("chalk");
Expand Down Expand Up @@ -120,12 +120,13 @@ function isModified(tsPath: string, jsPath: string): boolean {
function compile(filename: string, options: typescript.CompilerOptions): void {
var host = typescript.createCompilerHost(options);
var program = typescript.createProgram([filename], options, host);
var source = program.getSourceFile(filename);
var checker = program.getTypeChecker(true);
var result = checker.emitFiles();
if (emitError()) {
checkErrors(checker.getDiagnostics());
checkErrors(program.getDiagnostics()
.concat(checker.getDiagnostics()
.concat(result.diagnostics)));
}
checker.emitFiles(source);
}

/**
Expand All @@ -137,11 +138,13 @@ function checkErrors(errors: typescript.Diagnostic[]): void {
if (errors.length === 0) {
return;
}
errors.forEach((err: typescript.Diagnostic): void => {
errors.forEach((diagnostic: typescript.Diagnostic): void => {
var position = diagnostic.file.getLineAndCharacterFromPosition(
diagnostic.start);
console.error(
chalk.bgRed("" + err.code),
chalk.grey(path.basename(err.file.filename)),
chalk.red(err.messageText));
chalk.bgRed("" + diagnostic.code),
chalk.grey(`${diagnostic.file.filename}, (${position.line},${position.character})`),
diagnostic.messageText);
});
throw new Error("TypeScript Compilation Errors");
}
Expand Down
2 changes: 1 addition & 1 deletion test/spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/// <reference path="../node_modules/typescript/bin/typescript.d.ts"/>
/// <reference path="../typings/typescript/typescript.d.ts"/>
/// <reference path="../typings/chai/chai.d.ts"/>
/// <reference path="../typings/mocha/mocha.d.ts"/>
/// <reference path="../typings/node/node.d.ts"/>
Expand Down
3 changes: 3 additions & 0 deletions tsd.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
},
"node/node.d.ts": {
"commit": "42c8a3b74c05f6887ce21dd63c6234e424f9f8fe"
},
"typescript/typescript.d.ts": {
"commit": "ed38db403a56da84731a6f77b545762ee477a45b"
}
}
}