@@ -795,17 +795,19 @@ module Harness {
795
795
}
796
796
}
797
797
798
- export function createSourceFileAndAssertInvariants ( fileName : string , sourceText : string , languageVersion : ts . ScriptTarget ) {
799
- var result = ts . createSourceFile ( fileName , sourceText , languageVersion , /*setParentNodes:*/ true ) ;
800
- Utils . assertInvariants ( result , /*parent:*/ undefined ) ;
798
+ export function createSourceFileAndAssertInvariants ( fileName : string , sourceText : string , languageVersion : ts . ScriptTarget , assertInvariants = true ) {
799
+ // Only set the parent nodes if we're asserting invariants. We don't need them otherwise.
800
+ var result = ts . createSourceFile ( fileName , sourceText , languageVersion , /*setParentNodes:*/ assertInvariants ) ;
801
+ if ( assertInvariants ) {
802
+ Utils . assertInvariants ( result , /*parent:*/ undefined ) ;
803
+ }
801
804
return result ;
802
805
}
803
806
804
807
export var defaultLibFileName = 'lib.d.ts' ;
805
808
export var defaultLibSourceFile = createSourceFileAndAssertInvariants ( defaultLibFileName , IO . readFile ( libFolder + 'lib.core.d.ts' ) , /*languageVersion*/ ts . ScriptTarget . Latest ) ;
806
809
export var defaultES6LibSourceFile = createSourceFileAndAssertInvariants ( defaultLibFileName , IO . readFile ( libFolder + 'lib.core.es6.d.ts' ) , /*languageVersion*/ ts . ScriptTarget . Latest ) ;
807
810
808
-
809
811
// Cache these between executions so we don't have to re-parse them for every test
810
812
export var fourslashFileName = 'fourslash.ts' ;
811
813
export var fourslashSourceFile : ts . SourceFile ;
@@ -926,7 +928,8 @@ module Harness {
926
928
settingsCallback ?: ( settings : ts . CompilerOptions ) => void ,
927
929
options ?: ts . CompilerOptions ,
928
930
// Current directory is needed for rwcRunner to be able to use currentDirectory defined in json file
929
- currentDirectory ?: string ) {
931
+ currentDirectory ?: string ,
932
+ assertInvariants = true ) {
930
933
931
934
options = options || { noResolve : false } ;
932
935
options . target = options . target || ts . ScriptTarget . ES3 ;
@@ -1074,7 +1077,7 @@ module Harness {
1074
1077
var register = ( file : { unitName : string ; content : string ; } ) => {
1075
1078
if ( file . content !== undefined ) {
1076
1079
var fileName = ts . normalizeSlashes ( file . unitName ) ;
1077
- filemap [ getCanonicalFileName ( fileName ) ] = createSourceFileAndAssertInvariants ( fileName , file . content , options . target ) ;
1080
+ filemap [ getCanonicalFileName ( fileName ) ] = createSourceFileAndAssertInvariants ( fileName , file . content , options . target , assertInvariants ) ;
1078
1081
}
1079
1082
} ;
1080
1083
inputFiles . forEach ( register ) ;
0 commit comments