@@ -17,6 +17,7 @@ import { ExtractorContext } from '../ExtractorContext';
1717import { ILogger } from './ILogger' ;
1818import ApiJsonGenerator from '../generators/ApiJsonGenerator' ;
1919import ApiFileGenerator from '../generators/ApiFileGenerator' ;
20+ import PackageTypingsGenerator from '../generators/PackageTypingsGenerator' ;
2021import { MonitoredLogger } from './MonitoredLogger' ;
2122
2223/**
@@ -196,7 +197,8 @@ export class Extractor {
196197
197198 // This helps strict-null-checks to understand that _applyConfigDefaults() eliminated
198199 // any undefined members
199- if ( ! ( this . _config . policies && this . _config . apiJsonFile && this . _config . apiReviewFile ) ) {
200+ if ( ! ( this . _config . policies && this . _config . apiJsonFile && this . _config . apiReviewFile
201+ && this . _config . packageTypings ) ) {
200202 throw new Error ( 'The configuration object wasn\'t normalized properly' ) ;
201203 }
202204
@@ -219,12 +221,11 @@ export class Extractor {
219221 const outputFolder : string = path . resolve ( this . _absoluteRootFolder ,
220222 apiJsonFileConfig . outputFolder ) ;
221223
222- fsx . mkdirsSync ( outputFolder ) ;
223-
224224 const jsonGenerator : ApiJsonGenerator = new ApiJsonGenerator ( ) ;
225225 const apiJsonFilename : string = path . join ( outputFolder , packageBaseName + '.api.json' ) ;
226226
227227 this . _monitoredLogger . logVerbose ( 'Writing: ' + apiJsonFilename ) ;
228+ fsx . mkdirsSync ( path . dirname ( apiJsonFilename ) ) ;
228229 jsonGenerator . writeJsonFile ( apiJsonFilename , context ) ;
229230 }
230231
@@ -279,6 +280,18 @@ export class Extractor {
279280 }
280281 }
281282
283+ if ( this . _config . packageTypings . enabled ) {
284+ const packageTypingsGenerator : PackageTypingsGenerator = new PackageTypingsGenerator ( context ) ;
285+
286+ const dtsFilename : string = path . resolve ( this . _absoluteRootFolder ,
287+ this . _config . packageTypings . outputFolder , this . _config . packageTypings . internalFilename ) ;
288+ this . _monitoredLogger . logVerbose ( `Writing package typings: ${ dtsFilename } ` ) ;
289+
290+ fsx . mkdirsSync ( path . dirname ( dtsFilename ) ) ;
291+
292+ packageTypingsGenerator . writeTypingsFile ( dtsFilename ) ;
293+ }
294+
282295 // If there were any errors or warnings, then fail the build
283296 return ( this . _monitoredLogger . errorCount + this . _monitoredLogger . warningCount ) === 0 ;
284297 }
0 commit comments