@@ -129,7 +129,7 @@ namespace ts {
129
129
}
130
130
131
131
export function listFiles ( program : ProgramToEmitFilesAndReportErrors , writeFileName : ( s : string ) => void ) {
132
- if ( program . getCompilerOptions ( ) . listFiles ) {
132
+ if ( program . getCompilerOptions ( ) . listFiles || program . getCompilerOptions ( ) . listFilesOnly ) {
133
133
forEach ( program . getSourceFiles ( ) , file => {
134
134
writeFileName ( file . fileName ) ;
135
135
} ) ;
@@ -149,6 +149,8 @@ namespace ts {
149
149
emitOnlyDtsFiles ?: boolean ,
150
150
customTransformers ?: CustomTransformers
151
151
) {
152
+ const isListFilesOnly = ! ! program . getCompilerOptions ( ) . listFilesOnly ;
153
+
152
154
// First get and report any syntactic errors.
153
155
const diagnostics = program . getConfigFileParsingDiagnostics ( ) . slice ( ) ;
154
156
const configFileParsingDiagnosticsLength = diagnostics . length ;
@@ -158,15 +160,20 @@ namespace ts {
158
160
// semantic errors.
159
161
if ( diagnostics . length === configFileParsingDiagnosticsLength ) {
160
162
addRange ( diagnostics , program . getOptionsDiagnostics ( cancellationToken ) ) ;
161
- addRange ( diagnostics , program . getGlobalDiagnostics ( cancellationToken ) ) ;
162
163
163
- if ( diagnostics . length === configFileParsingDiagnosticsLength ) {
164
- addRange ( diagnostics , program . getSemanticDiagnostics ( /*sourceFile*/ undefined , cancellationToken ) ) ;
164
+ if ( ! isListFilesOnly ) {
165
+ addRange ( diagnostics , program . getGlobalDiagnostics ( cancellationToken ) ) ;
166
+
167
+ if ( diagnostics . length === configFileParsingDiagnosticsLength ) {
168
+ addRange ( diagnostics , program . getSemanticDiagnostics ( /*sourceFile*/ undefined , cancellationToken ) ) ;
169
+ }
165
170
}
166
171
}
167
172
168
173
// Emit and report any errors we ran into.
169
- const emitResult = program . emit ( /*targetSourceFile*/ undefined , writeFile , cancellationToken , emitOnlyDtsFiles , customTransformers ) ;
174
+ const emitResult = isListFilesOnly
175
+ ? { emitSkipped : true , diagnostics : emptyArray }
176
+ : program . emit ( /*targetSourceFile*/ undefined , writeFile , cancellationToken , emitOnlyDtsFiles , customTransformers ) ;
170
177
const { emittedFiles, diagnostics : emitDiagnostics } = emitResult ;
171
178
addRange ( diagnostics , emitDiagnostics ) ;
172
179
0 commit comments