File tree Expand file tree Collapse file tree 4 files changed +21
-8
lines changed Expand file tree Collapse file tree 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 {
9595  /** 
9696   * "The property ___ has a setter but no getter." 
9797   */ 
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' 
99105} 
100106
101107export  const  allExtractorMessageIds : Set < string >  =  new  Set < string > ( [ 
@@ -114,5 +120,6 @@ export const allExtractorMessageIds: Set<string> = new Set<string>([
114120  'ae-cyclic-inherit-doc' , 
115121  'ae-unresolved-link' , 
116122  'ae-setter-with-docs' , 
117-   'ae-missing-getter' 
123+   'ae-missing-getter' , 
124+   'ae-wrong-input-file-type' 
118125] ) ; 
Original file line number Diff line number Diff line change @@ -206,14 +206,17 @@ export class Collector {
206206
207207    // We can throw this error earlier in CompilerState.ts, but intentionally wait until after we've logged the 
208208    // 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 ( 
210211      ( {  fileName } )  =>  ! ExtractorConfig . hasDtsFileExtension ( fileName ) 
211212    ) ; 
212213    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 
217220      ) ; 
218221    } 
219222
Original file line number Diff line number Diff line change 7171      "ae-unresolved-inheritdoc-base" : {
7272        "logLevel" : " warning" 
7373        "addToApiReportFile" : true 
74+       },
75+       "ae-wrong-input-file-type" : {
76+         "logLevel" : " error" 
7477      }
7578    },
7679    "tsdocMessageReporting" : {
Original file line number Diff line number Diff line change @@ -135,6 +135,7 @@ export const enum ExtractorMessageId {
135135    MisplacedPackageTag  =  " ae-misplaced-package-tag" 
136136    MissingGetter  =  " ae-missing-getter" 
137137    MissingReleaseTag  =  " ae-missing-release-tag" 
138+     NotDtsFileExtension  =  " ae-wrong-input-file-type" 
138139    PreapprovedBadReleaseTag  =  " ae-preapproved-bad-release-tag" 
139140    PreapprovedUnsupportedType  =  " ae-preapproved-unsupported-type" 
140141    SetterWithDocs  =  " ae-setter-with-docs" 
@@ -265,5 +266,4 @@ export interface IExtractorMessagesConfig {
265266    tsdocMessageReporting? :  IConfigMessageReportingTable ;
266267}
267268
268- 
269269``` 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments