diff --git a/types/chai-enzyme/index.d.ts b/types/chai-enzyme/index.d.ts index 1056b9f27b..04416179af 100644 --- a/types/chai-enzyme/index.d.ts +++ b/types/chai-enzyme/index.d.ts @@ -176,7 +176,7 @@ declare namespace Chai { declare module "chai-enzyme" { import { ShallowWrapper, ReactWrapper } from "enzyme"; - type DebugWrapper = ShallowWrapper | Cheerio | ReactWrapper; + type DebugWrapper = ShallowWrapper | cheerio.Cheerio | ReactWrapper; function chaiEnzyMe(wrapper?: (debugWrapper: DebugWrapper) => string): Chai.ChaiPlugin; module chaiEnzyMe { diff --git a/types/cheerio/cheerio-tests.ts b/types/cheerio/cheerio-tests.ts index 3310c58b36..90a5bc6065 100644 --- a/types/cheerio/cheerio-tests.ts +++ b/types/cheerio/cheerio-tests.ts @@ -21,7 +21,7 @@ cheerio('li', 'ul', html); const $fromElement = cheerio.load($('ul').get(0)); if ($fromElement('ul > li').length !== 3) { - throw new Error('Expecting 3 elements when passing `CheerioElement` to `load()`'); + throw new Error('Expecting 3 elements when passing `cheerio.Element` to `load()`'); } $ = cheerio.load(Buffer.from(html)); @@ -337,3 +337,6 @@ $.parseHTML(html, null, true); $el.toArray(); cheerio.html($el); + +// $ExpectType string +cheerio.version; diff --git a/types/cheerio/index.d.ts b/types/cheerio/index.d.ts index e9476aac69..348b3c84e1 100644 --- a/types/cheerio/index.d.ts +++ b/types/cheerio/index.d.ts @@ -13,292 +13,295 @@ /// -declare type AttrFunction = (el: CheerioElement, i: number, currentValue: string) => any; - -interface Cheerio { - // Document References - // Cheerio https://github.com/cheeriojs/cheerio - // JQuery http://api.jquery.com - - [index: number]: CheerioElement; - cheerio: string; - length: number; - - // Attributes - - attr(): { [attr: string]: string }; - attr(name: string): string | undefined; - attr(name: string, value: AttrFunction): Cheerio; - // `value` *can* be `any` here but: - // 1. That makes type-checking the function-type useless - // 2. It's converted to a string anyways - attr(name: string, value: string): Cheerio; - // The map's values *can* be `any` but they'll all be cast to strings - // regardless. - attr(map: { [key: string]: any }): Cheerio; - - data(): any; - data(name: string): any; - data(name: string, value: any): any; - - val(): string; - val(value: string): Cheerio; - - removeAttr(name: string): Cheerio; - - has(selector: string): Cheerio; - has(element: CheerioElement): Cheerio; - - hasClass(className: string): boolean; - addClass(classNames: string): Cheerio; - - removeClass(): Cheerio; - removeClass(className: string): Cheerio; - removeClass(func: (index: number, className: string) => string): Cheerio; - - toggleClass(className: string): Cheerio; - toggleClass(className: string, toggleSwitch: boolean): Cheerio; - toggleClass(toggleSwitch?: boolean): Cheerio; - toggleClass( - func: (index: number, className: string, toggleSwitch: boolean) => string, - toggleSwitch?: boolean, - ): Cheerio; - - is(selector: string): boolean; - is(element: CheerioElement): boolean; - is(element: CheerioElement[]): boolean; - is(selection: Cheerio): boolean; - is(func: (index: number, element: CheerioElement) => boolean): boolean; - - // Form - serialize(): string; - serializeArray(): { name: string; value: string }[]; - - // Traversing - - find(selector: string): Cheerio; - find(element: Cheerio): Cheerio; - - parent(selector?: string): Cheerio; - parents(selector?: string): Cheerio; - parentsUntil(selector?: string, filter?: string): Cheerio; - parentsUntil(element: CheerioElement, filter?: string): Cheerio; - parentsUntil(element: Cheerio, filter?: string): Cheerio; - - prop(name: string): any; - prop(name: string, value: any): Cheerio; - - closest(): Cheerio; - closest(selector: string): Cheerio; - - next(selector?: string): Cheerio; - nextAll(): Cheerio; - nextAll(selector: string): Cheerio; - - nextUntil(selector?: string, filter?: string): Cheerio; - nextUntil(element: CheerioElement, filter?: string): Cheerio; - nextUntil(element: Cheerio, filter?: string): Cheerio; - - prev(selector?: string): Cheerio; - prevAll(): Cheerio; - prevAll(selector: string): Cheerio; - - prevUntil(selector?: string, filter?: string): Cheerio; - prevUntil(element: CheerioElement, filter?: string): Cheerio; - prevUntil(element: Cheerio, filter?: string): Cheerio; - - slice(start: number, end?: number): Cheerio; - - siblings(selector?: string): Cheerio; - - children(selector?: string): Cheerio; - - contents(): Cheerio; - - each(func: (index: number, element: CheerioElement) => any): Cheerio; - map(func: (index: number, element: CheerioElement) => any): Cheerio; - - filter(selector: string): Cheerio; - filter(selection: Cheerio): Cheerio; - filter(element: CheerioElement): Cheerio; - filter(elements: CheerioElement[]): Cheerio; - filter(func: (index: number, element: CheerioElement) => boolean): Cheerio; - - not(selector: string): Cheerio; - not(selection: Cheerio): Cheerio; - not(element: CheerioElement): Cheerio; - not(func: (index: number, element: CheerioElement) => boolean): Cheerio; - - first(): Cheerio; - last(): Cheerio; - - eq(index: number): Cheerio; - - get(): any[]; - get(index: number): any; - - index(): number; - index(selector: string): number; - index(selection: Cheerio): number; - - end(): Cheerio; - - add(selectorOrHtml: string): Cheerio; - add(selector: string, context: Document): Cheerio; - add(element: CheerioElement): Cheerio; - add(elements: CheerioElement[]): Cheerio; - add(selection: Cheerio): Cheerio; - - addBack(): Cheerio; - addBack(filter: string): Cheerio; - - // Manipulation - appendTo(target: Cheerio): Cheerio; - prependTo(target: Cheerio): Cheerio; - - append(content: string, ...contents: any[]): Cheerio; - append(content: Document, ...contents: any[]): Cheerio; - append(content: Document[], ...contents: any[]): Cheerio; - append(content: Cheerio, ...contents: any[]): Cheerio; - - prepend(content: string, ...contents: any[]): Cheerio; - prepend(content: Document, ...contents: any[]): Cheerio; - prepend(content: Document[], ...contents: any[]): Cheerio; - prepend(content: Cheerio, ...contents: any[]): Cheerio; - - after(content: string, ...contents: any[]): Cheerio; - after(content: Document, ...contents: any[]): Cheerio; - after(content: Document[], ...contents: any[]): Cheerio; - after(content: Cheerio, ...contents: any[]): Cheerio; - - insertAfter(content: string): Cheerio; - insertAfter(content: Document): Cheerio; - insertAfter(content: Cheerio): Cheerio; - - before(content: string, ...contents: any[]): Cheerio; - before(content: Document, ...contents: any[]): Cheerio; - before(content: Document[], ...contents: any[]): Cheerio; - before(content: Cheerio, ...contents: any[]): Cheerio; - - insertBefore(content: string): Cheerio; - insertBefore(content: Document): Cheerio; - insertBefore(content: Cheerio): Cheerio; - - remove(selector?: string): Cheerio; - - replaceWith(content: string): Cheerio; - replaceWith(content: CheerioElement): Cheerio; - replaceWith(content: CheerioElement[]): Cheerio; - replaceWith(content: Cheerio): Cheerio; - replaceWith(content: () => Cheerio): Cheerio; - - empty(): Cheerio; - - html(): string | null; - html(html: string): Cheerio; - - text(): string; - text(text: string): Cheerio; - - wrap(content: string): Cheerio; - wrap(content: Document): Cheerio; - wrap(content: Cheerio): Cheerio; - - css(propertyName: string): string; - css(propertyNames: string[]): string[]; - css(propertyName: string, value: string): Cheerio; - css(propertyName: string, value: number): Cheerio; - css(propertyName: string, func: (index: number, value: string) => string): Cheerio; - css(propertyName: string, func: (index: number, value: string) => number): Cheerio; - css(properties: Object): Cheerio; - - // Rendering - - // Miscellaneous - - clone(): Cheerio; - - // Not Documented - - toArray(): CheerioElement[]; -} - -interface CheerioOptionsInterface { - // Document References - // Cheerio https://github.com/cheeriojs/cheerio - // HTMLParser2 https://github.com/fb55/htmlparser2/wiki/Parser-options - // DomHandler https://github.com/fb55/DomHandler - - xmlMode?: boolean; - decodeEntities?: boolean; - lowerCaseTags?: boolean; - lowerCaseAttributeNames?: boolean; - recognizeCDATA?: boolean; - recognizeSelfClosing?: boolean; - normalizeWhitespace?: boolean; - withStartIndices?: boolean; - withEndIndices?: boolean; - ignoreWhitespace?: boolean; - _useHtmlParser2?: boolean; -} - -interface CheerioSelector { - (selector: string): Cheerio; - (selector: string, context: string): Cheerio; - (selector: string, context: CheerioElement): Cheerio; - (selector: string, context: CheerioElement[]): Cheerio; - (selector: string, context: Cheerio): Cheerio; - (selector: string, context: string, root: string): Cheerio; - (selector: string, context: CheerioElement, root: string): Cheerio; - (selector: string, context: CheerioElement[], root: string): Cheerio; - (selector: string, context: Cheerio, root: string): Cheerio; - (selector: any): Cheerio; -} - -interface CheerioStatic extends CheerioSelector { - // Document References - // Cheerio https://github.com/cheeriojs/cheerio - // JQuery http://api.jquery.com - root(): Cheerio; - contains(container: CheerioElement, contained: CheerioElement): boolean; - parseHTML(data: string, context?: Document, keepScripts?: boolean): Document[]; - - html(options?: CheerioOptionsInterface): string; - html(dom: string | Cheerio | CheerioElement, options?: CheerioOptionsInterface): string; - - xml(dom?: string | Cheerio | CheerioElement): string; -} - -interface CheerioElement { - // Document References - // Node Console - tagName: string; - type: string; - name: string; - attribs: { [attr: string]: string }; - children: CheerioElement[]; - childNodes: CheerioElement[]; - lastChild: CheerioElement; - firstChild: CheerioElement; - next: CheerioElement; - nextSibling: CheerioElement; - prev: CheerioElement; - previousSibling: CheerioElement; - parent: CheerioElement; - parentNode: CheerioElement; - nodeValue: string; - data?: string; - startIndex?: number; -} - -interface CheerioAPI extends CheerioSelector, CheerioStatic { - load(html: string | Buffer, options?: CheerioOptionsInterface): CheerioStatic; - load(element: CheerioElement, options?: CheerioOptionsInterface): CheerioStatic; -} - interface Document {} -declare module 'cheerio' { - const cheerio: CheerioAPI; - export = cheerio; +declare namespace cheerio { + interface Element { + // Document References + // Node Console + tagName: string; + type: string; + name: string; + attribs: { [attr: string]: string }; + children: Element[]; + childNodes: Element[]; + lastChild: Element; + firstChild: Element; + next: Element; + nextSibling: Element; + prev: Element; + previousSibling: Element; + parent: Element; + parentNode: Element; + nodeValue: string; + data?: string; + startIndex?: number; + } + + type AttrFunction = (el: Element, i: number, currentValue: string) => any; + + interface Cheerio { + // Document References + // Cheerio https://github.com/cheeriojs/cheerio + // JQuery http://api.jquery.com + + [index: number]: Element; + cheerio: string; + length: number; + + // Attributes + + attr(): { [attr: string]: string }; + attr(name: string): string | undefined; + attr(name: string, value: AttrFunction): Cheerio; + // `value` *can* be `any` here but: + // 1. That makes type-checking the function-type useless + // 2. It's converted to a string anyways + attr(name: string, value: string): Cheerio; + // The map's values *can* be `any` but they'll all be cast to strings + // regardless. + attr(map: { [key: string]: any }): Cheerio; + + data(): any; + data(name: string): any; + data(name: string, value: any): any; + + val(): string; + val(value: string): Cheerio; + + removeAttr(name: string): Cheerio; + + has(selector: string): Cheerio; + has(element: Element): Cheerio; + + hasClass(className: string): boolean; + addClass(classNames: string): Cheerio; + + removeClass(): Cheerio; + removeClass(className: string): Cheerio; + removeClass(func: (index: number, className: string) => string): Cheerio; + + toggleClass(className: string): Cheerio; + toggleClass(className: string, toggleSwitch: boolean): Cheerio; + toggleClass(toggleSwitch?: boolean): Cheerio; + toggleClass( + func: (index: number, className: string, toggleSwitch: boolean) => string, + toggleSwitch?: boolean, + ): Cheerio; + + is(selector: string): boolean; + is(element: Element): boolean; + is(element: Element[]): boolean; + is(selection: Cheerio): boolean; + is(func: (index: number, element: Element) => boolean): boolean; + + // Form + serialize(): string; + serializeArray(): { name: string; value: string }[]; + + // Traversing + + find(selector: string): Cheerio; + find(element: Cheerio): Cheerio; + + parent(selector?: string): Cheerio; + parents(selector?: string): Cheerio; + parentsUntil(selector?: string, filter?: string): Cheerio; + parentsUntil(element: Element, filter?: string): Cheerio; + parentsUntil(element: Cheerio, filter?: string): Cheerio; + + prop(name: string): any; + prop(name: string, value: any): Cheerio; + + closest(): Cheerio; + closest(selector: string): Cheerio; + + next(selector?: string): Cheerio; + nextAll(): Cheerio; + nextAll(selector: string): Cheerio; + + nextUntil(selector?: string, filter?: string): Cheerio; + nextUntil(element: Element, filter?: string): Cheerio; + nextUntil(element: Cheerio, filter?: string): Cheerio; + + prev(selector?: string): Cheerio; + prevAll(): Cheerio; + prevAll(selector: string): Cheerio; + + prevUntil(selector?: string, filter?: string): Cheerio; + prevUntil(element: Element, filter?: string): Cheerio; + prevUntil(element: Cheerio, filter?: string): Cheerio; + + slice(start: number, end?: number): Cheerio; + + siblings(selector?: string): Cheerio; + + children(selector?: string): Cheerio; + + contents(): Cheerio; + + each(func: (index: number, element: Element) => any): Cheerio; + map(func: (index: number, element: Element) => any): Cheerio; + + filter(selector: string): Cheerio; + filter(selection: Cheerio): Cheerio; + filter(element: Element): Cheerio; + filter(elements: Element[]): Cheerio; + filter(func: (index: number, element: Element) => boolean): Cheerio; + + not(selector: string): Cheerio; + not(selection: Cheerio): Cheerio; + not(element: Element): Cheerio; + not(func: (index: number, element: Element) => boolean): Cheerio; + + first(): Cheerio; + last(): Cheerio; + + eq(index: number): Cheerio; + + get(): any[]; + get(index: number): any; + + index(): number; + index(selector: string): number; + index(selection: Cheerio): number; + + end(): Cheerio; + + add(selectorOrHtml: string): Cheerio; + add(selector: string, context: Document): Cheerio; + add(element: Element): Cheerio; + add(elements: Element[]): Cheerio; + add(selection: Cheerio): Cheerio; + + addBack(): Cheerio; + addBack(filter: string): Cheerio; + + // Manipulation + appendTo(target: Cheerio): Cheerio; + prependTo(target: Cheerio): Cheerio; + + append(content: string, ...contents: any[]): Cheerio; + append(content: Document, ...contents: any[]): Cheerio; + append(content: Document[], ...contents: any[]): Cheerio; + append(content: Cheerio, ...contents: any[]): Cheerio; + + prepend(content: string, ...contents: any[]): Cheerio; + prepend(content: Document, ...contents: any[]): Cheerio; + prepend(content: Document[], ...contents: any[]): Cheerio; + prepend(content: Cheerio, ...contents: any[]): Cheerio; + + after(content: string, ...contents: any[]): Cheerio; + after(content: Document, ...contents: any[]): Cheerio; + after(content: Document[], ...contents: any[]): Cheerio; + after(content: Cheerio, ...contents: any[]): Cheerio; + + insertAfter(content: string): Cheerio; + insertAfter(content: Document): Cheerio; + insertAfter(content: Cheerio): Cheerio; + + before(content: string, ...contents: any[]): Cheerio; + before(content: Document, ...contents: any[]): Cheerio; + before(content: Document[], ...contents: any[]): Cheerio; + before(content: Cheerio, ...contents: any[]): Cheerio; + + insertBefore(content: string): Cheerio; + insertBefore(content: Document): Cheerio; + insertBefore(content: Cheerio): Cheerio; + + remove(selector?: string): Cheerio; + + replaceWith(content: string): Cheerio; + replaceWith(content: Element): Cheerio; + replaceWith(content: Element[]): Cheerio; + replaceWith(content: Cheerio): Cheerio; + replaceWith(content: () => Cheerio): Cheerio; + + empty(): Cheerio; + + html(): string | null; + html(html: string): Cheerio; + + text(): string; + text(text: string): Cheerio; + + wrap(content: string): Cheerio; + wrap(content: Document): Cheerio; + wrap(content: Cheerio): Cheerio; + + css(propertyName: string): string; + css(propertyNames: string[]): string[]; + css(propertyName: string, value: string): Cheerio; + css(propertyName: string, value: number): Cheerio; + css(propertyName: string, func: (index: number, value: string) => string): Cheerio; + css(propertyName: string, func: (index: number, value: string) => number): Cheerio; + css(properties: Object): Cheerio; + + // Rendering + + // Miscellaneous + + clone(): Cheerio; + + // Not Documented + + toArray(): Element[]; + } + + interface CheerioParserOptions { + // Document References + // Cheerio https://github.com/cheeriojs/cheerio + // HTMLParser2 https://github.com/fb55/htmlparser2/wiki/Parser-options + // DomHandler https://github.com/fb55/DomHandler + + xmlMode?: boolean; + decodeEntities?: boolean; + lowerCaseTags?: boolean; + lowerCaseAttributeNames?: boolean; + recognizeCDATA?: boolean; + recognizeSelfClosing?: boolean; + normalizeWhitespace?: boolean; + withStartIndices?: boolean; + withEndIndices?: boolean; + ignoreWhitespace?: boolean; + _useHtmlParser2?: boolean; + } + + interface Selector { + (selector: string): Cheerio; + (selector: string, context: string): Cheerio; + (selector: string, context: Element): Cheerio; + (selector: string, context: Element[]): Cheerio; + (selector: string, context: Cheerio): Cheerio; + (selector: string, context: string, root: string): Cheerio; + (selector: string, context: Element, root: string): Cheerio; + (selector: string, context: Element[], root: string): Cheerio; + (selector: string, context: Cheerio, root: string): Cheerio; + (selector: any): Cheerio; + } + + interface Root extends Selector { + // Document References + // Cheerio https://github.com/cheeriojs/cheerio + // JQuery http://api.jquery.com + root(): Cheerio; + contains(container: Element, contained: Element): boolean; + parseHTML(data: string, context?: Document, keepScripts?: boolean): Document[]; + + html(options?: CheerioParserOptions): string; + html(dom: string | Cheerio | Element, options?: CheerioParserOptions): string; + + xml(dom?: string | Cheerio | Element): string; + } + + interface CheerioAPI extends Root { + version: string; + load(html: string | Buffer, options?: CheerioParserOptions): Root; + load(element: Element, options?: CheerioParserOptions): Root; + } +} + +declare module 'cheerio' { + const cheerioModule: cheerio.CheerioAPI; + export = cheerioModule; } diff --git a/types/enzyme-react-intl/index.d.ts b/types/enzyme-react-intl/index.d.ts index 34c1890292..d1e73a6805 100644 --- a/types/enzyme-react-intl/index.d.ts +++ b/types/enzyme-react-intl/index.d.ts @@ -30,7 +30,7 @@ export function mountWithIntl(node: ReactElement

, options?: MountRender // render method // tslint:disable-next-line no-unnecessary-generics -export function renderWithIntl(node: ReactElement

, options?: any): Cheerio; +export function renderWithIntl(node: ReactElement

, options?: any): cheerio.Cheerio; // other methods diff --git a/types/enzyme-to-json/index.d.ts b/types/enzyme-to-json/index.d.ts index f7c4d75da3..64fdc453e2 100644 --- a/types/enzyme-to-json/index.d.ts +++ b/types/enzyme-to-json/index.d.ts @@ -6,4 +6,4 @@ import { ReactWrapper, ShallowWrapper } from 'enzyme'; -export default function toJson(wrapper: ShallowWrapper | ReactWrapper | Cheerio): object; +export default function toJson(wrapper: ShallowWrapper | ReactWrapper | cheerio.Cheerio): object; diff --git a/types/enzyme/enzyme-tests.tsx b/types/enzyme/enzyme-tests.tsx index 84ec16ef9c..5936ec7112 100644 --- a/types/enzyme/enzyme-tests.tsx +++ b/types/enzyme/enzyme-tests.tsx @@ -998,7 +998,7 @@ function ReactWrapperTest() { // CheerioWrapper function CheerioWrapperTest() { - const wrapper: Cheerio = + const wrapper: cheerio.Cheerio = shallow(

).render() || mount(
).render(); diff --git a/types/enzyme/index.d.ts b/types/enzyme/index.d.ts index 902c451b81..0e2f066c06 100644 --- a/types/enzyme/index.d.ts +++ b/types/enzyme/index.d.ts @@ -381,7 +381,7 @@ export interface CommonWrapper

> { /** * Renders the component to static markup and returns a Cheerio wrapper around the result. */ - render(): Cheerio; + render(): cheerio.Cheerio; /** * Returns the type of the current node of this wrapper. If it's a composite component, this will be the @@ -727,7 +727,7 @@ export function mount(node: ReactElement

, options?: MountRendererProps) /** * Render react components to static HTML and analyze the resulting HTML structure. */ -export function render(node: ReactElement

, options?: any): Cheerio; +export function render(node: ReactElement

, options?: any): cheerio.Cheerio; // See https://github.com/airbnb/enzyme/blob/v3.10.0/packages/enzyme/src/EnzymeAdapter.js export class EnzymeAdapter { diff --git a/types/gulp-cheerio/gulp-cheerio-tests.ts b/types/gulp-cheerio/gulp-cheerio-tests.ts index e2d3bfe267..b94cd232b2 100644 --- a/types/gulp-cheerio/gulp-cheerio-tests.ts +++ b/types/gulp-cheerio/gulp-cheerio-tests.ts @@ -1,4 +1,5 @@ -import cheerio = require('gulp-cheerio'); +import cheerio = require('cheerio'); +import gulpCheerio = require('gulp-cheerio'); import gulp = require('gulp'); import Vinyl = require('vinyl'); @@ -9,7 +10,7 @@ import Vinyl = require('vinyl'); gulp.task('sync', function () { return gulp .src(['src/*.html']) - .pipe(cheerio(function ($: CheerioStatic, file: Vinyl) { + .pipe(gulpCheerio(function ($: cheerio.Root, file: Vinyl) { // Each file will be run through cheerio and each corresponding `$` will be passed here. // `file` is the gulp file object // Make all h1 tags uppercase @@ -23,7 +24,7 @@ gulp.task('sync', function () { gulp.task('async', function () { return gulp .src(['src/*.html']) - .pipe(cheerio(function ($: CheerioStatic, file: Vinyl, done: Function) { + .pipe(gulpCheerio(function ($: cheerio.Root, file: Vinyl, done: Function) { // The only difference here is the inclusion of a `done` parameter. // Call `done` when everything is finished. `done` accepts an error if applicable. done(); @@ -41,8 +42,8 @@ gulp.task('async', function () { gulp.task('sync', function () { return gulp .src(['src/*.html']) - .pipe(cheerio({ - run: function ($: CheerioStatic, file: Vinyl) { + .pipe(gulpCheerio({ + run: function ($: cheerio.Root, file: Vinyl) { // Each file will be run through cheerio and each corresponding `$` will be passed here. // `file` is the gulp file object // Make all h1 tags uppercase @@ -58,8 +59,8 @@ gulp.task('sync', function () { gulp.task('async', function () { return gulp .src(['src/*.html']) - .pipe(cheerio({ - run: function ($: CheerioStatic, file: Vinyl, done: Function) { + .pipe(gulpCheerio({ + run: function ($: cheerio.Root, file: Vinyl, done: Function) { // The only difference here is the inclusion of a `done` parameter. // Call `done` when everything is finished. `done` accepts an error if applicable. done(); @@ -84,5 +85,5 @@ cheerio({ }); cheerio({ - cheerio: require('../cheerio/cheerio.d.ts') as CheerioStatic // special version of `cheerio` + cheerio: require('../cheerio/cheerio.d.ts') }); diff --git a/types/gulp-cheerio/index.d.ts b/types/gulp-cheerio/index.d.ts index f7e07b8f1c..30aefd8c41 100644 --- a/types/gulp-cheerio/index.d.ts +++ b/types/gulp-cheerio/index.d.ts @@ -8,24 +8,25 @@ /// import Vinyl = require('vinyl'); +import cheerio = require('cheerio'); -declare namespace cheerio { - interface Cheerio { +declare namespace gulpCheerio { + interface GulpCheerio { (callback: Callback): NodeJS.ReadWriteStream; (option: Option): NodeJS.ReadWriteStream; } interface Callback { - ($: CheerioStatic, file: Vinyl, done?: Function): any; + ($: cheerio.Root, file: Vinyl, done?: Function): any; } interface Option { run?: Callback; - parserOptions?: CheerioOptionsInterface; - cheerio?: CheerioStatic; + parserOptions?: cheerio.CheerioParserOptions; + cheerio?: cheerio.Root; } } -declare var cheerio: cheerio.Cheerio; +declare var gulpCheerio: gulpCheerio.GulpCheerio; -export = cheerio; +export = gulpCheerio; diff --git a/types/json_ml/index.d.ts b/types/json_ml/index.d.ts index 7cab812880..77b780f8bb 100644 --- a/types/json_ml/index.d.ts +++ b/types/json_ml/index.d.ts @@ -10,6 +10,6 @@ export type Node = string | [string, ...any[]]; export function parse(xml: string, trim?: boolean): Node[]; export function stringify( object: Node[], - replacer?: ((node: Cheerio) => any) | null, + replacer?: ((node: cheerio.Cheerio) => any) | null, indent?: number ): string; diff --git a/types/open-graph/index.d.ts b/types/open-graph/index.d.ts index 14a3fe3ce6..9cd5d396ef 100644 --- a/types/open-graph/index.d.ts +++ b/types/open-graph/index.d.ts @@ -66,7 +66,7 @@ declare namespace og { } function parse(websiteContent: string, options?: Options): Data; - function getHTML(url: string | Cheerio, callback: RequestCallback): void; + function getHTML(url: string | cheerio.Cheerio, callback: RequestCallback): void; } declare function og(url: string, callback: og.DataCallback, options?: og.Options): void;