Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stopNodes not in type definitions yet #191

Closed
4 of 7 tasks
sverweij opened this issue Oct 4, 2019 · 0 comments · Fixed by #192
Closed
4 of 7 tasks

stopNodes not in type definitions yet #191

sverweij opened this issue Oct 4, 2019 · 0 comments · Fixed by #192

Comments

@sverweij
Copy link
Contributor

sverweij commented Oct 4, 2019

Checklist

  • Have you asked your question on Stackoverflow or similar forum?
  • Are you running the latest version?
  • Have you included sample input, output, error, and expected output?
  • Have you checked if you are using correct configuration?
  • Did you try online tool? (N/A I think?)

Input

Code

import fastxml from 'fast-xml-parser';

function parse(pXMLString: string): any {
  if (fastxml.validate(pXMLString) === true) {
    return fastxml.parse(pXMLString, {
      attributeNamePrefix: '',
      ignoreAttributes: false,
      stopNodes: ['onentry', 'onexit', 'transition'],
    });
  }
  throw new Error("That doesn't look like valid xml ...\n");
}

Output

When compiling the code, the typescript compiler complains stopNodes doesn't exist on Partial<X2jOptions>.

(Demo repo over here npm i && npm run build to reproduce)

Root cause seems that X2jOptions in src/parser.d.ts doesn't yet contain the stopNodes attribute that was introduced in #150.

src/parseit.ts:8:7 - error TS2345: Argument of type '{ attributeNamePrefix: string; ignoreAttributes: false; stopNodes: string[]; }' is not assignable to parameter of type 'Partial<X2jOptions>'.
  Object literal may only specify known properties, and 'stopNodes' does not exist in type 'Partial<X2jOptions>'.

8       stopNodes: ['onentry', 'onexit', 'transition'],
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


Found 1 error.

expected data

The code compiles without warnings.

Would you like to work on this issue?

  • Yes
  • No
amitguptagwl pushed a commit that referenced this issue Oct 5, 2019
so they can be used cleanly in typescript.

Fixes #191
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 a pull request may close this issue.

1 participant