Leonidas-from-XIV / node-xml2js

XML to JavaScript object converter.
MIT License
4.87k stars 601 forks source link

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

Open Treycos opened 4 years ago

Treycos commented 4 years ago

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

He-Wolf commented 3 years ago

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