What is the reason behind tsc disregarding the include and exclude options in tsconfig.json?

I am facing an issue with my tsconfig.json file:

{
  "compilerOptions": {
    "target": "ES6",
    "lib": [
      "DOM",
      "ES6"
    ]
  },
  "include": [
    "src/server/**/*"
  ],
  "exclude": [
    "node_modules",
    "dist",
    "public"
  ]
}

When I executed tsc --project tsconfig.json, it completely disregarded the include and exclude settings causing a failure during compilation of files in the node_modules directory.

The only way it compiled successfully was using tsc src/server/**/*.ts, but this method did not adhere to the defined configuration.

I made sure that the compiler was reading the config file, as adding "watch": true under "compilerOptions" triggered the watch mode upon any changes made.

I referred to the documentation but couldn't find the resolution. The placement of the configurations in the JSON file seemed correct to me.

Does anyone have a solution for this problem?


Compiler version running on macOS Big Sur:

% tsc -v
Version 4.0.5

Answer №1

After addressing the issue mentioned in the comment below, I made a modification by including "skipLibCheck": true in the JSON configuration. The updated JSON looks like this:

{
  "compilerOptions": {
    "target": "ES6",
    "lib": [
      "DOM",
      "ES6"
    ],
    "skipLibCheck": true
  },
  "include": [
    "src/server/**/*"
  ],
  "exclude": [
    "node_modules",
    "dist",
    "public"
  ]
}

This adjustment resulted in successful compilation:

% tsc -p tsconfig.json
% echo $?
0

Answer №2

Encountering a similar issue, I managed to resolve it by updating TypeScript through the following command:

npm install -g typescript 

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

Next.js: Importing from a new endpoint triggers the code execution once more

Here is a simplified example I created for this specific question. Imagine I want to maintain a server-side state. components/dummy.ts console.log('initialize array') let number: number = 0 const incrementValue: () => number = () => numbe ...

Angular allows for creating a single build that caters to the unique global style needs of every

Currently, I am working on a project for two different clients, each requiring a unique style.css (Global CSS). My goal is to create a single production build that can be served to both clients, who have different domains. I would like the global style t ...

Strategies for adding elements to a FormArray in Angular 4

I am currently working on a dynamic Angular form that displays like this. <form [formGroup]="myForm"> <div *ngFor="let Repo of Repos;"> <fieldset> <legend>{{Repo.name}}</legend> ...

What is the best way to identify property errors in a React/Typescript project using ESLint?

I'm currently in the process of transitioning a Typescript project created with create-react-app to the latest version. As part of this update, I am moving from tslint to eslint which has posed some challenges. The main issue I'm facing is gettin ...

Stringified HTML code showcased

When working with Angular, I have encountered an issue where I am calling a function inside an .html file that returns a string containing a table element. My goal is to convert this string into HTML code. I attempted to use [innerHtml]: <p [innerHtml ...

RxJS BehaviorSubject allows you to retrieve the current value or obtain a new one depending on a specific condition

I am managing a subject that consumers subscribe to: private request$: Subject<Service> = new BehaviorSubject(null); Upon initialization, my components utilize this function: public service(id: number): Observable<Service> { return this. ...

The Angular CLI suddenly decided to stop providing me with useful lines (without sourcemaps) in the browser console, but interestingly the terminal continues

I recently noticed a change in my Angular project that is using Angular CLI. Instead of receiving error lines from my code, I am getting errors from compiled files like main.js and vendor.js. The 'normal' error messages in my terminal are pointin ...

Modifying iframe src using click event from a separate component in Angular 10

I am looking to dynamically update the src attribute of an iframe when the menu bar is clicked. The menu bar resides in a separate component and includes a dropdown menu for changing languages. Depending on which language is selected, I want to update the ...

What is the best way to create a data type that enables unrestricted index retrieval while ensuring that the value retrieved will never be

By enabling the noUncheckedIndexedAccess option in TypeScript, we ensure that when accessing object properties with arbitrary keys, the value type includes both the specified type and undefined. This behavior is generally appropriate as it aligns with run ...

Enhancements to managing universal configuration object across the entire application

My current project involves working on an application with multiple products. To streamline product-specific configuration and eliminate the need for excessive if-else statements, I am looking to implement product-specific config keys that are consistently ...

Utilize devextreme for uploading files

Currently, I am trying to implement an upload document feature using Dev-Extreme, but I keep encountering an error onFileUpload(event){ this.file = event.target.files[0] } <dxi-column [showInColumnChooser]="false" type="buttons" [width]="100 ...

Animating progress bars using React Native

I've been working on implementing a progress bar for my react-native project that can be used in multiple instances. Here's the code I currently have: The progress bar tsx: import React, { useEffect } from 'react' import { Animated, St ...

MUI DataGrid Identifying Duplicate Rows

I'm encountering an issue with my Data Grid component from MUI when fetching data using axios. The console shows the correct data, but on the page, it only displays one result or duplicates. I suspect there might be a frontend problem, but I'm s ...

Creating a personalized design for MUI TextField spin button

Looking to customize the appearance of the up/down spin buttons in MUI TextField. https://i.sstatic.net/DcG66.png Desiring white arrows and a black surrounding area that's slightly larger, akin to this: https://i.sstatic.net/ZxMJw.png I'm aware ...

Is there a way to configure tsconfig so that it can properly recognize ".graphql" files and aliases when they are imported into components?

Currently, I have encountered an issue where including "graphql" files in my components is leading to TypeScript errors due to unrecognized import pathing. Despite the error, the functionality works as expected. import QUERY_GET_CATS from "@gql/GetCats.gra ...

Exploring TypeAhead functionality in Reactjs 18

I have encountered an issue while using react-bootstrap-typeahead version 5.1.8. The problem arises when I try to utilize the typeahead feature, as it displays an error related to 'name'. Below is my code snippet: import { Typeahead } from " ...

Transferring documents from an angular ionic application to a slim php framework on the localhost

Hey there! I've got a project on my localhost where I need to upload files to a local folder. I'm sharing the code here in hopes that someone can assist me. HTML: <ion-item ion-item *ngFor="let item of lista" menuClose> Floor: ...

Can anyone help me with coloring Devanagiri diacritics in ReactJS?

I am currently working on a ReactJS project and I have come across an issue. I would like for the diacritic of a Devanagiri letter to be displayed in a different color than the letter it is attached to. For example: क + ी make की I was wondering ...

Ways to implement useState in a TypeScript environment

Hello, I am currently using TypeScript in React and trying to utilize the useState hook, but encountering an error. Here is my code: import React , { useState } from "react"; interface UserData { name: string; } export default function AtbComponent( ...

Is there a way to optimize Typescript compiler to avoid checking full classes and improve performance?

After experiencing slow Typescript compilation times, I decided to utilize generateTrace from https://github.com/microsoft/TypeScript/pull/40063 The trace revealed that a significant amount of time was spent comparing intricate classes with their subclass ...