typescript unable to use module as variable in import statement

Having trouble importing a variable from another file in TypeScript and assigning an alias name. I keep getting an error saying the alias name is not defined.

For example:

import { headerItems as TestHeader } from './headers';

Typescript version: 3.2.4
Ng cli: 7.3.7
webpack: 4.19.0

Thank you in advance!

Answer №1

To learn more, check out the following resources: https://github.com/angular/angular-cli/issues/13212 and https://github.com/IgorMinar/angular/commit/b7313ac2c619e96617258606d090f42ad73c44c0

The reason why import as leads to undefined aliases is not clear.

It appears that plain tsc behaves correctly and generates the right code, so it could be an issue with how @angular/cli or webpack are interacting causing this failure.

This issue should be looked into separately from the tsc update in angular/angular. Refer to angular/angular-cli#13212

-- Igor Minar

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

Is there a way to schedule a function to run every 6 hours in node.js based on actual time instead of the device's time?

var currentTime = new Date().getHours(); if(currentTime == 6){ //function Do stuff } if(currentTime == 12){ //function Do stuff } if(currentTime == 18){ //function Do stuff } if(currentTime == 24){ //function ...

Tips on implementing href with "javascript:window.open..." in AngularJS

I've been trying to utilize an anchor tag in my HTML code to open a new modal browser window with a URL retrieved through an Angular value like this: <a href="javascript:OpenPopUpPage('{{listing.Linktest}}');">Test Link</a> Alt ...

Parsing JSON in an Express application

I have developed a small application to test a larger one that I am currently working on. The small application reads data from a CSV file and then attempts to send this data to my API endpoint using POST requests. This is necessary as I need to send a lar ...

programming / mathematics - incorrect circular item rotation

I need help arranging a sequence of planes in a circular formation, all facing toward the center. However, I seem to be experiencing issues with the rotation after crossing the 180-degree mark. While my objects are correctly positioned around the circle, t ...

Inheriting from the AudioWorkletProcessor class and incorporating a pre-existing audioNode within the class

My goal is to extend the AudioWorkletProcessor class in order to create a new AudioNode. However, I want to include an existing audioNode, such as a GainNode, within the class - specifically inside the process function. The challenge lies in accessing the ...

A method to retrieve the content of an input field and assign it to an onclick event

I encountered an issue with an ajax function that requires the lat and lng variables. Here is a simple HTML code snippet: <fieldset> <legend>Geocoding Services</legend> Latitude:<br><input type="text" id="lat" value="42.3600077 ...

Mongoose is struggling to locate the expected result

I currently have three different schemas set up. User.js: const mongoose = require("mongoose"); const bcrypt = require("bcryptjs"); const userSchema = new mongoose.Schema({ name: { type: String, required: true, }, email: { type: String, ...

Utilize AJAX and jQuery to seamlessly submit a form

I am attempting to use jQuery and AJAX to submit a form in order to add a row to a table called cadreSante (which is in French). The code I am using for this operation is provided below. Can someone please identify any errors in the code and suggest ways t ...

Generate a new array using a single value extracted from an existing array

I'm new to working with arrays. Before this, I used to manually code everything in HTML. My question is, can you create an array based on the values of another array? var pmmain =["aaa", "bbb", "ccc", "ddd", "eee", "fff", "ggg", "hhh", "iii", "jjj", ...

Generate a fresh array of elements and combine the objects that share the same value

Looking to create a new array of objects based on the original specs array of objects. I have searched for similar questions but nothing has solved my issue. const specs = [ { label: 'Brand', value: 'Nike' }, { label: 'Age ra ...

Tips for integrating a back button functionality with AJAX requests

My single page web application allows users to enter genre, date range, and other inputs before making an ajax post request to a Java Spring MVC server. Despite everything working well, I now want to implement a back functionality. If a user wants to go b ...

Ways to update a value in a table by comparing two JSON objects

I am currently working with two JSON files containing data as shown below: JSON 1: let classes = [{ "Class": "A", "as_of": "12/31/2020", "student": [{ "raji": { "eng": ...

Scroll upwards within a nested div

Is there a way to smoothly animate the content of the inner div upward without requiring any button clicks? Also, is there a method to trigger an event once the animation has completed? ...

most effective method to link table header to corresponding table row within this specific data organization

In my current project, I have a table component that relies on two data structures to create an HTML table: one for the table schema (paymentTableMetadata) and one for the table data (paymentTableData). To simplify the process, I have hardcoded these data ...

Creating a OneToMany relationship in NestJS entity model

In my current project with NestJS, I am working on defining entity fields. While I have successfully defined a ManyToOne relation, I am facing difficulties in setting up the syntax for a OneToMany relation to match the structure of my other relationships. ...

Unraveling the Mystery: How Angular Handles Propagation of Color CSS Property Settings to Nested Components

Angular's style scope and inheritance are detailed in the guide: The styles defined in @Component metadata only affect the template of that specific component. They do not get passed down to any nested components or projected content. To propagate ...

Analyzing the differences in environment management between express and dotenv

Lately, I've noticed an abundance of tutorials and articles discussing NodeJS and the dotenv library. One common practice that keeps coming up is defining an ENV_MODE=development variable within the config.env file. However, it got me thinking - does ...

How to make an entire video clickable on Android for seamless playback?

I have implemented an HTML5 video in my mobile web application. Currently, users need to click the small play icon at the bottom left of the video to start playing it. Is there a way to make the entire video clickable so it plays when clicked anywhere on t ...

Managing the jQuery.noConflict function

Upon review, I noticed that the scripts I inherited start like this: var $j = jQuery.noConflict(); The purpose behind this code is not clear to me. While I understand the intent is to avoid conflicts, I am uncertain about the specific conflict it aims to ...

Steps for utilizing a function from the parent component to initialize TinyMCE

I have implemented an uploading function in my parent component. As I set up tinymce, I connected the [init] property of my component to the loadConfig() function. <editor [(ngModel)]="data" [init]="loadConfig()"></editor> The loadConfig func ...