private makeDiagnostic()

in src/transforms/deprecated-remover.ts [313:354]


  private makeDiagnostic(
    fqn: string,
    messagePrefix: 'Method',
    context: Method | Initializer,
    assembly: Assembly,
  ): JsiiDiagnostic;
  private makeDiagnostic(
    fqn: string,
    messagePrefix: 'Parameter',
    context: Parameter,
    assembly: Assembly,
  ): JsiiDiagnostic;
  private makeDiagnostic(fqn: string, messagePrefix: 'Property', context: Property, assembly: Assembly): JsiiDiagnostic;
  private makeDiagnostic(
    fqn: string,
    messagePrefix: 'Method' | 'Property' | 'Parameter',
    context: Method | Initializer | Parameter | Property,
    assembly: Assembly,
  ): JsiiDiagnostic {
    const node = bindings.getRelatedNode<
      | ts.AccessorDeclaration
      | ts.MethodDeclaration
      | ts.MethodSignature
      | ts.ParameterDeclaration
      | ts.PropertyDeclaration
      | ts.PropertySignature
    >(context);
    const diagnostic = JsiiDiagnostic.JSII_3999_INCOHERENT_TYPE_MODEL.create(
      node?.type ?? node!,
      `${messagePrefix} has @deprecated type ${fqn}, and it is erased by --strip-deprecated.`,
    );

    const typeInfo = assembly.types?.[fqn];
    const typeNode = typeInfo && bindings.getTypeRelatedNode(typeInfo);
    if (typeNode == null) {
      return diagnostic;
    }
    return diagnostic.addRelatedInformation(
      ts.getNameOfDeclaration(typeNode) ?? typeNode,
      'The @deprecated type is declared here',
    );
  }