@@ -122,9 +122,47 @@ module FourSlash {
122
122
return s . replace ( / [ & < > " ' \/ ] / g, ch => entityMap [ ch ] ) ;
123
123
}
124
124
125
+ // Name of ts.CompilerOptions properties that will be used by globalOptions
126
+ // To add additional option, add property into the compilerOptMetadataNames, refer the property in either globalMetadataNames or fileMetadataNames
127
+ // Add cases into convertGlobalOptionsToCompilationsSettings function for the compiler to acknowledge such option from meta data
128
+ var compilerOptMetadataNames = {
129
+ out : 'out' ,
130
+ outDir : 'outDir' ,
131
+ declaration : 'declaration' ,
132
+ sourceMap : 'sourceMap' ,
133
+ sourceRoot : 'sourceRoot'
134
+ } ;
135
+
125
136
// List of allowed metadata names
126
137
var fileMetadataNames = [ 'Filename' ] ;
127
- var globalMetadataNames = [ 'Module' , 'Target' , 'BaselineFile' ] ; // Note: Only BaselineFile is actually supported at the moment
138
+ var globalMetadataNames = [ 'BaselineFile' , compilerOptMetadataNames . out , compilerOptMetadataNames . outDir , compilerOptMetadataNames . declaration , compilerOptMetadataNames . outDir ,
139
+ compilerOptMetadataNames . declaration , compilerOptMetadataNames . sourceMap , compilerOptMetadataNames . sourceRoot ]
140
+
141
+ function convertGlobalOptionsToCompilationSettings ( globalOptions : { [ idx : string ] : string } ) : ts . CompilationSettings {
142
+ var settings : ts . CompilationSettings = { } ;
143
+ // Convert all property in globalOptions into ts.CompilationSettings
144
+ for ( var prop in globalOptions ) {
145
+ if ( globalOptions . hasOwnProperty ( prop ) ) {
146
+ switch ( prop ) {
147
+ case compilerOptMetadataNames . out :
148
+ settings . outFileOption = globalOptions [ prop ] ;
149
+ break ;
150
+ case compilerOptMetadataNames . outDir :
151
+ settings . outDirOption = globalOptions [ prop ] ;
152
+ break ;
153
+ case compilerOptMetadataNames . declaration :
154
+ settings . generateDeclarationFiles = true ;
155
+ break ;
156
+ case compilerOptMetadataNames . sourceMap :
157
+ settings . mapSourceFiles = true ;
158
+ break ;
159
+ case compilerOptMetadataNames . sourceRoot :
160
+ settings . sourceRoot = globalOptions [ prop ]
161
+ }
162
+ }
163
+ }
164
+ return settings ;
165
+ }
128
166
129
167
export var currentTestState : TestState = null ;
130
168
@@ -189,12 +227,6 @@ module FourSlash {
189
227
// Whether or not we should format on keystrokes
190
228
public enableFormatting = true ;
191
229
192
- // Whether or not to generate .d.ts file
193
- public enableDeclaration = false ;
194
-
195
- // Output filename for single-output-file option
196
- public singleOutputFilename : string = undefined ;
197
-
198
230
public formatCodeOptions : ts . FormatCodeOptions ;
199
231
200
232
public cancellationToken : TestCancellationToken ;
@@ -205,11 +237,15 @@ module FourSlash {
205
237
private scenarioActions : string [ ] = [ ] ;
206
238
private taoInvalidReason : string = null ;
207
239
240
+
208
241
constructor ( public testData : FourSlashData ) {
209
242
// Initialize the language service with all the scripts
210
243
this . cancellationToken = new TestCancellationToken ( ) ;
211
244
this . languageServiceShimHost = new Harness . LanguageService . TypeScriptLS ( this . cancellationToken ) ;
212
245
246
+ var compilationSettings = convertGlobalOptionsToCompilationSettings ( this . testData . globalOptions ) ;
247
+ this . languageServiceShimHost . setCompilationSettings ( compilationSettings ) ;
248
+
213
249
var inputFiles : { unitName : string ; content : string } [ ] = [ ] ;
214
250
215
251
testData . files . forEach ( file => {
@@ -226,9 +262,9 @@ module FourSlash {
226
262
//if (/require\(/.test(lastFile.content) || /reference\spath/.test(lastFile.content)) {
227
263
// inputFiles.push({ unitName: lastFile.fileName, content: lastFile.content });
228
264
//} else {
229
- inputFiles = testData . files . map ( file => {
230
- return { unitName : file . fileName , content : file . content } ;
231
- } ) ;
265
+ inputFiles = testData . files . map ( file => {
266
+ return { unitName : file . fileName , content : file . content } ;
267
+ } ) ;
232
268
//}
233
269
234
270
@@ -459,14 +495,6 @@ module FourSlash {
459
495
}
460
496
461
497
public verifyEmitOutput ( state : ts . EmitReturnStatus , filename ?: string ) {
462
- if ( this . enableDeclaration ) {
463
- this . languageServiceShimHost . setCompilationSettings ( { generateDeclarationFiles : true } ) ;
464
- }
465
-
466
- if ( this . singleOutputFilename !== undefined ) {
467
- this . languageServiceShimHost . setCompilationSettings ( { outFileOption : this . singleOutputFilename } ) ;
468
- }
469
-
470
498
var expectedFilenames :string [ ] = [ ] ;
471
499
if ( filename !== undefined ) {
472
500
expectedFilenames = filename . split ( " " ) ;
0 commit comments