It appears that tsc is failing to recognize the "exclude" directives specified in the tsconfig.json file

I'm having difficulty with tsc recognizing my tsconfig.json file and compiling my .ts files. I keep encountering duplication errors that I'm trying to prevent using my tsconfig.json.

Here's what I have:

package.json
tsconfig.json
typings.json
typings /
    main/ ...etc
    browser/ ...etc
    main.d.ts
    browser.d.ts
src / ...   <source files in here.>

This is how my typings.json appears:

{
  "ambientDependencies": {
    "es6-shim": "registry:dt/es6-shim#0.31.2+20160317120654",
    "jasmine": "registry:dt/jasmine#2.2.0+20160412134438",
    "node": "registry:dt/node#4.0.0+20160509154515"
  }
}

My tsconfig.json is structured as follows:

{
  "compilerOptions": {
    "target": "es5",
    "module": "system",
    "moduleResolution": "node",
    "sourceMap": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "removeComments": false,
    "noImplicitAny": false
  },
  "exclude": [
    "node_modules",
    "bower_components",
    "typings/main",
    "typings/main.d.ts"
  ]
}

In my package.json, under the tests object, I have:

 "tsc": "tsc",

I expect my tsconfig.json to instruct tsc to ignore main.d.ts and other definitions in 'main'. More information on avoiding type definition collisions can be found here.

So when I execute npm run tsc, I anticipate tsc to overlook main.d.ts and everything in 'main', yet it doesn't.

I've come across instances where tsc disregards tsconfig.json when specific files are defined, but that's not the case here.

Why is tsc overlooking my tsconfig.json? Why isn't tsc cooperating?

Your thoughts would be greatly appreciated!

By the way, the errors consist of multiple lines like these - affecting both main and browser folders:

typings/main/ambient/node/index.d.ts(2067,18): error TS2300: Duplicate identifier 'PassThrough'.
typings/main/ambient/node/index.d.ts(2072,9): error TS2300: Duplicate identifier 'showHidden'.
typings/main/ambient/node/index.d.ts(2073,9): error TS2300: Duplicate identifier 'depth'.
typings/main/ambient/node/index.d.ts(2146,9): error TS2300: Duplicate identifier 'isTTY'.
...

Edit:

After modifying my tsconfig.json to exclude browser and browser.d.ts, and referencing typings/main.d.ts in my reference path in src/typings.d.ts, I now encounter these errors:

src/typings.d.ts(3,13): error TS2403: Subsequent variable declarations must have the same type. Variable 'module' should be of type 'NodeModule', but has '{ id: string; }' type.
typings/main.d.ts(1,1): error TS6053: File 'typings/main/ambient/angular-protractor/index.d.ts' not found.
typings/main.d.ts(5,1): error TS6053: File 'typings/main/ambient/selenium-webdriver/index.d.ts' not found.

Answer №1

The issue arose because you mistakenly referenced the excluded main.d.ts file in your code, causing duplicate loading from tsc.

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 it impossible to use type as a generic in TypeScript?

Struggling with TypeScript in React and encountered an issue. I decided to use a generic to build an abstracted class related to Axios. However, I ran into an ESLint error when using any as the type parameter for my generic. ESLint: Unexpected any. Specif ...

While performing compilation, Angular's ngFor triggers an error when used with SVG elements

I am attempting to create a recursive function of lines in order to generate a graph, but I am encountering a strange error in the console. It works fine on node.js. Below is the code snippet: <svg height = "200" width = "300"> ...

The act of updating Angular 2 to Angular 4 has resulted in an issue where the 'AnimationDriver' member is not being exported

After upgrading my Angular 2 to Angular 4, I encountered an error message when running my project: The module 'node_modules/@angular/platform-browser/platform-browser' does not have the exported member 'AnimationDriver'. ...

Trouble with a third-party library component not functioning properly on the server side in a Next.js environment

I've encountered a puzzling issue lately in my work. Recently, I started using the new NextJS v13 with React server components. I'm integrating it into a project that depends on a small private third-party library I created and shared among mul ...

Deleting button on Angular 4's CKEditor

