Skip to content

problems with typescript #783

@0x0a0d

Description

@0x0a0d

I got multiple problems when using DomUtils with typescript

DomUtils.findAll(el => el.name === 'div' && el.parent?.name === 'body', dom.children')

TS2339: Property 'name' does not exist on type 'NodeWithChildren'.


DomUtils.getElements({name: 'div'}, dom.children).map(elment => element.children)

TS2339: Property 'children' does not exist on type 'Node'.


find(test: (elem: Node) => boolean, nodes: Node[], recurse: boolean, limit: number): Node[]
findAll(test: (elem: Element) => boolean, nodes: Node[]): Element[]

Why typeof test's params of find is Node but findAll is Element? and their return too?


There are cases like these but I can't remember now

How to be clear

Why getElements not return Element[] ?

When will method return Element, Node, NodeWithChildren, ... ?

Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions