File tree 4 files changed +21
-8
lines changed 4 files changed +21
-8
lines changed Original file line number Diff line number Diff line change @@ -95,7 +95,13 @@ export const enum ExtractorMessageId {
95
95
/**
96
96
* "The property ___ has a setter but no getter."
97
97
*/
98
- MissingGetter = 'ae-missing-getter'
98
+ MissingGetter = 'ae-missing-getter' ,
99
+
100
+ /**
101
+ * "Incorrect file type; API Extractor expects to analyze compiler outputs with the .d.ts file extension.
102
+ * Troubleshooting tips: `https://api-extractor.com/link/dts-error`"
103
+ */
104
+ NotDtsFileExtension = 'ae-wrong-input-file-type'
99
105
}
100
106
101
107
export const allExtractorMessageIds : Set < string > = new Set < string > ( [
@@ -114,5 +120,6 @@ export const allExtractorMessageIds: Set<string> = new Set<string>([
114
120
'ae-cyclic-inherit-doc' ,
115
121
'ae-unresolved-link' ,
116
122
'ae-setter-with-docs' ,
117
- 'ae-missing-getter'
123
+ 'ae-missing-getter' ,
124
+ 'ae-wrong-input-file-type'
118
125
] ) ;
Original file line number Diff line number Diff line change @@ -206,14 +206,17 @@ export class Collector {
206
206
207
207
// We can throw this error earlier in CompilerState.ts, but intentionally wait until after we've logged the
208
208
// associated diagnostic message above to make debugging easier for developers.
209
- const badSourceFile : boolean = sourceFiles . some (
209
+ // Typically there will be many such files -- to avoid too much noise, only report the first one.
210
+ const badSourceFile : ts . SourceFile | undefined = sourceFiles . find (
210
211
( { fileName } ) => ! ExtractorConfig . hasDtsFileExtension ( fileName )
211
212
) ;
212
213
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).'
214
+ this . messageRouter . addAnalyzerIssueForPosition (
215
+ ExtractorMessageId . NotDtsFileExtension ,
216
+ 'Incorrect file type; API Extractor expects to analyze compiler outputs with the .d.ts file extension. ' +
217
+ 'Troubleshooting tips: https://api-extractor.com/link/dts-error' ,
218
+ badSourceFile ,
219
+ 0
217
220
) ;
218
221
}
219
222
Original file line number Diff line number Diff line change 71
71
"ae-unresolved-inheritdoc-base" : {
72
72
"logLevel" : " warning" ,
73
73
"addToApiReportFile" : true
74
+ },
75
+ "ae-wrong-input-file-type" : {
76
+ "logLevel" : " error"
74
77
}
75
78
},
76
79
"tsdocMessageReporting" : {
Original file line number Diff line number Diff line change @@ -135,6 +135,7 @@ export const enum ExtractorMessageId {
135
135
MisplacedPackageTag = " ae-misplaced-package-tag" ,
136
136
MissingGetter = " ae-missing-getter" ,
137
137
MissingReleaseTag = " ae-missing-release-tag" ,
138
+ NotDtsFileExtension = " ae-wrong-input-file-type" ,
138
139
PreapprovedBadReleaseTag = " ae-preapproved-bad-release-tag" ,
139
140
PreapprovedUnsupportedType = " ae-preapproved-unsupported-type" ,
140
141
SetterWithDocs = " ae-setter-with-docs" ,
@@ -265,5 +266,4 @@ export interface IExtractorMessagesConfig {
265
266
tsdocMessageReporting? : IConfigMessageReportingTable ;
266
267
}
267
268
268
-
269
269
```
You can’t perform that action at this time.
0 commit comments