Skip to content

Commit

Permalink
test get changes
Browse files Browse the repository at this point in the history
  • Loading branch information
5saviahv committed Feb 25, 2021
1 parent 253cfe5 commit cb6f40f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ declare namespace cheerio {

eq(index: number): Cheerio;

get(): any[];
get(index: number): any;
get(): Element[];
get(index: number): Element | undefined;

index(): number;
index(selector: string): number;
Expand Down
5 changes: 3 additions & 2 deletions types/index.test-d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { expectType } from 'tsd';
import cheerio from '..';
import type { Element, Node } from 'domhandler';

/*
* LOADING
Expand All @@ -19,7 +20,7 @@ cheerio(html);
cheerio('ul', html);
cheerio('li', 'ul', html);

const $fromElement = cheerio.load($('ul').get(0));
const $fromElement = cheerio.load($('ul').get(0) as Element);

if ($fromElement('ul > li').length !== 3) {
throw new Error(
Expand Down Expand Up @@ -248,7 +249,7 @@ $el.eq(0).text();
$el.eq(-1).text();

// .get( [i] )
$el.get(0).tagName;
$el.get(0)?.tagName;
$el.get().length;

// .index()
Expand Down

0 comments on commit cb6f40f

Please sign in to comment.