@@ -14,7 +14,9 @@ namespace ts {
14
14
15
15
describe ( "printFile" , ( ) => {
16
16
const printsCorrectly = makePrintsCorrectly ( "printsFileCorrectly" ) ;
17
- const sourceFile = createSourceFile ( "source.ts" , `
17
+ // Avoid eagerly creating the sourceFile so that `createSourceFile` doesn't run unless one of these tests is run.
18
+ let sourceFile : SourceFile ;
19
+ before ( ( ) => sourceFile = createSourceFile ( "source.ts" , `
18
20
interface A<T> {
19
21
// comment1
20
22
readonly prop?: T;
@@ -48,8 +50,7 @@ namespace ts {
48
50
49
51
// comment10
50
52
function functionWithDefaultArgValue(argument: string = "defaultValue"): void { }
51
- ` , ScriptTarget . ES2015 ) ;
52
-
53
+ ` , ScriptTarget . ES2015 ) ) ;
53
54
printsCorrectly ( "default" , { } , printer => printer . printFile ( sourceFile ) ) ;
54
55
printsCorrectly ( "removeComments" , { removeComments : true } , printer => printer . printFile ( sourceFile ) ) ;
55
56
@@ -59,7 +60,8 @@ namespace ts {
59
60
60
61
describe ( "printBundle" , ( ) => {
61
62
const printsCorrectly = makePrintsCorrectly ( "printsBundleCorrectly" ) ;
62
- const bundle = createBundle ( [
63
+ let bundle : Bundle ;
64
+ before ( ( ) => bundle = createBundle ( [
63
65
createSourceFile ( "a.ts" , `
64
66
/*! [a.ts] */
65
67
@@ -72,14 +74,15 @@ namespace ts {
72
74
// comment1
73
75
const b = 2;
74
76
` , ScriptTarget . ES2015 )
75
- ] ) ;
77
+ ] ) ) ;
76
78
printsCorrectly ( "default" , { } , printer => printer . printBundle ( bundle ) ) ;
77
79
printsCorrectly ( "removeComments" , { removeComments : true } , printer => printer . printBundle ( bundle ) ) ;
78
80
} ) ;
79
81
80
82
describe ( "printNode" , ( ) => {
81
83
const printsCorrectly = makePrintsCorrectly ( "printsNodeCorrectly" ) ;
82
- const sourceFile = createSourceFile ( "source.ts" , "" , ScriptTarget . ES2015 ) ;
84
+ let sourceFile : SourceFile ;
85
+ before ( ( ) => sourceFile = createSourceFile ( "source.ts" , "" , ScriptTarget . ES2015 ) ) ;
83
86
// tslint:disable boolean-trivia
84
87
const syntheticNode = createClassDeclaration (
85
88
undefined ,
0 commit comments