@@ -43,7 +43,7 @@ module ts {
43
43
}
44
44
45
45
if ( canUseOldTranspile ) {
46
- let diagnostics : Diagnostic [ ] = [ ] ;
46
+ let diagnostics : Diagnostic [ ] = [ ] ;
47
47
let transpileResult = transpile ( input , transpileOptions . compilerOptions , transpileOptions . fileName , diagnostics , transpileOptions . moduleName ) ;
48
48
checkDiagnostics ( diagnostics , testSettings . expectedDiagnosticCodes ) ;
49
49
if ( testSettings . expectedOutput ) {
@@ -57,18 +57,18 @@ module ts {
57
57
}
58
58
59
59
if ( ! transpileOptions . fileName ) {
60
- transpileOptions . fileName = "file.ts" ;
60
+ transpileOptions . fileName = transpileOptions . compilerOptions . jsx ? "file.tsx" : "file.ts" ;
61
61
}
62
62
63
- transpileOptions . compilerOptions . sourceMap = true ;
63
+ transpileOptions . compilerOptions . sourceMap = true ;
64
64
let transpileModuleResultWithSourceMap = transpileModule ( input , transpileOptions ) ;
65
65
assert . isTrue ( transpileModuleResultWithSourceMap . sourceMapText !== undefined ) ;
66
66
67
67
let expectedSourceMapFileName = removeFileExtension ( getBaseFileName ( normalizeSlashes ( transpileOptions . fileName ) ) ) + ".js.map" ;
68
68
let expectedSourceMappingUrlLine = `//# sourceMappingURL=${ expectedSourceMapFileName } ` ;
69
69
70
70
if ( testSettings . expectedOutput !== undefined ) {
71
- assert . equal ( transpileModuleResultWithSourceMap . outputText , testSettings . expectedOutput + expectedSourceMappingUrlLine ) ;
71
+ assert . equal ( transpileModuleResultWithSourceMap . outputText , testSettings . expectedOutput + expectedSourceMappingUrlLine ) ;
72
72
}
73
73
else {
74
74
// expected output is not set, just verify that output text has sourceMappingURL as a last line
@@ -78,7 +78,7 @@ module ts {
78
78
assert . equal ( output , expectedSourceMappingUrlLine ) ;
79
79
}
80
80
else {
81
- let suffix = getNewLineCharacter ( transpileOptions . compilerOptions ) + expectedSourceMappingUrlLine
81
+ let suffix = getNewLineCharacter ( transpileOptions . compilerOptions ) + expectedSourceMappingUrlLine
82
82
assert . isTrue ( output . indexOf ( suffix , output . length - suffix . length ) !== - 1 ) ;
83
83
}
84
84
}
@@ -274,5 +274,14 @@ var x = 0;`,
274
274
it ( "Supports backslashes in file name" , ( ) => {
275
275
test ( "var x" , { expectedOutput : "var x;\r\n" , options : { fileName : "a\\b.ts" } } ) ;
276
276
} ) ;
277
+
278
+ it ( "transpile file as 'tsx' if 'jsx' is specified" , ( ) => {
279
+ let input = `var x = <div/>` ;
280
+ let output = `var x = React.createElement("div", null);\n` ;
281
+ test ( input , {
282
+ expectedOutput : output ,
283
+ options : { compilerOptions : { jsx : JsxEmit . React , newLine : NewLineKind . LineFeed } }
284
+ } )
285
+ } ) ;
277
286
} ) ;
278
287
}
0 commit comments