Manifest for npm module

After releasing my first npm package, I realized that I needed to implement a declaration file ("*.d.ts") when integrating it into one of my projects. Despite multiple attempts, I have not been able to successfully integrate it and have spent days trying to resolve this issue. Any assistance would be greatly appreciated.

package.json

{
    "main": "./dist/App",
    "name": "react-native-range-slider-expo",
    "description": "range slider",
    "license": "MIT",
    "homepage": "https://github.com/D10S60948/react-native-range-slider-expo#readme",
    "version": "1.0.8",
    "types": "./dist/App",
    "scripts": {
        "start": "expo start",
        "android": "expo start --android",
        "ios": "expo start --ios",
        "web": "expo start --web",
        "eject": "expo eject",
        "build": "tsc"
    },
    "dependencies": {
        "expo": "~38.0.8",
        "expo-status-bar": "^1.0.2",
        "react": "~16.11.0",
        "react-dom": "~16.11.0",
        "react-native": "https://github.com/expo/react-native/archive/sdk-38.0.2.tar.gz",
        "react-native-gesture-handler": "^1.6.1",
        "react-native-svg": "^12.1.0",
        "react-native-web": "~0.11.7"
    },
    "devDependencies": {
        "@babel/core": "^7.8.6",
        "@types/react": "~16.9.41",
        "@types/react-native": "~0.62.13",
        "typescript": "~3.9.5"
    },
    "keywords": [
        "range",
        "slider",
        "expo"
    ]
}

tsconfig.json

{
  "compilerOptions": {
    "allowSyntheticDefaultImports": true,
    "jsx": "react-native",
    "lib": ["dom", "esnext"],
    "moduleResolution": "node",
    "noEmit": true,
    "skipLibCheck": true,
    "resolveJsonModule": true,
    "strict": true,
    "declaration": true,
    "outDir": "./dist"
  }
}

Answer №1

After some trial and error, I finally succeeded in generating the ".d.ts" file.

All it took was removing this line from "tsconfig.json"

"noEmit": true

and then executing this command

tsc --emitDeclarationOnly

Before I knew it, the ".d.ts" file appeared right alongside the "tsx" file. Success!

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

Book of Tales displaying Emotion Styling upon initial load only

I'm currently working with the styled api provided by emotion in order to create a custom styled button. const StyledButton = styled(Button)` background-color: ${theme.palette.grey['800']}; width: 50; height: 50; &:hover { ba ...

How to effectively handle null values using try..catch statement in typescript

As a beginner, I am learning how to write a try/catch statement in TypeScript. My issue is that there is a function within the "try" block that returns null. How can I implement code in the "catch" block specifically for when the function in "try" returns ...

Displaying a collection of objects in HTML by iterating through an array

As someone new to coding, I am eager to tackle the following challenge: I have designed 3 distinct classes. The primary class is the Place class, followed by a restaurant class and an events class. Both the restaurant class and events class inherit core p ...

Ways to address the issue of Node.js versions with odd numbers not qualifying for LTS status and being unsuitable for production node:16120 due to UnhandledPromiseRejectionWarning

After attempting to initiate a new Angular application with ng new app, I encountered the following error: Node.js version v11.0.0 detected. Odd numbered Node.js versions will not enter LTS status and should not be used for production. For more information ...

When trying to pass MaterialUI theme props to styled components, an error of 'Undefined' is encountered

I'm encountering difficulty accessing my Material-UI theme props within a styled component, resulting in errors like... TypeError: Cannot read property 'primary' of undefined or similar issues in the browser. Here is the custom theme I&apo ...

Designing the Firebase Structure of an Angular Application

What is the best way to structure Firestore and Angular for efficient querying? When using a JSON Cloud Firestore database, one of the challenges is inserting people and relating them to users. To optimize query speed and efficiency, it is important to c ...

Issue: gyp encountered an error during the build process on the Macbook M3 Pro device

Whenever I run npm i on my project in NestJS, using Node 18 on a MacBook M3 Pro with the Sonoma operating system, I consistently encounter the following error: npm http fetch GET 200 http://nexuscloud.banco.bestado.cl/repository/npm-group/pino/-/pino-7.11. ...

Challenges encountered when retrieving parameters from union types in TypeScript

Why can't I access attributes in union types like this? export interface ICondition { field: string operator: string value: string } export interface IConditionGroup { conditions: ICondition[] group_operator: string } function foo(item: I ...

Add a calendar icon to the DateRangePicker in React Mui

I am trying to set up a DateRangePicker using Material UI with a calendar icon. Here is an example of how I want it to look: https://i.stack.imgur.com/LnYnY.png After following the API documentation and using this code: components={{ OpenPickerIcon: Cal ...

Differences between String Comparison in Node.js with "UTF-16"

Just starting out with Node.js and hoping to find an npm package or module that can compare two strings in UTF-16 format. In my C# code, I currently use the following function: public int Compare(string x, string y) { var myComparer = CompareInfo.Get ...

tips for extracting data from C# generic collection lists using TypeScript

This is the code I wrote in my .cshtml file: @ { var myList = (List<MyViewModel>)ViewBag.MyCollection; } <input id="myListHidden" type="hidden" data-my-list="@myList" /> Next, here is the TypeScript code that retrieves the value from ab ...

Transferring functionality from a child component to a parent component

I have a Base Component called ListComponent and a ParentComponent named Businesses2ListComponent. The concept is to have multiple types of Lists with tables that all stem from the ListComponent. This requires passing the correct service accordingly. In t ...

Leverage the nativeElement property within two separate components

Encountering an error in the autocomplete feature for Angular Maps (AGM), which reads: ERROR Error: Uncaught (in promise): TypeError: Cannot read property 'nativeElement' of undefined TypeError: Cannot read property 'nativeElement' of ...

There is no link between the two containers

I am facing an issue where two containers need to connect with each other. However, when attempting to fetch data from one container, I encounter an ENOTFOUND error. Surprisingly, this code functions properly on my local system but fails within the contain ...

The module 'webpack/lib/web/FetchCompileWasmTemplatePlugin' could not be located

I encountered an issue with my Vue application that is currently running live on Node version 8. Upon cloning the application, I deleted the `package.lock` file and `node_module` folder. Following this, I ran `npm i` but faced a problem as I have node vers ...

Issues arise when attempting to export a React application as an npm module that includes an SVG image

In my React application, which was created using the create-react-app script and then published as an npm module, everything is working well. I am able to use the exported components without any issues. However, I am facing a problem with displaying pictur ...

Is there a way to clear the selected date in a date picker while using MatDateRangeSelectionStrategy?

Recently, I was experimenting with the date picker feature of Angular Material and stumbled upon this particular example After implementing this example with my own logic, everything seemed to be working perfectly fine except for one issue. The dates were ...

What is the best way to utilize the 'files' and 'directories' properties within the package.json file?

If a package.json contains a files property and/or a directories property: "files": [ "./src/assets/fonts/" ], "directories": { "assets:": "./src/assets" } How can these properties be utilized? The official documentation does not provide ...

React useEffect Hook fails to trigger after redux State update

I recently created a React.FunctionComponent to serve as a wrapper for children and perform certain actions after some redux dispatch operations in Typescript, but I'm facing issues. Here is the code snippet of the wrapper: import React, {useState, us ...

The RouteParams encounter a problem because it is unable to resolve all parameters

I'm encountering an issue with the RC3 router. The error message I am receiving is: Can't resolve all parameters for RouteParams: (?). Below is my code: //route.ts import {provideRouter, RouterConfig} from '@angular/router'; import {H ...