Tips on reordering modules in typings.json

Utilizing typings for loading type definitions. In my project, I am utilizing bluebird as the promise implementation. The following lines are present in my typings.json:

"Promise": "github:DefinitelyTyped/DefinitelyTyped/bluebird/bluebird.d.ts#dd328830dddffbe19e9addd7cf8532cbd3600816",
"node": "github:DefinitelyTyped/DefinitelyTyped/node/node.d.ts#48c1e3c1d6baefa4f1a126f188c27c4fefd36bff",

The typings (version 1.0.3) generates the subsequent typings/index.d.ts:

/// <reference path="globals/node/index.d.ts" />
/// <reference path="globals/Promise/index.d.ts" />

During compilation, tsc throws errors wherever Promise is used, such as:

error TS2339: Property 'exists' does not exist on type 'Promise<IResourcePatched> | Promise<string>'

Despite the correctness of the code which previously functioned without issues. Upon switching the order of the lines in typings/index.d.ts to reference bluebird first, the program compiles and functions as expected...

Evidently, tsc adopts the definition of Promise it encounters first, with the one from node differing slightly from that of bluebird.

Enquiry lies in how to ensure that typings list the dependencies in index.d.ts in the required order or how to eliminate the Promise declaration from the node definition?

PS: Requesting someone with adequate reputation to include a typings tag on StackOverflow.

Update: Attempted altering the order of typings in typings.json only to observe node typings consistently positioned before Promise. They seem to be arranged alphabetically...

Update 2: It turns out there isn't a Promise definition within node but rather within the module "es6-shim", necessitated as a dependency by angular2. Different names, same issue: ordering.

Note: TypeScript-Compiler set up to generate es5 code.

Answer №1

The main issue here is not the order of things, but rather the fact that there are conflicting definitions for the Promise object. Specifically, the standard definition of Promise used by TypeScript when targeting es6/es2015 does not align with the one provided by es6-shim. You can either adjust TypeScript to target es5, or remove es6-shim altogether. The Angular2 quick-start guide seems to opt for the former solution.

Answer №2

My discovery appears to be applicable to typings version 1.0.3, but may not hold true for future releases. Exercise caution when utilizing this information.

The sequence of reference paths in typings/index.d.ts appears to be arranged according to the alphabetical order of object key names in the globalDependencies object found in typings.json. The keys' names seem to have no additional significance. Therefore, adjusting the object keys to align with your requirements seems to be a viable temporary solution.

In Typescript, it appears that the most recent definition of a global module is retained (at least as of version 1.8.10).

It seems that uppercase letters are consistently prioritized over lowercase letters (A-Za-z), indicating an alphabetical order likely based on the ASCII table. I have not delved into the source code to determine its exact functionality.

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

The formControl value is not being shown on the display

I am facing an issue with a form that has multiple fields created using formGroup and formControlName. The challenge arises when I launch the application and need to retrieve data from the back end to display it on the view. The specific problem I'm ...

Does a typescript definition file exist for Apple MapKit JS?

Before embarking on creating one, I'm curious if anyone has come across a typescript definition file (.d.ts) for Apple MapKit JS? ...

What is the best method for retrieving GET parameters in an Angular2 application?

Is there a way in Angular2 to retrieve GET parameters and store them locally similar to how sessions are handled in PHP? GET Params URL I need to obtain the access_token before navigating to the Dashboard component, which makes secure REST Webservice cal ...

What is the process of creating an asynchronous function that will resolve a promise when the readline on('close') event is triggered within it in Typescript?

