Skip to content

Wrong exported types #10

Closed
Closed

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

Activity

  1. amitguptagwl commented on Jul 30, 2026

    @amitguptagwl
    Member

    done

  2. djkfx commented on Jul 31, 2026

    @djkfx
    Author

    Ok, you fixed point 1, but ValidationError in _ fast-xml-validator/lib/fxv.d.cts_ still do not match the one in src/ValidationError.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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