@samitouri / QOS-React-2 / commits / 655ac0f0dd

update typescript

chico committed May 3, 2016 at 02:08 UTC 655ac0f0ddc4e0be16974bc7fa560b973d60ff56
3 files changed +23 -15
package.json
+1 -1
@@ -58,7 +58,7 @@
58 "run-sequence": "^1.1.4",
59 "through2": "^2.0.0",
60 "tmp": "~0.0.28",
61 - "typescript": "~1.4.0",
61 + "typescript": "~1.8.10",
62 "uglify-js": "^2.5.0",
63 "uglifyify": "^3.0.1"
64 },
scripts/jest/ts-preprocessor.js
+19 -14
@@ -4,12 +4,15 @@ var fs = require('fs');
4 var path = require('path');
5 var ts = require('typescript');
6
7 -var tsOptions = {module: 'commonjs'};
7 +var tsOptions = {
8 + module: ts.ModuleKind.CommonJS,
9 + jsx: ts.JsxEmit.React,
10 +};
11
12 function formatErrorMessage(error) {
13 return (
14 error.file.filename + '(' +
12 - error.file.getLineAndCharacterFromPosition(error.start).line +
15 + error.file.getLineAndCharacterOfPosition(error.start).line +
16 '): ' +
17 error.messageText
18 );
@@ -18,7 +21,7 @@ function formatErrorMessage(error) {
21 function compile(content, contentFilename) {
22 var output = null;
23 var compilerHost = {
21 - getSourceFile: function(filename, languageVersion) {
24 + getSourceFile(filename, languageVersion) {
25 var source;
26
27 // `path.normalize` and `path.join` are used to turn forward slashes in
@@ -30,7 +33,7 @@ function compile(content, contentFilename) {
33
34 if (filename === 'lib.d.ts') {
35 source = fs.readFileSync(
33 - require.resolve('typescript/bin/lib.d.ts')
36 + require.resolve('typescript/lib/lib.d.ts')
37 ).toString();
38 } else if (filename === 'jest.d.ts') {
39 source = fs.readFileSync(
@@ -55,34 +58,36 @@ function compile(content, contentFilename) {
58 }
59 return ts.createSourceFile(filename, source, 'ES5', '0');
60 },
58 - writeFile: function(name, text, writeByteOrderMark) {
61 + writeFile(name, text, writeByteOrderMark) {
62 if (output === null) {
63 output = text;
64 } else {
65 throw new Error('Expected only one dependency.');
66 }
67 },
65 - getCanonicalFileName: function(filename) {
68 + getCanonicalFileName(filename) {
69 return filename;
70 },
68 - getCurrentDirectory: function() {
71 + getCurrentDirectory() {
72 return '';
73 },
71 - getNewLine: function() {
74 + getNewLine() {
75 return '\n';
76 },
77 + fileExists(filename) {
78 + return ts.sys.fileExists(filename);
79 + },
80 + useCaseSensitiveFileNames() {
81 + return ts.sys.useCaseSensitiveFileNames;
82 + },
83 };
84 var program = ts.createProgram([
85 'lib.d.ts',
86 'jest.d.ts',
87 contentFilename,
88 ], tsOptions, compilerHost);
80 - var errors = program.getDiagnostics();
81 - if (!errors.length) {
82 - var checker = program.getTypeChecker(true);
83 - errors = checker.getDiagnostics();
84 - checker.emitFiles();
85 - }
89 + var emitResult = program.emit();
90 + var errors = ts.getPreEmitDiagnostics(program).concat(emitResult.diagnostics);
91 if (errors.length) {
92 throw new Error(errors.map(formatErrorMessage).join('\n'));
93 }
src/isomorphic/modern/class/__tests__/ReactTypeScriptClass-test.ts
+3
@@ -1,3 +1,6 @@
1 +/// <reference path="../React.d.ts" />
2 +/// <reference path="../ReactDOM.d.ts" />
3 +
4 /*!
5 * Copyright 2015-present, Facebook, Inc.
6 * All rights reserved.