TobiasNickel / tXml

:zap:very small and fast xml-parser in pure javascript:zap:
MIT License
217 stars 28 forks source link

tXml.d.ts #20

Open moongazers opened 3 years ago

moongazers commented 3 years ago

Should the type be

export type tNode = { tagName: string; attributes: object; children: (tNode | string | number)[]; };

?

TobiasNickel commented 3 years ago

strings do not get parsed automatically into numbers. did you find any number? and can share some example?

moongazers commented 3 years ago

Maybe it's due to my poor typescript understanding but 'children' prop in tNode is like

children: ["aaaa", "bbbb"]
children: [
{tagName: "1111", attributes: {...}, children:[...]}
{tagName: "1111", attributes: {...}, children:[...]}
]

Currently tNode type declaration is export type tNode = { tagName: string; attributes: object; children: tNode | string | number[]; }; Should 'children' always be array at least ? Or am I missing sth here... Thanks!

TobiasNickel commented 3 years ago

ahh, yes, the typedefinition should not contain the number. For the children as well as for the parser result. I will take that into the next 4.1 release. I already have one other change I want to release. Will do this at the weekend.

moongazers commented 3 years ago

Thanks Tobias, tXml is such a great lib, the performance is outstanding! Really help our project a lot. Will dig a bit when time permitted :)