Code Monkey home page Code Monkey logo

Comments (8)

danvk avatar danvk commented on August 27, 2024 7

I've published type declarations for this package on DefinitelyTyped. You can get them via:

npm install -D @types/react-lazy-load-image-component

The props for LazyLoadImage derive from HTMLImageElement, so everything should be there.

from react-lazy-load-image-component.

diegochavez avatar diegochavez commented on August 27, 2024 6

This is a WIP :D 👍 updated

declare module 'react-lazy-load-image-component' {
  import { Styles } from 'jss';
  import * as React from 'react';
  export const LazyLoadImage: React.FunctionComponent<{
    afterLoad?: () => any;
    beforeLoad?: () => any;
    delayMethod?: string;
    delayTime?: number;
    effect?: string;
    placeholderSrc?: string;
    threshold?: number;
    visibleByDefault?: boolean;
    wrapperClassName?: string;
    src?: string;
    width?: number;
    height?: number;
    className?: string | Styles;
  }>;
  enum DelayMethod {
    debounce = "debounce", 
    throttle = "throttle"
  };
  interface LazyComponentProps { 
    delayMethod: DelayMethod;
    delayTime: number
  };
  export const trackWindowScroll: (BaseComponent: React.ComponentType<P>) => BaseComponent<P & LazyComponentProps, S>;
  export const LazyLoadComponent: React.FunctionComponent<{
    afterLoad?: () => void,
    beforeLoad?: () => void,
    delayMethod?: DelayMethod,
    delayTime?: number,
    placeholder?: ReactNode,
    threshold?: number
    visibleByDefault?: boolean,
    children: ReactNode
  }>;
};

from react-lazy-load-image-component.

diegochavez avatar diegochavez commented on August 27, 2024 1

ejecting? no, you only include this file in your typescript project as react-lazy-load-image-component.d.ts @d-bo

from react-lazy-load-image-component.

diegochavez avatar diegochavez commented on August 27, 2024 1

@d-bo can be anywhere in the project but should work with a /typings directory on the root of your project Typescript pickup any .d.ts file and try to match.

@Aljullu I'll make a PR to include the d.ts in this project. 👍

from react-lazy-load-image-component.

d-bo avatar d-bo commented on August 27, 2024

Also seems there is no way to include it through tsconfig.json without ejecting create-react-app.
Nice to get it as a npm install @types/react-lazy-load-image-component

TypeScript error: Could not find a declaration file for module 
'react-lazy-load-image-component'. '/prj/node_modules/
react-lazy-load-image-component/build/index.js' implicitly has an 'any' type.
  Try `npm install @types/react-lazy-load-image-component` if it exists or add 
a new declaration (.d.ts) file containing 
`declare module 'react-lazy-load-image-component';`  TS7016

from react-lazy-load-image-component.

d-bo avatar d-bo commented on August 27, 2024

the path to include ?
got it - src/ folder

from react-lazy-load-image-component.

zerosym avatar zerosym commented on August 27, 2024

Thanks for the typings. I noticed some valid image attributes such as "alt" are missing though and they should all be valid as per the bottom row of the props table in the docs.

https://github.com/Aljullu/react-lazy-load-image-component/blob/master/README.md#props

from react-lazy-load-image-component.

Aljullu avatar Aljullu commented on August 27, 2024

Closing this issue now that @danvk created the declarations in DefinitelyTyped (thank you!). I added a link in the README file so they are easy to find.

from react-lazy-load-image-component.

Related Issues (20)

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.