From 5bca9792476a08bf500e20c1978e73b760b714f1 Mon Sep 17 00:00:00 2001 From: isMeCoder Date: Mon, 30 Oct 2017 10:11:20 -0700 Subject: [PATCH] .html() can return null .html() can return null when querying an element that does not exist. Repro: const response = await axios.default.get('https://www.google.com/') const $ = cheerio.load(response.data) const foo = $('.bar').html() console.log(`foo is: ${foo}`) //foo is: null --- types/cheerio/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/cheerio/index.d.ts b/types/cheerio/index.d.ts index 93f30e8a9f..511fce354d 100644 --- a/types/cheerio/index.d.ts +++ b/types/cheerio/index.d.ts @@ -172,7 +172,7 @@ interface Cheerio { empty(): Cheerio; - html(): string; + html(): string | null; html(html: string): Cheerio; text(): string;