TS6059 found in excluded folder

I'm facing an issue with my tsconfig.json file that looks like this:

{"compilerOptions": {                                                                         
    "module": "commonjs",                                                                    
    "noImplicitAny": false,                                                                  
    "removeComments": true,                                                                  
    "preserveConstEnums": true,                                                              
    "outDir": "./target/src/",                                                               
    "rootDir": "./src/main/webapp/",                                                         
    "sourceMap": true,                                                                       
    "experimentalDecorators": true                                                           
},                                                                                           
    "exclude": ["node_modules", "target"]  
}

Upon running tsc, I encountered the following error:

error TS6059: File '../node_modules/ng2-select/components/ng2-select-config.ts' is not under 'rootDir' 'main/webapp'. 'rootDir' is expected to contain all source files.

The problem seems to arise when trying to import ng2-select in a file:

import {Component} from 'angular2/core';
import {select} from 'ng2-select';

If I remove the second import and run tsc again, everything works fine. However, adding the second one triggers the error mentioned above.

Any insights into why it's attempting to compile ng2-select despite being excluded?

Thank you!

Answer №1

There seems to be a problem either within the structure of the ng2-select module or a potential bug in the typescript compiler.

This issue arises when there are both .ts and .d.ts files located in the same directory within the module's directory you are attempting to load from. The compiler may get confused as it compiles something outside of the defined rootDir.

I personally encountered this issue and have addressed it on the repository for the module found on GitHub. Check out my discussion here. In the meantime, you may find temporary help with this solution, although it is not ideal. Hopefully, a permanent fix will be implemented soon.

Update:

The issue has been resolved in the latest release.

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

Encountering difficulty in presenting detailed information using a .json file

My photo gallery app functions perfectly when fetching data from jsonplaceholder.typicode.com. However, when I use my own local data, it breaks whenever I try to click on a photo to view its details. How is it possible for the photos to display correctly b ...

Using React and Typescript, implement an Ant Design Table that includes a Dropdown column. This column should pass

Next Row: { title: "Adventure", render: (item: ToDoItem) => { //<- this item return ( <Dropdown overlay={menu}> <Button> Explore <DownOutlined /> </Button> </Dropdown&g ...

Utilize Angular directive to encapsulate JQuery

I am struggling to integrate the jquery codepen provided by mnpenner into an angular directive. This is my first time working with directives and I can't seem to get it functioning... http://codepen.io/mnpenner/pen/mFokd I attempted to add the code ...

Can a function's return type be set to match the return type of its callback function?

Check out the following function export const tryAsyncAwait = async (fn: () => any) => { try { const data = await fn(); return [data, null]; } catch (error) { return [null, error]; } }; If I use this function as an example... const ...

AngularJS Project Guide for Running Breeze Queries

I need assistance creating a universal function to run a breeze query. This function must fulfill the following objectives: Check if the query has been executed before, and if so, run the query locally. Be compatible with environments like Sharepoint 201 ...

AngularJS Interceptors for secure page management

I recently started working with AngularJS and I'm facing an issue with my interceptor that catches 401 errors from server responses. When a 401 status is detected, it triggers a "loginRequired" message broadcast and redirects to the login page. Howev ...

Incorporate Sendbird into Angular 6 for seamless communication integration

I recently started delving into the world of angular6 and nodejs. I am eager to integrate sendbird with Angular6, but I'm struggling to find a clear starting point. If anyone has successfully done this before, I would greatly appreciate some guidance ...

What is the process for sending a GET request with a URL-encoded object in Angular?

I am struggling with a complex object: { valueA:'a', value_array: { 'v': {value:1, value:2}, 'v2': {value:1, value:2}, } } Is there a way to encode it as a URL string for a GET request using Angular's HTTP servic ...

Infer the types and flatten arrays within arrays

I am currently working on creating a custom function in typescript that can flatten nested arrays efficiently. My current implementation is as follows: function flattenArrayByKey<T, TProp extends keyof T>(array: T[], prop: TProp): T[TProp] { re ...

Upon upgrading @types/angular, I encountered error TS2694 stating that the namespace 'angular' does not have an exported member 'xxx'

Following the upgrade of angular and @types/angular to version 1.6.x, an array of TS2694 errors suddenly appeared: error TS2694: Namespace 'angular' does not include an exported member named 'material' error TS2694: Namespace 'ang ...

Challenges encountered when setting a value to a custom directive via property binding

I'm working on a question.component.html template where I render different options for a specific question. The goal is to change the background color of an option to yellow if the user selects the correct answer, and to red if they choose incorrectly ...

Removing the @Input decorator in Angular's codebase

I am currently working on an Angular project for a class, and I'm facing an issue where removing the @Input decorator from my component is causing the entire application to not load properly. import { Component, OnInit, Input } from '@angular/ ...

My browser is able to display the JSON response from an HTTP request, as well as the REST client, but

I am attempting to access my own endpoint on a subdomain managed by Nginx. I anticipate the request to fail and return a JSON payload structured like this: { "hasError": true, "data": null, "error": { " ...

Using `ngIf` to loop through two distinct arrays

Looking at this code snippet: <tr ng-repeat="row in someController.searchResults" ng-class="{'selected': tableRow.selected}" ng-click="selectRow(tableRow)" > This piece of code is iterating through the searchResults array. I&ap ...

When attempting to run npm install for @types/jquery, an error is returned stating "Invalid name: @types/jquery"

npm install @types/jquery npm ERR! Windows_NT 10.0.10586 npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-c ...

Guide on how to have two controllers execute identical tasks in Angular while modifying the appearance of the website

Trying to recreate Google's homepage functionality using Angular has been challenging for me. Despite watching Egghead videos and studying the API extensively, I couldn't find a specific example for this behavior. Here's what I aim to achiev ...

Having Trouble Retrieving Data from Observable in Angular 2 and Typescript

I've encountered a promise error when trying to access a variable that receives data from an observable. Here's an example: Within my component, I have defined the Stat class: export class Stats { name: string; percentage: number; constru ...

Preserving quotation marks when utilizing JSON parsing

Whenever I try to search for an answer to this question, I am unable to find any relevant results. So please excuse me if this has been asked before in a different way. I want to preserve all quotation marks in my JSON when converting from a string. In m ...

Setting up TypeScript in an Angular 2 project and integrating Facebook login

Currently, I am in the process of familiarizing myself with Angular 2 and typescript. Although things have been going smoothly so far, I have hit a roadblock while attempting to implement a Facebook login message. In my search for a solution, I stumbled up ...

Setting up WebPack for TypeScript with import functionality

A tutorial on webpack configuration for typescript typically demonstrates the following: const path = require('path'); module.exports = { ... } Is it more advantageous to utilize ES modules and configure it with import statements instead? Or is ...