node-xml2js icon indicating copy to clipboard operation
node-xml2js copied to clipboard

Changing the tag name key when using `preserveChildrenOrder = true`

Open Treycos opened this issue 5 years ago • 1 comments

Currently, using preserveChildrenOrder = true will make every node have a #name property containing their tag name.

With the latest iteration of JavaScript, variable names starting with an # will now be considered private properties by default.

This makes creating TypeScript interfaces with this property impossible and may also be a breaking change in next-gen browsers supporting the private field feature.

Example TypeScript code:

export interface ScrapNode {
    #name: string;
}

Will generate the following error:

image

Should the default tag property be changed, or can we get an additional option to change ?

Thank you for your help

EDIT

Deconstruction also becomes tedious:

const { children, #name } = node;

image

Treycos avatar Jul 07 '20 17:07 Treycos

+1 for additional option so that #name can be configured like in case of attrkey and charkey

He-Wolf avatar Dec 19 '20 11:12 He-Wolf