@@ -810,15 +810,16 @@ module Harness {
810
810
}
811
811
812
812
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
+
818
819
// 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 ) ;
820
821
821
- if ( assertInvariants ) {
822
+ if ( shouldAssertInvariants ) {
822
823
Utils . assertInvariants ( result , /*parent:*/ undefined ) ;
823
824
}
824
825
@@ -829,8 +830,8 @@ module Harness {
829
830
const lineFeed = "\n" ;
830
831
831
832
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 ) ;
834
835
835
836
// Cache these between executions so we don't have to re-parse them for every test
836
837
export var fourslashFileName = 'fourslash.ts' ;
@@ -861,7 +862,7 @@ module Harness {
861
862
function register ( file : { unitName : string ; content : string ; } ) {
862
863
if ( file . content !== undefined ) {
863
864
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 ) ;
865
866
}
866
867
} ;
867
868
inputFiles . forEach ( register ) ;
@@ -884,7 +885,7 @@ module Harness {
884
885
}
885
886
else if ( fn === fourslashFileName ) {
886
887
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 ) ;
888
889
return fourslashSourceFile ;
889
890
}
890
891
else {
0 commit comments