Currently, I am utilizing version 4.7.3/basic/ckeditor.js and seeking guidance on how to eliminate the "About" and "NumberedList" buttons. Does anyone have a solution for this? <ckeditor [(ngModel)]="work.points" [config]="{removePlugins: 'Ab ...

What might be causing my action function to be triggered during the rendering process?

While working on creating a basic card view in material UI, I encountered an issue where the functions for adding and deleting items seem to be triggered multiple times upon rendering. I am aware that a common reason for this could be using action={myFunc ...

Removing the gridlines in a Linechart using Apexcharts

I am experiencing issues with the grid and Nodata options on my Apexchart line chart. noData: { text: none , align: 'center', verticalAlign: 'middle', offsetX: 0, offsetY: 0, style: { color: undefined, fontSize: &apo ...

The counterpart of the RxJS setTimeout operator

Looking for a RxJS operator alternative to set/clearTimeout in these circumstances: this.mouseEnterSubscription = this.mouseEnterStream .subscribe(() => { this.timeout = setTimeout(() => { void this.playVideo(); }, 500) }); this.mo ...

Issue with data propagation in Angular 2 RC5 when using ngStyle in parent component

Here is a basic Angular 2 application setup I am working with: import { Component } from '@angular/core'; @Component({ selector: 'my-app', template: ` <h1>Test</h1> <test-component [Height] = "30 ...

Using services in Angular 6 CLI with dynamically added components

One of my recent projects involved creating a directive in Angular 6 called 'DeleteDirective' and integrating it with a service called 'DeleteService' to enable the deletion of items from the application. Once an item is deleted (handle ...

Navigating the structure of an Angular project: sorting modules by core, features, and

Before we begin, let me clarify that this question is original and has not been asked before. I have thoroughly reviewed the angular guide on this topic. However, I still find myself with a handful of questions. Starting with feature modules - the concept ...

Choosing Vue select options depending on a condition

I am working on a dropdown template with Vue.js and have encountered some challenges. Here is the basic structure of my dropdown: <select v-model="selectedClient" class="stat-select text-u-c"> <option disabled value="">Please select a Client ...

Ensuring Mongoose Schema complies with an external API

My database schema includes a mongoose User schema with the following structure: const User: Schema = new Schema({ // some other fields email: {type: String, unique: true, require: true, validate: [myValidator, 'invalid email provided'], // some ...

Cannot find property in type, and the parameter is implicitly of an unspecified type

I've been encountering this issue where I keep getting an error message. I attempted to resolve it by setting "noImplicitAny": false in tsconfig.json, but unfortunately that did not work. As for the 'Property does not exist on type' error, I ...

Identify modifications in NGRX state before shutting down

In my Angular application, I am utilizing NGRX to manage state. Users are able to switch between different versions of the store, each saved and reloaded from a database. It's important for me to detect when changes have been made to the store but not ...

The Threejs Raycaster detects collisions with objects even when the ray is just grazing the surface

Within my Vue component, I have integrated a threejs scene and I am facing an issue with selecting objects using the mouse. I am currently using the OnPointerDown event and raycaster to locate objects under the mouse pointer. However, it seems like the ray ...

Deeply nested .map function to update state value

The current state value const [settings, setSettings] = useContext(SettingsContext) Utilizing the .map method on the settings state {settings[categoryIndex]?.config?.map((item: ConfigItem, index: number) => ...

The access token generated by the Angular Keycloak adapter for Spring Boot backend authorization is not valid

The access tokens generated by Angular's keycloak adapter are invalid for communicating with a Spring Boot backend application secured by the same Keycloak realm. The localhost addresses were replaced with example.com to avoid issues with spam filters ...

Tips for running a Nativescript-Angular app in the background

I am currently developing a hybrid app using NativeScript and Angular that has the capability to send real-time location updates from the user to a server via the geolocation plugin, among other features. While everything seems to be working fine when the ...

Simulating @Input data for an Angular component using Jest

As we transition our Jasmine tests to Jest in our Angular project, we are encountering issues when attempting to mock @Input values of components in the tests. Previously, in Jasmine, we would write code like this: @Component({ selector: 'app-messag ...