Skip to content

fix X2jOptions type by defining two distinct types depending on jPath value#805

Open
KuSh wants to merge 1 commit intoNaturalIntelligence:masterfrom
KuSh:master
Open

fix X2jOptions type by defining two distinct types depending on jPath value#805
KuSh wants to merge 1 commit intoNaturalIntelligence:masterfrom
KuSh:master

Conversation

@KuSh
Copy link

@KuSh KuSh commented Mar 19, 2026

Purpose / Goal

Avoid type check errors for current fxp users by not pushing the new path-expression-matcher Matcher type on them.

fixes #803

Unfortunately I didn't found an elegant solution to avoid duplicating types, something I've tested was like:

type X2jBaseOptions<M extends string | Matcher> = {
  // ... unique definitions of attributes and documentation ...
}

type X2jJPathOptions = X2jBaseOptions<string> & { jPath?: true; };

type X2jMatcherOptions = X2jBaseOptions<Matcher> & { jPath: false; };

export type X2jOptions = X2jJPathOptions | X2jMatcherOptions;

Unfortunately I'm not sure the end user experience will be good. I can update the PR into that if you prefer.

Type

Please mention the type of PR

  • Bug Fix
  • Refactoring / Technology upgrade
  • New Feature

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enhance type definition for XMLParser isArray option when using TypeScript

1 participant