11/// <reference path="..\..\..\src\harness\harness.ts" />
22
3+ interface ObjectConstructor {
4+ assign < T , U > ( target : T , source : U ) : T & U ;
5+ }
6+
37namespace ts {
48 describe ( "Transpile" , ( ) => {
59
@@ -21,6 +25,9 @@ namespace ts {
2125 assert . equal ( expectedDiagnosticTexts [ i ] , diagnostics [ i ] && diagnostics [ i ] . messageText ) ;
2226 }
2327 } ;
28+ if ( diagnostics . length !== n && diagnostics . length ) {
29+ console . log ( JSON . stringify ( diagnostics , undefined , 2 ) ) ;
30+ }
2431 assert . equal ( diagnostics . length , n , "Resuting diagnostics count does not match expected" ) ;
2532 }
2633
@@ -89,6 +96,19 @@ namespace ts {
8996
9097 }
9198
99+ function testCompilerOption ( options : CompilerOptions , input ?: string , output ?: string ) : void {
100+ input = input || "x = 0;" ;
101+ output = output || `"use strict";\r\nx = 0;\r\n` ;
102+ test ( input , {
103+ expectedOutput : output ,
104+ options : {
105+ compilerOptions : Object . assign ( { module : ModuleKind . CommonJS , newLine : NewLineKind . CarriageReturnLineFeed } , options ) ,
106+ fileName : "input.js" ,
107+ reportDiagnostics : true
108+ }
109+ } ) ;
110+ }
111+
92112 it ( "Generates no diagnostics with valid inputs" , ( ) => {
93113 // No errors
94114 test ( `var x = 0;` , { options : { compilerOptions : { module : ModuleKind . CommonJS } } } ) ;
@@ -304,21 +324,198 @@ var x = 0;`,
304324 test ( "var x" , { expectedOutput : `"use strict";\r\nvar x;\r\n` , options : { fileName : "http://somewhere/directory//directory2/file.ts" } } ) ;
305325 } ) ;
306326
307- it ( "Support options with lib values" , ( ) => {
308- const input = "const a = 10;" ;
309- const output = `"use strict";\r\nvar a = 10;\r\n` ;
310- test ( input , {
311- expectedOutput : output ,
312- options : { compilerOptions : { lib : [ "es6" , "dom" ] , module : ModuleKind . CommonJS } , fileName : "input.js" , reportDiagnostics : true }
327+ describe ( "Works with all compiler options" , ( ) => {
328+
329+ it ( "Supports setting 'allowJs'" , ( ) => {
330+ testCompilerOption ( { allowJs : true } ) ;
313331 } ) ;
314- } ) ;
315332
316- it ( "Support options with types values" , ( ) => {
317- const input = "const a = 10;" ;
318- const output = `"use strict";\r\nvar a = 10;\r\n` ;
319- test ( input , {
320- expectedOutput : output ,
321- options : { compilerOptions : { types : [ "jquery" , "typescript" ] , module : ModuleKind . CommonJS } , fileName : "input.js" , reportDiagnostics : true }
333+ it ( "Supports setting 'allowSyntheticDefaultImports'" , ( ) => {
334+ testCompilerOption ( { allowSyntheticDefaultImports : true } ) ;
335+ } ) ;
336+
337+ it ( "Supports setting 'allowUnreachableCode'" , ( ) => {
338+ testCompilerOption ( { allowUnreachableCode : true } ) ;
339+ } ) ;
340+
341+ it ( "Supports setting 'allowUnusedLabels'" , ( ) => {
342+ testCompilerOption ( { allowUnusedLabels : true } ) ;
343+ } ) ;
344+
345+ it ( "Supports setting 'baseUrl'" , ( ) => {
346+ testCompilerOption ( { baseUrl : "./folder/baseUrl" } ) ;
347+ } ) ;
348+
349+ it ( "Supports setting 'charset'" , ( ) => {
350+ testCompilerOption ( { charset : "en-us" } ) ;
351+ } ) ;
352+
353+ it ( "Supports setting 'declaration'" , ( ) => {
354+ testCompilerOption ( { declaration : true } ) ;
355+ } ) ;
356+
357+ it ( "Supports setting 'declarationDir'" , ( ) => {
358+ testCompilerOption ( { declarationDir : "out/declarations" } ) ;
359+ } ) ;
360+
361+ it ( "Supports setting 'emitBOM'" , ( ) => {
362+ testCompilerOption ( { emitBOM : true } ) ;
363+ } ) ;
364+
365+ it ( "Supports setting 'emitDecoratorMetadata'" , ( ) => {
366+ testCompilerOption ( { emitDecoratorMetadata : true , experimentalDecorators : true } ) ;
367+ } ) ;
368+
369+ it ( "Supports setting 'experimentalDecorators'" , ( ) => {
370+ testCompilerOption ( { experimentalDecorators : true } ) ;
371+ } ) ;
372+
373+ it ( "Supports setting 'forceConsistentCasingInFileNames'" , ( ) => {
374+ testCompilerOption ( { forceConsistentCasingInFileNames : true } ) ;
375+ } ) ;
376+
377+ it ( "Supports setting 'isolatedModules'" , ( ) => {
378+ testCompilerOption ( { isolatedModules : true } ) ;
379+ } ) ;
380+
381+ it ( "Supports setting 'jsx'" , ( ) => {
382+ testCompilerOption ( { jsx : 1 } ) ;
383+ } ) ;
384+
385+ it ( "Supports setting 'lib'" , ( ) => {
386+ testCompilerOption ( { lib : [ "es2015" , "dom" ] } ) ;
387+ } ) ;
388+
389+ it ( "Supports setting 'locale'" , ( ) => {
390+ testCompilerOption ( { locale : "en-us" } ) ;
391+ } ) ;
392+
393+ it ( "Supports setting 'module'" , ( ) => {
394+ testCompilerOption ( { module : 1 } ) ;
395+ } ) ;
396+
397+ it ( "Supports setting 'moduleResolution'" , ( ) => {
398+ testCompilerOption ( { moduleResolution : 2 } ) ;
399+ } ) ;
400+
401+ it ( "Supports setting 'newLine'" , ( ) => {
402+ testCompilerOption ( { newLine : 0 } ) ;
403+ } ) ;
404+
405+ it ( "Supports setting 'noEmit'" , ( ) => {
406+ testCompilerOption ( { noEmit : true } ) ;
407+ } ) ;
408+
409+ it ( "Supports setting 'noEmitHelpers'" , ( ) => {
410+ testCompilerOption ( { noEmitHelpers : true } ) ;
411+ } ) ;
412+
413+ it ( "Supports setting 'noEmitOnError'" , ( ) => {
414+ testCompilerOption ( { noEmitOnError : true } ) ;
415+ } ) ;
416+
417+ it ( "Supports setting 'noErrorTruncation'" , ( ) => {
418+ testCompilerOption ( { noErrorTruncation : true } ) ;
419+ } ) ;
420+
421+ it ( "Supports setting 'noFallthroughCasesInSwitch'" , ( ) => {
422+ testCompilerOption ( { noFallthroughCasesInSwitch : true } ) ;
423+ } ) ;
424+
425+ it ( "Supports setting 'noImplicitAny'" , ( ) => {
426+ testCompilerOption ( { noImplicitAny : true } ) ;
427+ } ) ;
428+
429+ it ( "Supports setting 'noImplicitReturns'" , ( ) => {
430+ testCompilerOption ( { noImplicitReturns : true } ) ;
431+ } ) ;
432+
433+ it ( "Supports setting 'noImplicitThis'" , ( ) => {
434+ testCompilerOption ( { noImplicitThis : true } ) ;
435+ } ) ;
436+
437+ it ( "Supports setting 'noImplicitUseStrict'" , ( ) => {
438+ testCompilerOption ( { noImplicitUseStrict : true } , "x;" , "x;\r\n" ) ;
439+ } ) ;
440+
441+ it ( "Supports setting 'noLib'" , ( ) => {
442+ testCompilerOption ( { noLib : true } ) ;
443+ } ) ;
444+
445+ it ( "Supports setting 'noResolve'" , ( ) => {
446+ testCompilerOption ( { noResolve : true } ) ;
447+ } ) ;
448+
449+ it ( "Supports setting 'out'" , ( ) => {
450+ testCompilerOption ( { out : "./out" } ) ;
451+ } ) ;
452+
453+ it ( "Supports setting 'outDir'" , ( ) => {
454+ testCompilerOption ( { outDir : "./outDir" } ) ;
455+ } ) ;
456+
457+ it ( "Supports setting 'outFile'" , ( ) => {
458+ testCompilerOption ( { outFile : "./outFile" } ) ;
459+ } ) ;
460+
461+ it ( "Supports setting 'paths'" , ( ) => {
462+ testCompilerOption ( { paths : { "*" : [ "./generated*" ] } } ) ;
463+ } ) ;
464+
465+ it ( "Supports setting 'preserveConstEnums'" , ( ) => {
466+ testCompilerOption ( { preserveConstEnums : true } ) ;
467+ } ) ;
468+
469+ it ( "Supports setting 'reactNamespace'" , ( ) => {
470+ testCompilerOption ( { reactNamespace : "react" } ) ;
471+ } ) ;
472+
473+ it ( "Supports setting 'removeComments'" , ( ) => {
474+ testCompilerOption ( { removeComments : true } ) ;
475+ } ) ;
476+
477+ it ( "Supports setting 'rootDir'" , ( ) => {
478+ testCompilerOption ( { rootDir : "./rootDir" } ) ;
479+ } ) ;
480+
481+ it ( "Supports setting 'rootDirs'" , ( ) => {
482+ testCompilerOption ( { rootDirs : [ "./a" , "./b" ] } ) ;
483+ } ) ;
484+
485+ it ( "Supports setting 'skipLibCheck'" , ( ) => {
486+ testCompilerOption ( { skipLibCheck : true } ) ;
487+ } ) ;
488+
489+ it ( "Supports setting 'skipDefaultLibCheck'" , ( ) => {
490+ testCompilerOption ( { skipDefaultLibCheck : true } ) ;
491+ } ) ;
492+
493+ it ( "Supports setting 'strictNullChecks'" , ( ) => {
494+ testCompilerOption ( { strictNullChecks : true } ) ;
495+ } ) ;
496+
497+ it ( "Supports setting 'stripInternal'" , ( ) => {
498+ testCompilerOption ( { stripInternal : true } ) ;
499+ } ) ;
500+
501+ it ( "Supports setting 'suppressExcessPropertyErrors'" , ( ) => {
502+ testCompilerOption ( { suppressExcessPropertyErrors : true } ) ;
503+ } ) ;
504+
505+ it ( "Supports setting 'suppressImplicitAnyIndexErrors'" , ( ) => {
506+ testCompilerOption ( { suppressImplicitAnyIndexErrors : true } ) ;
507+ } ) ;
508+
509+ it ( "Supports setting 'target'" , ( ) => {
510+ testCompilerOption ( { target : 2 } ) ;
511+ } ) ;
512+
513+ it ( "Supports setting 'types'" , ( ) => {
514+ testCompilerOption ( { types : [ "jquery" , "jasmine" ] } ) ;
515+ } ) ;
516+
517+ it ( "Supports setting 'typeRoots'" , ( ) => {
518+ testCompilerOption ( { typeRoots : [ "./folder" ] } ) ;
322519 } ) ;
323520 } ) ;
324521
0 commit comments