kreudev / react-infinite-logo-slider

A slider of logos or react components that scroll horizontally infinitely
18 stars 1 forks source link

Lack of TypeScript type definitions #1

Open kantar0 opened 1 year ago

kantar0 commented 1 year ago

The "react-infinite-logo-slider" package does not include TypeScript type definitions, which makes it difficult to use in TypeScript projects without encountering type errors. As a result, developers who want to use this package in a TypeScript project must either write their own type definitions or rely on the package without type checking, which can lead to bugs and errors. image

kreudev commented 2 months ago

I'll keep it in mind for a future update, thank you!

kreudev commented 1 month ago

Have you tried this?:

1. Create a Type Definitions File

First, create a type definitions file for the package. This file should be placed in the @types directory of your project, or any other directory that TypeScript can recognize. Usually, it's placed in a folder named @types in the root of the project.

For example, you can create the file @types/react-infinite-logo-slider/index.d.ts

@types/ └── react-infinite-logo-slider/ └── index.d.ts

2. Write the Type Definitions

Inside the index.d.ts file, add the type definitions for the Slider component. Here's a basic example:

` // @types/react-infinite-logo-slider/index.d.ts

declare module 'react-infinite-logo-slider' { import * as React from 'react';

interface SliderProps { // Define the props that the component accepts width?: string; duration: number; }

const Slider: React.FC;

export default Slider; } `

3. Configure tsconfig.json

Ensure that your tsconfig.json includes the @types directory so that TypeScript can find your custom definitions. Your configuration should include something like this:

{ "compilerOptions": { "typeRoots": ["./node_modules/@types", "./@types"], // Other configuration options } }

4. Import and Use the Component in Your Project

Now you can import and use the Slider component in your TypeScript files (.tsx). TypeScript will use the type definitions you created.

For example:

` // App.tsx import React from 'react'; import Slider from 'react-infinite-logo-slider';

const App: React.FC = () => { return (

....

); }

export default App; `

pzehle commented 1 week ago

Why not directly add it to the package instead of providing a half-working code? If you are not longer working on this, it's fine, it is not your obligation, however I would recommend you close/archive this, or update it to a latest version for others. Just my 2 cents.