@@ -808,9 +808,17 @@ module Harness {
808808 }
809809 }
810810
811- export function createSourceFileAndAssertInvariants ( fileName : string , sourceText : string , languageVersion : ts . ScriptTarget , assertInvariants = true ) {
811+ export function createSourceFileAndAssertInvariants (
812+ fileName : string ,
813+ sourceText : string ,
814+ languageVersion : ts . ScriptTarget ,
815+ assertInvariants : boolean ,
816+ isDefaultLib : boolean ) {
817+
812818 // Only set the parent nodes if we're asserting invariants. We don't need them otherwise.
813819 var result = ts . createSourceFile ( fileName , sourceText , languageVersion , /*setParentNodes:*/ assertInvariants ) ;
820+ result . isDefaultLib = isDefaultLib ;
821+
814822 if ( assertInvariants ) {
815823 Utils . assertInvariants ( result , /*parent:*/ undefined ) ;
816824 }
@@ -821,8 +829,8 @@ module Harness {
821829 const lineFeed = "\n" ;
822830
823831 export var defaultLibFileName = 'lib.d.ts' ;
824- export var defaultLibSourceFile = createSourceFileAndAssertInvariants ( defaultLibFileName , IO . readFile ( libFolder + 'lib.core.d.ts' ) , /*languageVersion*/ ts . ScriptTarget . Latest ) ;
825- export var defaultES6LibSourceFile = createSourceFileAndAssertInvariants ( defaultLibFileName , IO . readFile ( libFolder + 'lib.core.es6.d.ts' ) , /*languageVersion*/ ts . ScriptTarget . Latest ) ;
832+ export var defaultLibSourceFile = createSourceFileAndAssertInvariants ( defaultLibFileName , IO . readFile ( libFolder + 'lib.core.d.ts' ) , /*languageVersion*/ ts . ScriptTarget . Latest , /*assertInvariants:*/ true , /*isDefaultLib:*/ true ) ;
833+ export var defaultES6LibSourceFile = createSourceFileAndAssertInvariants ( defaultLibFileName , IO . readFile ( libFolder + 'lib.core.es6.d.ts' ) , /*languageVersion*/ ts . ScriptTarget . Latest , /*assertInvariants:*/ true , /*isDefaultLib:*/ true ) ;
826834
827835 // Cache these between executions so we don't have to re-parse them for every test
828836 export var fourslashFileName = 'fourslash.ts' ;
@@ -832,13 +840,14 @@ module Harness {
832840 return ts . sys . useCaseSensitiveFileNames ? fileName : fileName . toLowerCase ( ) ;
833841 }
834842
835- export function createCompilerHost ( inputFiles : { unitName : string ; content : string ; } [ ] ,
836- writeFile : ( fn : string , contents : string , writeByteOrderMark : boolean ) => void ,
837- scriptTarget : ts . ScriptTarget ,
838- useCaseSensitiveFileNames : boolean ,
839- // the currentDirectory is needed for rwcRunner to passed in specified current directory to compiler host
840- currentDirectory ?: string ,
841- newLineKind ?: ts . NewLineKind ) : ts . CompilerHost {
843+ export function createCompilerHost (
844+ inputFiles : { unitName : string ; content : string ; } [ ] ,
845+ writeFile : ( fn : string , contents : string , writeByteOrderMark : boolean ) => void ,
846+ scriptTarget : ts . ScriptTarget ,
847+ useCaseSensitiveFileNames : boolean ,
848+ // the currentDirectory is needed for rwcRunner to passed in specified current directory to compiler host
849+ currentDirectory ?: string ,
850+ newLineKind ?: ts . NewLineKind ) : ts . CompilerHost {
842851
843852 // Local get canonical file name function, that depends on passed in parameter for useCaseSensitiveFileNames
844853 function getCanonicalFileName ( fileName : string ) : string {
@@ -852,7 +861,7 @@ module Harness {
852861 function register ( file : { unitName : string ; content : string ; } ) {
853862 if ( file . content !== undefined ) {
854863 var fileName = ts . normalizePath ( file . unitName ) ;
855- filemap [ getCanonicalFileName ( fileName ) ] = createSourceFileAndAssertInvariants ( fileName , file . content , scriptTarget ) ;
864+ filemap [ getCanonicalFileName ( fileName ) ] = createSourceFileAndAssertInvariants ( fileName , file . content , scriptTarget , /*assertInvariants:*/ true , /*isDefaultLib:*/ false ) ;
856865 }
857866 } ;
858867 inputFiles . forEach ( register ) ;
@@ -875,7 +884,7 @@ module Harness {
875884 }
876885 else if ( fn === fourslashFileName ) {
877886 var tsFn = 'tests/cases/fourslash/' + fourslashFileName ;
878- fourslashSourceFile = fourslashSourceFile || createSourceFileAndAssertInvariants ( tsFn , Harness . IO . readFile ( tsFn ) , scriptTarget ) ;
887+ fourslashSourceFile = fourslashSourceFile || createSourceFileAndAssertInvariants ( tsFn , Harness . IO . readFile ( tsFn ) , scriptTarget , /*assertInvariants:*/ true , /*isDefaultLib:*/ false ) ;
879888 return fourslashSourceFile ;
880889 }
881890 else {
@@ -964,7 +973,8 @@ module Harness {
964973 settingsCallback ( null ) ;
965974 }
966975
967- var newLine = '\r\n' ;
976+ let newLine = '\r\n' ;
977+ options . skipDefaultLibCheck = true ;
968978
969979 // Files from built\local that are requested by test "@includeBuiltFiles" to be in the context.
970980 // Treat them as library files, so include them in build, but not in baselines.
@@ -1050,6 +1060,10 @@ module Harness {
10501060 options . outDir = setting . value ;
10511061 break ;
10521062
1063+ case 'skipdefaultlibcheck' :
1064+ options . skipDefaultLibCheck = setting . value === "true" ;
1065+ break ;
1066+
10531067 case 'sourceroot' :
10541068 options . sourceRoot = setting . value ;
10551069 break ;
@@ -1134,9 +1148,11 @@ module Harness {
11341148 var fileOutputs : GeneratedFile [ ] = [ ] ;
11351149
11361150 var programFiles = inputFiles . concat ( includeBuiltFiles ) . map ( file => file . unitName ) ;
1137- var program = ts . createProgram ( programFiles , options , createCompilerHost ( inputFiles . concat ( includeBuiltFiles ) . concat ( otherFiles ) ,
1151+ var compilerHost = createCompilerHost (
1152+ inputFiles . concat ( includeBuiltFiles ) . concat ( otherFiles ) ,
11381153 ( fn , contents , writeByteOrderMark ) => fileOutputs . push ( { fileName : fn , code : contents , writeByteOrderMark : writeByteOrderMark } ) ,
1139- options . target , useCaseSensitiveFileNames , currentDirectory , options . newLine ) ) ;
1154+ options . target , useCaseSensitiveFileNames , currentDirectory , options . newLine ) ;
1155+ var program = ts . createProgram ( programFiles , options , compilerHost ) ;
11401156
11411157 var emitResult = program . emit ( ) ;
11421158
@@ -1480,7 +1496,8 @@ module Harness {
14801496 "errortruncation" , "usecasesensitivefilenames" , "preserveconstenums" ,
14811497 "includebuiltfile" , "suppressimplicitanyindexerrors" , "stripinternal" ,
14821498 "isolatedmodules" , "inlinesourcemap" , "maproot" , "sourceroot" ,
1483- "inlinesources" , "emitdecoratormetadata" , "experimentaldecorators" ] ;
1499+ "inlinesources" , "emitdecoratormetadata" , "experimentaldecorators" ,
1500+ "skipdefaultlibcheck" ] ;
14841501
14851502 function extractCompilerSettings ( content : string ) : CompilerSetting [ ] {
14861503
0 commit comments