Here's a code snippet I'm working with: private readFile() { var innerPackageMap = new Map<string, DescriptorModel>(); // Start reading file. let rl = readline.createInterface({ input: fs.createReadStream(MY_INPUT_FILE ...

Incorporating observables into an existing axios post request

Currently, I have an API using axios to send HTTP POST requests. These requests contain logs that are stored in a file. The entire log is sent at once when a user signs into the system. Now, I've been instructed to modify the code by incorporating Rx ...

Material-UI - TypeScript - Autocomplete utilizing getOptionLabel and renderOption for optimized selection functionality

I am attempting to showcase member and company using MUI Autocomplete. I have an array called suggestion that contains the options to display. [ { "__typename": "Member", "id": "ckwa91sfy0sd241b4l8rek ...

Angular Error: Unable to access the 'title' property of an undefined value

Error Message Showing on Console for post-create.component.html ERROR Message: TypeError: Cannot read property 'title' of undefined at PostCreateComponent_Template (template.html:13) I suspect the issue is related to this line - console.log(for ...

Tips on adding JSX to Storybook controls

While using Storybook, I want to navigate to my component and test the behavior of the Docs tab by changing control values for each property. I have implemented a component called Footer that can accept types such as string | JSX.Element | React.FunctionCo ...

Setting form values using Angular 9

I am currently facing a challenge that I could use some assistance with. My dilemma involves integrating a new payment system, and I seem to be encountering some obstacles. Here is a snippet of what I have: options: PaystackOptions= { amount: 5000, emai ...

Preventing the display of the login page for an authenticated user in Angular

My application has different modules for authentication, dashboard, and root routing. The auth module contains routes for sign-in, the dashboard module has routes for home with authentication guard, and the root module redirects to home or a PageNotFound c ...

Guide to Automatically Updating Angular Component When Service Data Changes

I am currently working on an Angular application that features a sidebar component displaying different menu items based on the user's data. The sidebar should only display an option for "Empresas" if the user has not created any company yet. Once a c ...

The Angular 2 and TypeScript error stating that the argument of type response is not assignable is causing issues

In my Angular application, I have a service that includes a value defined as: private client_comments = new BehaviorSubject([]); When attempting to update this value with the response from an HTTP request, I encountered the following error message: A ...

Unable to locate the specified nested module during the import process

Imagine a scenario where we have two packages, namely package1 and package2. When package2 attempts to import the module from package1, an error is thrown stating that the module is not found. The import statement in question looks like this: import { ... ...

What is the method to dynamically add an error to a FormGroup control using programming?

I am working with a dynamic FormGroup and I need to add an error to a form control programmatically. However, the current method I know of replaces any existing errors as shown below: this.userForm.controls.username.setErrors({ 'exists': &apos ...

Disable TS4023 error in TypeScript: Unable to name external module "xyz"

//custom-slice.js import { createCustomSlice } from '@my/data-toolkit'; /* ***********************For Managing all the divisions data****************************** */ export const divisionDataSlice = createCustomSlice({ name: 'divisionda ...

Files for the Express API and Sequelize are nowhere to be found

After collaborating with a Freelance developer for more than 10 months on a project, the developer suddenly disappeared without warning. Although he sent me a file containing the work he had completed, I realized that the backend API was missing. Project ...

Verifying the Redux saga test plan's functionality by testing a reducer with a specific state branch

I'm facing some challenges in properly testing my saga. The issue arises because when the saga is running, the reducer is mounted at state: {...initialState}, while my saga select effects expect the reducer to be mounted at state: {authentication: {.. ...

Can you explain the concept of BuildOptions in Sequelize?

Despite poring through the sequelize documentation and conducting extensive searches online, I have yet to come across a satisfactory answer: Why is BuildOptions necessary and what impact does it have on the created model? import { Sequelize, Model, Data ...

Interact with SOAP web service using an Angular application

I have experience consuming Restful services in my Angular applications, but recently a client provided me with a different type of web service at this URL: http://123.618.196.10/WCFTicket/Service1.svc?wsdl. Can I integrate this into an Angular app? I am ...

Why is the Last Page display on pagination showing as 3 instead of 2 per items?

When working on Angular 13, I encountered an issue with applying pagination numbers like 1, 2, 3, etc. The problem I faced was that the last page Number should be 2, but it is displaying as 3. Why is this happening? To investigate the issue, I tested my ...