diff --git a/types/index.d.ts b/types/index.d.ts index e5c8957f79..5620dbeab7 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -2,7 +2,7 @@ import { Document, Element, DomHandlerOptions } from 'domhandler'; import { ParserOptions } from 'htmlparser2'; declare namespace cheerio { - type AttrFunction = (el: Element, i: number, currentValue: string) => any; + type AttrFunction = (this: Element, i: number, currentValue: string) => any; interface Cheerio { // Document References diff --git a/types/index.test-d.ts b/types/index.test-d.ts index bfed0143c2..c86fcbfe0c 100644 --- a/types/index.test-d.ts +++ b/types/index.test-d.ts @@ -81,8 +81,16 @@ $el.cheerio; $el.attr(); $el.attr('id'); $el.attr('id', 'favorite').html(); -$el.attr('id', (el, i, attr) => el.tagName + i * 2 + attr).html(); -$el.attr('id', (el) => el.tagName).html(); +$el + .attr('id', function (i, attr) { + return this.tagName + i * 2 + attr; + }) + .html(); +$el + .attr('id', function () { + return this.tagName; + }) + .html(); $el.attr({ id: 'uniq', class: 'big' }).html(); $multiEl.prop('foo') === undefined;