Skip to content

Invalid overload checking with equality comparer @1.6.0-beta #4619

@SergioMorchon

Description

@SergioMorchon

Invalid overload checking with equality comparer @1.6.0-beta

Hi!

I'm currently checking my code with the new 1.6.0-beta versión, and founded the following.

Code example

(<HTMLInputElement>element).value !== $(element).data("lastValue")

Issue

It works on 1.5.3, but with 1.6.0-beta: error TS2365: Operator '!==' cannot be applied to types 'string' and 'JQuery'..

Help context

$.fn.data has the following overloads (from definitely typed, I had the commit 286c198898978cb6045076c3e47f823a02217b41):

    /**
     * Store arbitrary data associated with the matched elements.
     *
     * @param key A string naming the piece of data to set.
     * @param value The new data value; it can be any Javascript type including Array or Object.
     */
    data(key: string, value: any): JQuery;
    /**
     * Store arbitrary data associated with the matched elements.
     *
     * @param obj An object of key-value pairs of data to update.
     */
    data(obj: { [key: string]: any; }): JQuery;
    /**
     * Return the value at the named data store for the first element in the jQuery collection, as set by data(name, value) or by an HTML5 data-* attribute.
     *
     * @param key Name of the data stored.
     */
    data(key: string): any;
    /**
     * Return the value at the named data store for the first element in the jQuery collection, as set by data(name, value) or by an HTML5 data-* attribute.
     */
    data(): any;

What I think...

It shoud choose data(key: string): any; but it seems to be working with some of the first or second ones.

OR

Simply checking the $(element) and ignoring the .data("lastValue").

OR I should check my code and didn't see what is going on.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Breaking ChangeWould introduce errors in existing codeExternalRelates to another program, environment, or user action which we cannot control.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions