Skip to content

Commit

Permalink
Make type declaration more accurate
Browse files Browse the repository at this point in the history
  • Loading branch information
octogonz committed May 14, 2022
1 parent caa76bf commit ca2e07a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions apps/api-extractor/src/generators/ApiModelGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -826,11 +826,11 @@ export class ApiModelGenerator {
const propertyTypeTokenRange: IExcerptTokenRange = ExcerptBuilder.createEmptyTokenRange();

// If the property declaration's type is `undefined`, then we're processing a setter with no corresponding
// getter. Use the parameter type instead (note that TSC will enforce that the setter has exactly one
// parameter).
const propertyTypeNode: ts.TypeNode =
// getter. Use the parameter type instead (note that TypeScript always reports an error if a setter
// does not have exactly one parameter).
const propertyTypeNode: ts.TypeNode | undefined =
(astDeclaration.declaration as ts.PropertyDeclaration | ts.GetAccessorDeclaration).type ||
(astDeclaration.declaration as ts.SetAccessorDeclaration).parameters[0].type!;
(astDeclaration.declaration as ts.SetAccessorDeclaration).parameters[0].type;
nodesToCapture.push({ node: propertyTypeNode, tokenRange: propertyTypeTokenRange });

const excerptTokens: IExcerptToken[] = this._buildExcerptTokens(astDeclaration, nodesToCapture);
Expand Down

0 comments on commit ca2e07a

Please sign in to comment.