8000 Update to use latest version of typescript · githubsheng/immutable-js@eae7a01 · GitHub
[go: up one dir, main page]

Skip to content

Commit eae7a01

Browse files
committed
Update to use latest version of typescript
This updates the jest preprocessor to work with the new typescript compiler, allowing us to support the newer typescript features like "this' return types. The new typescript version found a legitimate error in a test file, which is also fixed in this rev
1 parent 2c93401 commit eae7a01

File tree

3 files changed

+25
-16
lines changed

3 files changed

+25
-16
lines changed

__tests__/zip.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ describe('zip', () => {
5858
it('can zip to create immutable collections', () => {
5959
expect(
6060
I.Seq.of(1,2,3).zipWith(
61-
() => I.List(arguments),
61+
function () { return I.List(arguments); },
6262
I.Seq.of(4,5,6),
6363
I.Seq.of(7,8,9)
6464
).toJS()

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575
"rollup": "0.24.0",
7676
"run-sequence": "1.1.5",
7777
"through2": "2.0.0",
78-
"typescript": "~1.4.1",
78+
"typescript": "1.7.5",
7979
"uglify-js": "2.6.1",
8080
"vinyl-buffer": "1.0.0",
8181
"vinyl-source-stream": "1.1.0"
8000

resources/jestPreprocessor.js

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -34,22 +34,31 @@ function compileTypeScript(filePath) {
3434

3535
var host = typescript.createCompilerHost(options);
3636
var program = typescript.createProgram([filePath], options, host);
37-
var checker = typescript.createTypeChecker(program, /*fullTypeCheck*/ true);
38-
var result = checker.emitFiles();
39-
40-
program.getDiagnostics()
41-
.concat(checker.getDiagnostics())
42-
.concat(result.diagnostics)
43-
.forEach(function(diagnostic) {
44-
var lineChar = diagnostic.file.getLineAndCharacterFromPosition(diagnostic.start);
45-
console.error('%s %d:%d %s', diagnostic.file.filename, lineChar.line, lineChar.character, diagnostic.messageText);
46-
});
47-
48-
if (result.emitResultStatus !== typescript.EmitReturnStatus.Succeeded) {
49-
throw new Error('Compiling ' + filePath + ' failed');
37+
38+
var diagnostics = program.getSyntacticDiagnostics();
39+
40+
if (diagnostics.length === 0) {
41+
diagnostics = program.getGlobalDiagnostics();
42+
}
43+
44+
if (diagnostics.length === 0) {
45+
diagnostics = program.getSemanticDiagnostics();
46+
}
47+
48+
if (diagnostics.length === 0) {
49+
var emitOutput = program.emit();
50+
diagnostics = emitOutput.diagnostics;
51+
}
52+
53+
if (diagnostics.length === 0) {
54+
return fs.readFileSync(outputPath, {encoding: 'utf8'});
5055
}
5156

52-
return fs.readFileSync(outputPath, {encoding: 'utf8'});
57+
diagnostics.forEach(function(diagnostic) {
58+
var loc = typescript.getLineAndCharacterOfPosition(diagnostic.file, diagnostic.start);
59+
console.error('%s %d:%d %s', diagnostic.file.fileName, loc.line, loc.character, diagnostic.messageText);
60+
});
61+
throw new Error('Compiling ' + filePath + ' failed');
5362
}
5463

5564
function withLocalImmutable(filePath, jsSrc) {

0 commit comments

Comments
 (0)
0