File tree 2 files changed +26
-1
lines changed 2 files changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -188,6 +188,8 @@ export class Collector {
188
188
this . messageRouter . addCompilerDiagnostic ( diagnostic ) ;
189
189
}
190
190
191
+ const sourceFiles : readonly ts . SourceFile [ ] = this . program . getSourceFiles ( ) ;
192
+
191
193
if ( this . messageRouter . showDiagnostics ) {
192
194
this . messageRouter . logDiagnosticHeader ( 'Root filenames' ) ;
193
195
for ( const fileName of this . program . getRootFileNames ( ) ) {
@@ -196,12 +198,25 @@ export class Collector {
196
198
this . messageRouter . logDiagnosticFooter ( ) ;
197
199
198
200
this . messageRouter . logDiagnosticHeader ( 'Files analyzed by compiler' ) ;
199
- for ( const sourceFile of this . program . getSourceFiles ( ) ) {
201
+ for ( const sourceFile of sourceFiles ) {
200
202
this . messageRouter . logDiagnostic ( sourceFile . fileName ) ;
201
203
}
202
204
this . messageRouter . logDiagnosticFooter ( ) ;
203
205
}
204
206
207
+ // We can throw this error earlier in CompilerState.ts, but intentionally wait until after we've logged the
208
+ // associated diagnostic message above to make debugging easier for developers.
209
+ const badSourceFile : boolean = sourceFiles . some (
210
+ ( { fileName } ) => ! ExtractorConfig . hasDtsFileExtension ( fileName )
211
+ ) ;
212
+ if ( badSourceFile ) {
213
+ throw new Error (
214
+ 'API Extractor expects to only process .d.ts files, but encountered non-.d.ts file(s).\n' +
215
+ 'Run with the "--diagnostics" flag and inspect the "Files analyzed by compiler" to find the unexpected ' +
216
+ 'file(s).'
217
+ ) ;
218
+ }
219
+
205
220
// Build the entry point
206
221
const entryPointSourceFile : ts . SourceFile = this . workingPackage . entryPointSourceFile ;
207
222
Original file line number Diff line number Diff line change
1
+ {
2
+ "changes" : [
3
+ {
4
+ "packageName" : " @microsoft/api-extractor" ,
5
+ "comment" : " Throw an error early if API Extractor will attempt to process non-.d.ts files" ,
6
+ "type" : " patch"
7
+ }
8
+ ],
9
+ "packageName" : " @microsoft/api-extractor"
10
+ }
You can’t perform that action at this time.
0 commit comments