Skip to content

Commit 5790e5f

Browse files
committed
A bit more cleanup
1 parent b117031 commit 5790e5f

File tree

2 files changed

+16
-20
lines changed

2 files changed

+16
-20
lines changed

apps/api-extractor/src/collector/MessageRouter.ts

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -204,16 +204,14 @@ export class MessageRouter {
204204
// NOTE: Since compiler errors pertain to issues specific to the .d.ts files,
205205
// we do not apply source mappings for them.
206206
const sourceFile: ts.SourceFile = diagnostic.file;
207-
const sourceLocation: ISourceLocation | undefined = this._sourceMapper.getSourceLocationFromFileAndPos(
207+
const sourceLocation: ISourceLocation = this._sourceMapper.getSourceLocationFromFileAndPos(
208208
sourceFile,
209209
diagnostic.start || 0,
210210
true /* useDtsLocation */
211211
);
212-
if (sourceLocation) {
213-
options.sourceFilePath = sourceLocation.sourceFilePath;
214-
options.sourceFileLine = sourceLocation.sourceFileLine;
215-
options.sourceFileColumn = sourceLocation.sourceFileColumn;
216-
}
212+
options.sourceFilePath = sourceLocation.sourceFilePath;
213+
options.sourceFileLine = sourceLocation.sourceFileLine;
214+
options.sourceFileColumn = sourceLocation.sourceFileColumn;
217215
}
218216

219217
this._messages.push(new ExtractorMessage(options));
@@ -262,15 +260,13 @@ export class MessageRouter {
262260
text: message.unformattedText
263261
};
264262

265-
const sourceLocation: ISourceLocation | undefined = this._sourceMapper.getSourceLocationFromFileAndPos(
263+
const sourceLocation: ISourceLocation = this._sourceMapper.getSourceLocationFromFileAndPos(
266264
sourceFile,
267265
message.textRange.pos
268266
);
269-
if (sourceLocation) {
270-
options.sourceFilePath = sourceLocation.sourceFilePath;
271-
options.sourceFileLine = sourceLocation.sourceFileLine;
272-
options.sourceFileColumn = sourceLocation.sourceFileColumn;
273-
}
267+
options.sourceFilePath = sourceLocation.sourceFilePath;
268+
options.sourceFileLine = sourceLocation.sourceFileLine;
269+
options.sourceFileColumn = sourceLocation.sourceFileColumn;
274270

275271
const extractorMessage: ExtractorMessage = new ExtractorMessage(options);
276272

@@ -382,15 +378,13 @@ export class MessageRouter {
382378
properties
383379
};
384380

385-
const sourceLocation: ISourceLocation | undefined = this._sourceMapper.getSourceLocationFromFileAndPos(
381+
const sourceLocation: ISourceLocation = this._sourceMapper.getSourceLocationFromFileAndPos(
386382
sourceFile,
387383
pos
388384
);
389-
if (sourceLocation) {
390-
options.sourceFilePath = sourceLocation.sourceFilePath;
391-
options.sourceFileLine = sourceLocation.sourceFileLine;
392-
options.sourceFileColumn = sourceLocation.sourceFileColumn;
393-
}
385+
options.sourceFilePath = sourceLocation.sourceFilePath;
386+
options.sourceFileLine = sourceLocation.sourceFileLine;
387+
options.sourceFileColumn = sourceLocation.sourceFileColumn;
394388

395389
const extractorMessage: ExtractorMessage = new ExtractorMessage(options);
396390

apps/api-extractor/src/generators/ApiModelGenerator.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1132,8 +1132,10 @@ export class ApiModelGenerator {
11321132

11331133
private _getSourceFile(declaration: ts.Declaration): string | undefined {
11341134
const sourceFile: ts.SourceFile = declaration.getSourceFile();
1135-
const sourceLocation: ISourceLocation | undefined =
1136-
this._collector.sourceMapper.getSourceLocationFromFileAndPos(sourceFile, declaration.pos);
1135+
const sourceLocation: ISourceLocation = this._collector.sourceMapper.getSourceLocationFromFileAndPos(
1136+
sourceFile,
1137+
declaration.pos
1138+
);
11371139

11381140
return path.relative(this._collector.extractorConfig.projectFolder, sourceLocation.sourceFilePath);
11391141
}

0 commit comments

Comments
 (0)