Encountering the message "Error: Unused file" while executing a test for a recently added type definition

In contributing to the DefinitelyTyped project, I recently introduced a new type definition for the hyphen library. The code can be found here.

Unfortunately, running the test script npm run test hyphen resulted in the following error message:

C:\MyProjects\code\ts-d.ts\DefinitelyTyped>npm run test hyphen

...
Error: Unused file C:\MyProjects\code\ts-d.ts\DefinitelyTyped/types/hyphen/index.d.ts (used files: ["patterns/de-1996.d.ts","patterns/hu.d.ts","en-gb.d.ts","hyphen-tests.ts","common.ts","tsconfig.json","tslint.json"])
...

The error claims that index.d.ts is not being used, even though it is referenced in my hyphen-tests.ts file.

I could simply add index.d.ts to OTHER_FILES.txt to bypass the issue, but this would not address the root problem. Any assistance with resolving this would be greatly appreciated. Thank you.

Answer №1

After some investigation, I discovered that the crucial missing piece in my tsconfig.json was the absence of the index.d.ts entry under the files option:

{
    "compilerOptions": {
        "module": "commonjs",
        "lib": [
            "es6"
        ],
        "strict": true,
        "baseUrl": "../",
        "typeRoots": [
            "../"
        ],
        "noEmit": true,
        "forceConsistentCasingInFileNames": true,
        "types": []
    },
    "files": [
        "index.d.ts",
        "hyphen-tests.ts"
    ]
}

Interestingly, even though all other .d.ts files were being recognized through their imports within hyphen-tests.ts, this particular file needed to be explicitly listed in the files array for proper compilation.

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

There are no code completion suggestions available for MUI v5 types when using WebStorm

Why am I not receiving code completion suggestions for MUI components in WebStorm? TypeScript v4.4.4 WebStorm 2021.2.3 MUI v5.0.4 function App() { const { path, url } = useRouteMatch(); return ( <div className="App"> &l ...

Determination of function return type based on the presence of an optional argument

I am attempting to design a function that will have a return type based on whether an optional parameter (factory) is provided or not If the factory parameter is passed, then the return type should match the return type of the factory Otherwise, it shoul ...

Using JavaScript to retrieve comma-separated values depending on a specific condition

Hey there, I am encountering a problem with filtering out values from an array of objects. Essentially, I have an array of objects const arr = [ { "id": null, "name": null, "role": "Authorized ...

Consolidate all REST service requests and match the server's response to my specific object model

My goal was to develop a versatile REST service that could be utilized across all my services. For instance, for handling POST requests, the following code snippet demonstrates how I implemented it: post<T>(relativeUrl: string, body?: any, params?: ...

How can I achieve the same functionality as C# LINQ's GroupBy in Typescript?

Currently, I am working with Angular using Typescript. My situation involves having an array of objects with multiple properties which have been grouped in the server-side code and a duplicate property has been set. The challenge arises when the user updat ...

The parameter 'NextApiRequest' cannot be assigned to the parameter 'Request'

I encountered a typescript issue that states: Argument of type 'NextApiRequest' is not assignable to parameter of type 'Request'. Type 'NextApiRequest' is not assignable to type '{ url: string; }'. Types of pro ...

How can I restrict the return type of a generic method in TypeScript based on the argument type?

How can we constrain the return type of getStreamFor$(item: Item) based on the parameter type Item? The desired outcome is: When calling getStream$(Item.Car), the type of stream$ should be Observable<CarModel> When calling getStream$(Item.Animal), ...

Issue with detecting errors in Angular unit test when using jest throwError method

Imagine I have a component that contains the following method: someMethod() { this.someService .doServicesMethod(this.id) .pipe( finalize(() => (this.loading = false)), catchError((e) => { this.showErrorMessage = true; ...

Extracting the content within Angular component tags

I'm looking for a way to extract the content from within my component call. Is there a method to achieve this? <my-component>get what is here inside in my-component</my-component> <my-select [list]="LMObjects" [multiple]=&qu ...

Is it possible for Typescript to resolve a json file?

Is it possible to import a JSON file without specifying the extension in typescript? For instance, if I have a file named file.json, and this is my TypeScript code: import jsonData from './file'. However, I am encountering an error: [ts] Cannot ...

The Angular performance may be impacted by the constant recalculation of ngStyle when clicking on various input fields

I am facing a frustrating performance issue. Within my component, I have implemented ngStyle and I would rather not rewrite it. However, every time I interact with random input fields on the same page (even from another component), the ngStyle recalculate ...

What is the best way to deactivate an <a> tag in React after it has been clicked?

Is there a way to deactivate the anchor tag below in React once it has been clicked? The onClick function is not functioning on the anchor tag. <td align="left"> <input type="file" accept=".csv,.xlsx,.xls" ...

Accessing the constants and state of child components within a parent component in React

I've created a MUI TAB component that looks like this <Box sx={{ width: "100%" }}> <Box sx={{ borderBottom: 1, borderColor: "divider" }}> <Tabs value={value} onChange={handleChange} aria-label ...

Deactivate user input depending on a certain requirement

Greetings everyone, I am currently working with the following code snippet: <table class="details-table" *ngIf="peop && peopMetadata"> <tr *ngFor="let attribute of peopMetadata.Attributes"> <td class="details-property"&g ...

Angular2 components are not cooperating with the Bootstrap styling

Problem with applying Bootstrap styles to Angular2 components. The Bootstrap fluid container is not functioning properly in the UI when used within an Angular2 component. However, it works fine if 'container-fluid' is placed inside the component ...

Ensuring the presence of TypeScript variables

Take a look at this code snippet: let str: string | null; function print(msg: string) { console.log(msg); } print(str); When running this code, the typescript compiler correctly identifies the error, stating that Argument of type 'string | nu ...

Stuck on loading screen with Angular 2 Testing App

Currently working on creating a test app for Angular 2, but encountering an issue where my application is continuously stuck on the "Loading..." screen. Below are the various files involved: app.component.ts: import {Component} from '@angular/core& ...

Starting PM2 with multiple instances can be achieved by following these steps

While running my nodejs code with PM2, I encountered a requirement for multiple instances of nodejs executing the same code. To address this need, I created a script named "myscript.sh": cd ~/myproject PM2_HOME='.pm2_1' /usr/local/bin/node /u ...

What is the best way to extract values from a specific table column and store them in an array using Angular?

I have a section of code containing a table in my component: expect-next-month.component.html <table id="users"> <tr> <th>Number of month</th> <th>Total checking e ...

Challenges with date formatting arise for Spanish speakers when the date returns as NaN or an Invalid

I have been working on an Angular app Objective: My aim is to allow users to input dates in Spanish format (DD/MM/YYYY) and display them as such, while converting them back to English format when saving the data to the Database. Issue: One problem I enco ...