Closed rschristian closed 4 years ago
I am so sorry that we do not have firstChild(and many attributes and methods) defined in TextNode.I have changed the definition in 1.2.18. let me know if you still have issues.
Well one step closer, but structure
does not exist on Node
. It will need to be added here for someone to follow even the second line of the demo.
It is not enough if only definition defined.see https://github.com/taoqf/node-html-parser/blob/master/src/nodes/html.ts#L228
@rschristian @taoqf If you want to follow the README with TypeScript, write the following:
import { HTMLElement, parse } from 'node-html-parser';
const root: HTMLElement = parse('<ul id="list"><li>Hello World</li></ul>');
console.log((root.firstChild as HTMLElement).structure);
Since HTMLElement is overwritten by this package, you need to import the one which has been overwritten and not the base one.
Trying to follow the little example in the ReadMe, it seems like your type definitions are off, as it certainly won't compile. The following code...
...results in the following error...
Using Node-HTML-Parser v1.2.17