Is it acceptable to include a @types library as a regular dependency in the package.json file of a Typescript library?

Should the library also be compatible with Typescript projects?

I am developing a Typescript library that utilizes node-fetch and @types/node-fetch, which will be shared through an internal NPM registry within the company.

If I only include @types/node-fetch as a dev-dependency, users of the library who are also using Typescript in their projects will have to manually install the missing types since dev-dependencies are not automatically included.

The solution I currently have is to declare @types/node-fetch as a regular dependency, but it seems unusual (as types are typically not needed for runtime operations).

Is this the correct approach, or is there a better way to handle this situation?

Answer №1

When your public API relies on declarations from @types/node-fetch, it is appropriate to classify it as a regular dependency. Check out this discussion for more information.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Remove an element from an array within objects

Need help with removing specific items from an array within objects? If you want to delete all hobbies related to dancing, you may consider using the splice method const people = [{ id: 1, documents: [{ ...

What is the location of the storage for npm modules?

Currently, I am in the process of learning node.js and I have a couple of inquiries: Can you please explain where npm modules are stored? 2. Just to clarify, is node.js considered a database technology? 3. Lastly, do you need an internet connection in ...

Having trouble utilizing HTML Canvas in the newest release of Angular and TypeScript

After extensive searching on the internet, I have not been able to find any working examples of using HTML canvas in Angular. It seems that changes in syntax in Typescript and Angular's newer versions have rendered all existing solutions obsolete. I ...

Implementing a GIF loader in your webpack configuration for a Typescript/React/Next.js application

Upon inserting a .gif file in my Typescript React app, an error message has surfaced. ./src/gif/moving.gif 1:6 Module parse failed: Unexpected token (1:6) You may need an appropriate loader to handle this file type, currently no loaders are configured to p ...

Applying REGEX on input text in React Native

I'm having trouble getting my regex function to work correctly, so I believe there might be an error in my code. Any assistance would be greatly appreciated. Here is the regex function I am using: let validatePlate = (plate) => { var re = /(^[A ...

Foundation-sites module missing - new project requires installation of Node modules

I recently encountered an issue that has been discussed multiple times here, but unfortunately, I couldn't find a suitable solution. After formatting my disk and installing macOS Monterey, the following software versions were installed: node.js v16. ...

An issue was encountered during the installation process of less

When attempting to install less using the following command: npm install less . An error is encountered: npm ERR! Error: EROFS, symlink '../less/bin/lessc' npm ERR! If you require assistance, please report this *entire* log, npm ERR! including ...

Exploring subclasses in TypeScript

When working with TypeScript and defining an interface like the one below: export interface IMyInterface { category: "Primary" | "Secondary" | "Tertiary", } Can we access the specific "sub types" of the category, such as ...

Is it possible to create a map of functions that preserves parameter types? How can variadic tuple types in TypeScript v4 potentially enhance this

Initially, I faced a challenge when trying to implement a function similar to mapDispatchToProps in Redux. I struggled with handling an array of functions (action creators) as arguments, but managed to come up with a workaround that works, although it feel ...

Can you determine the size of an unknown array in TypeScript?

Currently diving into TypeScript and tackling some TDD challenges. Within my model file, I'm working with a property named 'innovatorQuotes' that should be an array containing strings with a fixed length of 3. I'm struggling to nail dow ...

Tips for effectively timing out a Node.js Oracle DB connection that fails to respond

I am currently utilizing Npm Oracle in my Node.js application. I am facing an issue where my compiler hangs while trying to connect to the Oracle database, causing a thread to get stuck. I need to implement a timeout mechanism as my client cannot wait for ...

What is the correct way to input the 'name' HTML attribute in an Ant Design select element?

I am facing an issue with the 'name' attribute in my Ant Design Select component. When trying to set the 'name' attribute, I encountered an error message that is causing issues. https://i.stack.imgur.com/Lzb4t.png Ant Design Select Co ...

What is the reason for yarn removing the "private" setting with value of "true" from my package.json file?

After executing the command yarn within a directory containing a package.json file that includes the field "private": "true",, I noticed that this line gets silently removed. This discrepancy in behavior can be observed between yarn 3 ...

Firebase data causing issues with ion-gesture recognition?

Hey there! I'm currently facing an issue with my ionic app. I added the ion-gesture to my project, but due to the ngFor loop pulling data from Firebase, the cards are unable to move. Here's a snippet of my code: <ion-card *ngFor="let po ...

Unable to update Discord due to opus installation issue

I recently encountered an issue with my Discord bot that was working perfectly fine yesterday. After attempting to host it on Heroku, I ran into some errors. To find a solution, I followed advice from an online post and executed the command npm cache cle ...

Exploring Nested <Routes> with ReactJs

My decision on whether to display the Foo page or the Bar page is based on the route. However, the Foo page itself contains two sub-routes for components to render depending on the URL path - such as FooOne or FooTwo. This results in having two layers of r ...

What is the best way to create a personalized filter function for dates in JavaScript?

I am working with a DataTable that includes a column called Timestamp: <p-dataTable sortMode="multiple" scrollable="scrollable" scrollHeight="150" [value]="currentChartData" #dt> <p-column field="timestamp" header="Timestamp" [sortable]=" ...

Position components in Angular 2 based on an array's values

Hello all, I am a beginner in terms of Angular 2 and currently facing some obstacles. My goal is to create a board for a board game called Reversi, which has a similar layout to chess but with mono-color pieces. In order to store the necessary information, ...

Angular2 Service Failing to Return Expected Value

It's frustrating that my services are not functioning properly. Despite spending the last two days scouring Stack Overflow for solutions, I haven't been able to find a solution that matches my specific issue. Here is a snippet of my Service.ts c ...

Update the output directory for the `bin` command in NPM to customize the location of node modules

As of now, if you are utilizing a package.json file to organize your project's dependencies (regardless of whether it's a ruby, php, python, or js application), by default everything gets installed under ./node_modules. In cases where some depen ...