Skip to content

Wrong exported types #10

Description

@djkfx

Objects in fast-xml-validator/lib/fxv.d.cts has different signature than in sources:

  1. In lib:
declare class SyntaxValidator {
  constructor(options?: validationOptions);
  validate(xmlData: string): true;
  static validate(xmlData: string, options?: validationOptions): true | ValidationError;
}

but in sources static function just create an object and call validate method, so it should also be declared to return true only:
static validate(xmlData: string, options?: validationOptions): true;

  1. In lib:
type ValidationError = {
  err: {
    code: string;
    msg: string,
    line: number,
    col: number
  };
};

in src ( fast-xml-validator/src/ValidationError.js ):

export default class ValidationError extends Error {
  constructor(message, code, line, col) {
    super(message);
    this.name = this.constructor.name;
    this.code = code;
    this.line = line;
    this.col = col;
    Error.captureStackTrace?.(this, this.constructor);
  }
}

so there is no way to catch the error without getting warnings all redeclaring an error interface in own code

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions