Coder Social home page Coder Social logo

Typescript - react component requires placeholder, onPointerEnterCapture & onPointerLeaveCapture properties about theme-toggles HOT 8 CLOSED

arkatsy avatar arkatsy commented on September 3, 2024
Typescript - react component requires placeholder, onPointerEnterCapture & onPointerLeaveCapture properties

from theme-toggles.

Comments (8)

oddgr8 avatar oddgr8 commented on September 3, 2024 1

Narrowed it further, the issue is related to types/react. It occurs on 18.2.43 but not on version 18.2.42

from theme-toggles.

oddgr8 avatar oddgr8 commented on September 3, 2024 1

Awesome!
My temporary workaround was to just give empty placeholder,onPointerEnterCapture and onPointerLeaveCapture values as attributes. This works btw.

I'll try more to get a better solution and raise a PR if I can.

Thanks!

from theme-toggles.

AlfieJones avatar AlfieJones commented on September 3, 2024 1

It'd be awesome to get a PR for this. If not, I can work on it in a few weeks.

It'll have to be made to the v4 branch https://github.com/AlfieJones/theme-toggles/tree/v4

I'm planning on getting v5 finished up this summer which is what the main branch is currently showing

from theme-toggles.

arkatsy avatar arkatsy commented on September 3, 2024 1

Thanks for the info. I'll give it a chance when I find some time.

from theme-toggles.

oddgr8 avatar oddgr8 commented on September 3, 2024

This issue only occurs for Nextjs 13.5 and not for 13.4. Can someone please look into this?

from theme-toggles.

arkatsy avatar arkatsy commented on September 3, 2024

I'll try to investigate the issue. I doubt this has to do anything with Nextjs, same happens with Vite. If I find a solution I'll open a PR or just post my findings here.

from theme-toggles.

arkatsy avatar arkatsy commented on September 3, 2024

Thanks @oddgr8, this actually helped a lot to find the issue faster.

Based the version diff, it seems that the 18.2.43 version removes the placeholder from the HTMLAttributes
(see: npm diff --diff=@types/[email protected] --diff=@types/[email protected])

I think it comes from this pr: https://github.com/DefinitelyTyped/DefinitelyTyped/pull/67170/commits
I found also this issue that explains the reason I think: DefinitelyTyped/DefinitelyTyped#26736
But this is the cause only for the placeholder.

For the onPointerEnterCapture and onPointerLeaveCapture there is a change in the version 18.2.66 that removes these both from the DOMAttributes.
(see npm diff --diff=@types/[email protected] --diff=@types/[email protected] or DefinitelyTyped/DefinitelyTyped@73b5985)

I also found this discussion about it: DefinitelyTyped/DefinitelyTyped#69006

from theme-toggles.

arkatsy avatar arkatsy commented on September 3, 2024

Sure! You can also add the properties back to the declaration if you want:

declare module "react" {
  interface HTMLAttributes<T> extends AriaAttributes, DOMAttributes<T> {
    placeholder?: string | undefined;
  }

  interface DOMAttributes<T> {
    onPointerEnterCapture?: React.PointerEventHandler<T> | undefined;
    onPointerLeaveCapture?: React.PointerEventHandler<T> | undefined;
  }
}

from theme-toggles.

Related Issues (11)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.