Closed johnnyoshika closed 3 years ago
Good catch! Thanks for the heads up, Johnny.
@nonara Thank you for the great library! I depend on it extensively in my project.
Happy to help! @taoqf is the library's author, but I'm sure he'll be glad to hear that it's working well for you!
I have this and several other fixes in place in the following PR, but I'll also follow-up in this thread when we have a release ready.
Corrected in v5
The TypeScript return type for
querySelector()
isHTMLElement
instead ofHTMLElement | null
.querySelector()
can potentially return null if no elements are found. This will allow code that could throw a null reference exception to pass the type checker.Relevant type definition:
https://github.com/taoqf/node-html-parser/blob/2077d420b9cfde74e4f03639fa569b937735ebc5/src/nodes/html.ts#L383-L386
Can you set the return type to
HTMLElement | null
?