@@ -810,15 +810,16 @@ module Harness {
810810 }
811811
812812 export function createSourceFileAndAssertInvariants (
813- fileName : string ,
814- sourceText : string ,
815- languageVersion : ts . ScriptTarget ,
816- assertInvariants : boolean ) {
817-
813+ fileName : string ,
814+ sourceText : string ,
815+ languageVersion : ts . ScriptTarget ) {
816+ // We'll only assert invariants outside of light mode.
817+ const shouldAssertInvariants = ! Harness . lightMode ;
818+
818819 // Only set the parent nodes if we're asserting invariants. We don't need them otherwise.
819- var result = ts . createSourceFile ( fileName , sourceText , languageVersion , /*setParentNodes:*/ assertInvariants ) ;
820+ var result = ts . createSourceFile ( fileName , sourceText , languageVersion , /*setParentNodes:*/ shouldAssertInvariants ) ;
820821
821- if ( assertInvariants ) {
822+ if ( shouldAssertInvariants ) {
822823 Utils . assertInvariants ( result , /*parent:*/ undefined ) ;
823824 }
824825
@@ -829,8 +830,8 @@ module Harness {
829830 const lineFeed = "\n" ;
830831
831832 export var defaultLibFileName = 'lib.d.ts' ;
832- export var defaultLibSourceFile = createSourceFileAndAssertInvariants ( defaultLibFileName , IO . readFile ( libFolder + 'lib.core.d.ts' ) , /*languageVersion*/ ts . ScriptTarget . Latest , /*assertInvariants*/ ! Harness . lightMode ) ;
833- export var defaultES6LibSourceFile = createSourceFileAndAssertInvariants ( defaultLibFileName , IO . readFile ( libFolder + 'lib.core.es6.d.ts' ) , /*languageVersion*/ ts . ScriptTarget . Latest , /*assertInvariants*/ ! Harness . lightMode ) ;
833+ export var defaultLibSourceFile = createSourceFileAndAssertInvariants ( defaultLibFileName , IO . readFile ( libFolder + 'lib.core.d.ts' ) , /*languageVersion*/ ts . ScriptTarget . Latest ) ;
834+ export var defaultES6LibSourceFile = createSourceFileAndAssertInvariants ( defaultLibFileName , IO . readFile ( libFolder + 'lib.core.es6.d.ts' ) , /*languageVersion*/ ts . ScriptTarget . Latest ) ;
834835
835836 // Cache these between executions so we don't have to re-parse them for every test
836837 export var fourslashFileName = 'fourslash.ts' ;
@@ -861,7 +862,7 @@ module Harness {
861862 function register ( file : { unitName : string ; content : string ; } ) {
862863 if ( file . content !== undefined ) {
863864 var fileName = ts . normalizePath ( file . unitName ) ;
864- filemap [ getCanonicalFileName ( fileName ) ] = createSourceFileAndAssertInvariants ( fileName , file . content , scriptTarget , /*assertInvariants*/ ! Harness . lightMode ) ;
865+ filemap [ getCanonicalFileName ( fileName ) ] = createSourceFileAndAssertInvariants ( fileName , file . content , scriptTarget ) ;
865866 }
866867 } ;
867868 inputFiles . forEach ( register ) ;
@@ -884,7 +885,7 @@ module Harness {
884885 }
885886 else if ( fn === fourslashFileName ) {
886887 var tsFn = 'tests/cases/fourslash/' + fourslashFileName ;
887- fourslashSourceFile = fourslashSourceFile || createSourceFileAndAssertInvariants ( tsFn , Harness . IO . readFile ( tsFn ) , scriptTarget , /*assertInvariants*/ ! Harness . lightMode ) ;
888+ fourslashSourceFile = fourslashSourceFile || createSourceFileAndAssertInvariants ( tsFn , Harness . IO . readFile ( tsFn ) , scriptTarget ) ;
888889 return fourslashSourceFile ;
889890 }
890891 else {
0 commit comments