System.js alias module cannot be located by TypeScript

Working on an angular2 project, I recently created aliases for modules using System.js. For example:

 map: {
      '%cool_modules%' : prodFolderName + '/modules',
    }

However, when attempting to import {MyModule} from '%cool_modules%', I encountered an error stating: typescript: can't find module %cool_modules%

The same issue arose with @angular/core, rx/Obserable, and more.

Is there a way to resolve this problem? Thank you

Answer №1

To ensure your alias is recognized, make sure to update your tsconfig.json file with the necessary configurations:

{
    "compilerOptions": {
        ...
        "paths": {
            "@angular/core": [
                "jspm_packages/npm/@angular/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="e88b879a8da8dac6d8c6d9">[email protected]</a>"
            ],
            "rxjs/*": [
                "jspm_packages/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="83f1fbe9f0c3b6adb3adb3aee1e6f7e2adb2b1">[email protected]</a>/*"
            ],
            "systemjs": [
                "jspm_packages/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="c1b2b8b2b5a4acabb281f1eff0f8eff2f9">[email protected]</a>"
            ],
            "zone.js": [
                "jspm_packages/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="4f3520212a61253c0f7f6179617e7d">[email protected]</a>"
            ],
            "%cool_modules%": [
                "coolModulePath"
            ]
        }
    }
}

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

Can a React function component be typed with TypeScript without the need for arrow functions?

Here is my current React component typed in a specific way: import React, { FunctionComponent } from "react"; const HelloWorld : FunctionComponent = () => { return ( <div> Hello </div> ); } export default HelloWorld; I ...

Definitions for Typescript types that describe a custom hook responsible for fetching a specific part of the Redux state

I've created a custom hook called useReduxState to fetch a specific piece of state from Redux like so: const STATE_A = useReduxState("STATE_A"); Now, I'm running into issues when trying to integrate Typescript. These are the types I a ...

Stop unnecessary updating of state in a global context within a Functional Component to avoid re-rendering

I am currently working with a Context that is being provided to my entire application. Within this context, there is a state of arrays that store keys for filtering the data displayed on the app. I have implemented this dropdown selector, which is a tree s ...

Is there a way to customize a chart in Ionic 2 to resemble the image provided?

Hello there, I am currently using import {Chart} from 'chart.js'; to generate my chart; however, I am facing some difficulties. My goal is to create a chart similar to the one displayed below. Warm regards //Generating the doughnut this.dou ...

Is there a way to switch the display of an icon using Font Awesome and Angular?

I'm attempting to switch between the sort-amount-asc and sort-amount-desc classes while also including another icon in the initial state, using Angular. I attempted to use a ternary operator within ngClass but am struggling to make it work with the fo ...

Passing extra arguments to a callback function in Typescript

I'm trying to pass a parameter to a callback function. Below is the snippet of my function: let func = function(el, index){ if(el.id === myId) return index; } arr = [obj1, obj2, obj4, ...]; arr.filter(func); Is there a way to suc ...

Tips for automatically scrolling mat-select option to the top when mat-select is closed

Is there a way to automatically scroll the mat-select options to the top after closing it? I am faced with a situation where I have numerous options in my mat-select dropdown. If I select an option from the bottom and then close the mat-select, is there a ...

Accessing selectionStart and selectionEnd values in Angular using ControlValueAccessor

In my Angular project, I have a custom directive that is supposed to access the selectionStart and selectionEnd values of its host element's input. Here is how I implemented this in my directive: @Directive({ selector: '[inputBehavior]', } ...

What is the best way to transfer a value from *ngFor directive in Angular to the data-target attribute?

I was trying to create dynamic collapsible lists using Angular and the Bootstrap library. Since I didn't know how many lists there would be, I decided to use an *ngFor loop. However, I encountered a problem right at the start. I needed a way to identi ...

Learning to access $refs values in Vue.js

In my Vuejs (3) project that uses Typescript, I am working on avoiding the use of the type any with $refs: const el = (this.$refs['target'] as any).$el This results in a warning message: warning Unexpected any. Specify a different type @typesc ...

There was a typo in the Next.js TypeScript custom Document error message: TypeError: The Document class constructor cannot be invoked without using the 'new' keyword

I encountered a problem with my website that has a customized Document by _document.js. When I tried running yarn dev, I received the error: TypeError: Class constructor Document cannot be invoked without 'new' I spent a considerable amount of t ...

Steps to Turn Off Angular 2 Material Input Field

Please carefully review the Description below before proceeding: This is an HTML file containing code snippets: <div class="row col-md-2"> <mat-form-field appearance="outline" class="nameInput col-md-2"> <mat-label>One< ...

Set the style of the mat-select element

I'm having an issue with my select option in Angular Material. The options look fine, but when I select one, the strong tag disappears. Can anyone help me style only that part? Thank you in advance. <mat-select formControlName="projectId" ...

Importing Typescript reference paths with SystemJS when adding an application to the website

I have a link like this: http://www.example.com/product/ (Product is the name of my application in the server for accessing it under the main website). When working with MVC and including files such as CSS stylesheets in the head section, I usually use "~ ...

Generate a map that returns zero elements in a Typescript/Angular function

I recently started learning Angular and am currently working on a practice app. I have a feature where the app takes in a property file as input from HTML, processes the file, and stores the values in a map using TypeScript. While I can successfully store ...

Node module @azure/functions was uninstalled following the deployment of Azure Functions using VSCode

Whenever I deploy my Azure Function app using VSCode, the @azure/functions node module keeps getting removed and the import statement displays an error stating that the module cannot be found. I am aware that this package is not necessary in Azure, but how ...

Is there a way to simultaneously filter by two attributes using mat-select-filter in Angular?

I have integrated the mat-select-filter library in my Angular project, but I am facing an issue with the displayMember filter. Currently, it only filters by code, but I would like it to also filter by name simultaneously. Is there a way to achieve this u ...

Enhancing asynchronous operations with TypeScript and ExpressJs using Async/Await

Exploring the benefits of TypeScript's async/await in an Express project, I came across the following code snippet that seems to be stuck indefinitely without producing any outcome. Any thoughts on how to fix this issue? .. router.get('/test ...

Drawing coordinate lines on a two-dimensional array that simulates a grid

Are you solving a challenging code problem from the advent of code series? Check out the problem description here. The task involves processing input data in the form of coordinate lines on a grid (x1,y1 -> x2,y2). The goal is to populate a 2D array wi ...

What is the best way to import modules in Typescript/Javascript synchronously during runtime?

I have a Typescript class where I am attempting to perform a synchronous import, however, the import is being executed asynchronously. My code snippet looks like this: --------------100 lines of code-------------------- import('../../../x/y/z') ...