@@ -17,7 +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/packageTypings/PackageTypingsGenerator' ;
20+ import { PackageTypingsGenerator , PackageTypingsDtsKind } from '../generators/packageTypings/PackageTypingsGenerator' ;
2121import { MonitoredLogger } from './MonitoredLogger' ;
2222
2323/**
@@ -153,16 +153,16 @@ export class Extractor {
153153
154154 this . _localBuild = options . localBuild || false ;
155155
156- switch ( this . _actualConfig . compiler . configType ) {
156+ switch ( this . actualConfig . compiler . configType ) {
157157 case 'tsconfig' :
158- const rootFolder : string = this . _actualConfig . compiler . rootFolder ;
158+ const rootFolder : string = this . actualConfig . compiler . rootFolder ;
159159 if ( ! fsx . existsSync ( rootFolder ) ) {
160160 throw new Error ( 'The root folder does not exist: ' + rootFolder ) ;
161161 }
162162
163163 this . _absoluteRootFolder = path . normalize ( path . resolve ( rootFolder ) ) ;
164164
165- let tsconfig : { } | undefined = this . _actualConfig . compiler . overrideTsconfig ;
165+ let tsconfig : { } | undefined = this . actualConfig . compiler . overrideTsconfig ;
166166 if ( ! tsconfig ) {
167167 // If it wasn't overridden, then load it from disk
168168 tsconfig = JsonFile . load ( path . join ( this . _absoluteRootFolder , 'tsconfig.json' ) ) ;
@@ -172,7 +172,7 @@ export class Extractor {
172172 ts . sys , this . _absoluteRootFolder ) ;
173173
174174 const normalizedEntryPointFile : string = path . normalize (
175- path . resolve ( this . _absoluteRootFolder , this . _actualConfig . project . entryPointSourceFile ) ) ;
175+ path . resolve ( this . _absoluteRootFolder , this . actualConfig . project . entryPointSourceFile ) ) ;
176176
177177 // Append the normalizedEntryPointFile and remove any source files from the list
178178 const analysisFilePaths : string [ ] = Extractor . generateFilePathsForAnalysis ( commandLine . fileNames
@@ -248,12 +248,12 @@ export class Extractor {
248248 }
249249
250250 const projectConfig : IExtractorProjectConfig = options . projectConfig ?
251- options . projectConfig : this . _actualConfig . project ;
251+ options . projectConfig : this . actualConfig . project ;
252252
253253 // This helps strict-null-checks to understand that _applyConfigDefaults() eliminated
254254 // any undefined members
255- if ( ! ( this . _actualConfig . policies && this . _actualConfig . apiJsonFile && this . _actualConfig . apiReviewFile
256- && this . _actualConfig . packageTypings ) ) {
255+ if ( ! ( this . actualConfig . policies && this . actualConfig . apiJsonFile && this . actualConfig . apiReviewFile
256+ && this . actualConfig . packageTypings ) ) {
257257 throw new Error ( 'The configuration object wasn\'t normalized properly' ) ;
258258 }
259259
@@ -265,7 +265,7 @@ export class Extractor {
265265 program : this . _program ,
266266 entryPointFile : path . resolve ( this . _absoluteRootFolder , projectConfig . entryPointSourceFile ) ,
267267 logger : this . _monitoredLogger ,
268- policies : this . _actualConfig . policies
268+ policies : this . actualConfig . policies
269269 } ) ;
270270
271271 for ( const externalJsonFileFolder of projectConfig . externalJsonFileFolders || [ ] ) {
@@ -274,7 +274,7 @@ export class Extractor {
274274
275275 const packageBaseName : string = path . basename ( context . packageName ) ;
276276
277- const apiJsonFileConfig : IExtractorApiJsonFileConfig = this . _actualConfig . apiJsonFile ;
277+ const apiJsonFileConfig : IExtractorApiJsonFileConfig = this . actualConfig . apiJsonFile ;
278278
279279 if ( apiJsonFileConfig . enabled ) {
280280 const outputFolder : string = path . resolve ( this . _absoluteRootFolder ,
@@ -288,16 +288,16 @@ export class Extractor {
288288 jsonGenerator . writeJsonFile ( apiJsonFilename , context ) ;
289289 }
290290
291- if ( this . _actualConfig . apiReviewFile . enabled ) {
291+ if ( this . actualConfig . apiReviewFile . enabled ) {
292292 const generator : ApiFileGenerator = new ApiFileGenerator ( ) ;
293293 const apiReviewFilename : string = packageBaseName + '.api.ts' ;
294294
295295 const actualApiReviewPath : string = path . resolve ( this . _absoluteRootFolder ,
296- this . _actualConfig . apiReviewFile . tempFolder , apiReviewFilename ) ;
296+ this . actualConfig . apiReviewFile . tempFolder , apiReviewFilename ) ;
297297 const actualApiReviewShortPath : string = this . _getShortFilePath ( actualApiReviewPath ) ;
298298
299299 const expectedApiReviewPath : string = path . resolve ( this . _absoluteRootFolder ,
300- this . _actualConfig . apiReviewFile . apiReviewFolder , apiReviewFilename ) ;
300+ this . actualConfig . apiReviewFile . apiReviewFolder , apiReviewFilename ) ;
301301 const expectedApiReviewShortPath : string = this . _getShortFilePath ( expectedApiReviewPath ) ;
302302
303303 const actualApiReviewContent : string = generator . generateApiFileContent ( context ) ;
@@ -339,17 +339,21 @@ export class Extractor {
339339 }
340340 }
341341
342- if ( this . _actualConfig . packageTypings . enabled ) {
342+ if ( this . actualConfig . packageTypings . enabled ) {
343343 const packageTypingsGenerator : PackageTypingsGenerator = new PackageTypingsGenerator ( context ) ;
344+ packageTypingsGenerator . analyze ( ) ;
344345
345- const dtsFilename : string = path . resolve ( this . _absoluteRootFolder ,
346- this . _actualConfig . packageTypings . outputFolder , this . _actualConfig . packageTypings . dtsFilePathForInternal ) ;
346+ this . _generateTypingsFile ( packageTypingsGenerator ,
347+ this . actualConfig . packageTypings . dtsFilePathForPublic ! ,
348+ PackageTypingsDtsKind . PublicRelease ) ;
347349
348- this . _monitoredLogger . logVerbose ( `Writing package typings: ${ dtsFilename } ` ) ;
350+ this . _generateTypingsFile ( packageTypingsGenerator ,
351+ this . actualConfig . packageTypings . dtsFilePathForPreview ! ,
352+ PackageTypingsDtsKind . PreviewRelease ) ;
349353
350- fsx . mkdirsSync ( path . dirname ( dtsFilename ) ) ;
351-
352- packageTypingsGenerator . writeTypingsFile ( dtsFilename ) ;
354+ this . _generateTypingsFile ( packageTypingsGenerator ,
355+ this . actualConfig . packageTypings . dtsFilePathForInternal ! ,
356+ PackageTypingsDtsKind . InternalRelease ) ;
353357 }
354358
355359 if ( this . _localBuild ) {
@@ -361,6 +365,18 @@ export class Extractor {
361365 }
362366 }
363367
368+ private _generateTypingsFile ( packageTypingsGenerator : PackageTypingsGenerator ,
369+ dtsFilePath : string , dtsKind : PackageTypingsDtsKind ) : void {
370+ const dtsFilename : string = path . resolve ( this . _absoluteRootFolder ,
371+ this . actualConfig . packageTypings ! . outputFolder , dtsFilePath ) ;
372+
373+ this . _monitoredLogger . logVerbose ( `Writing package typings: ${ dtsFilename } ` ) ;
374+
375+ fsx . mkdirsSync ( path . dirname ( dtsFilename ) ) ;
376+
377+ packageTypingsGenerator . writeTypingsFile ( dtsFilename , dtsKind ) ;
378+ }
379+
364380 private _getShortFilePath ( absolutePath : string ) : string {
365381 if ( ! path . isAbsolute ( absolutePath ) ) {
366382 throw new Error ( 'Expected absolute path: ' + absolutePath ) ;
0 commit comments