VSCode encounters difficulty in locating the tsconfig within the Next.js application developed with NX

For the creation of a new NX workspace, I executed the following command:

npx create-nx-workspace@latest --preset=next --packageManager=yarn --skipGit

To further expand on this, I also generated a shared library using the command below:

npx nx g @nrwl/next:library components --directory=shared/ui/theme-v1.0 --component=false --tags=--tags=scope:themev1-ui,type:shared,platform:web --style=none --importPath=@my-app/shared/ui/theme-v1.0/components

In order to share the tsconfig.json within the Next.js app, here is the configuration snippet that was utilized:

{
  "extends": "../../tsconfig.base.json",
  "compilerOptions": {
    // Compiler options here...
  },
  "include": [
    "src/**/*.ts",
    // Include paths listed here...
  ],
  "exclude": ["node_modules", "jest.config.ts"]
}

After running npx nx lint, no errors were reported from the linter. However, in my VSCode setup, there seems to be an issue with detecting the tsconfig file, leading to false error notifications. A screenshot has been provided along with the folder structure for reference:https://i.sstatic.net/1E97q.jpg

The problem appears to be specific to the Next.js project, as other libraries do not exhibit the same issue. Another screenshot showcasing the absence of this problem in other scenarios can be viewed here:https://i.sstatic.net/DsrdC.jpg

Attempts to resolve this by creating a separate tsconfig.app.json file and extending tsconfig.json did not yield positive results. Reloading VSCode was also attempted without success. The root cause remains uncertain, whether it's related to VSCode or the NX set-up, given that workspace TypeScript is being utilized instead of the default option provided by VSCode.

Details regarding the package.json configuration are outlined below:

{
  // Package.json details here...
}

NX.json configuration settings are detailed as follows:

{
  // NX.json settings outlined here...
}

Answer №1

The problem has been identified. It appears that the issue lies in the include property set by the @nrwl/next team.

Upon creating a new app, the include property is initially defined as:

  "include": [
    "src/**/*.ts",
    "src/**/*.tsx",
    "src/**/*.js",
    "src/**/*.jsx",
    "next-env.d.ts"
  ]

However, the Next.js app does not contain a src/ directory. As a result, it should be modified to:

"include": ["**/*.ts", "**/*.tsx", "**/*.js", "**/*.jsx", "next-env.d.ts"]

I have also submitted a GitHub ticket for this issue - https://github.com/nrwl/nx/issues/13861

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

When attempting to save, TypeORM throws an error stating "undefined property 'inverseJoinColumns' cannot be read."

In a scenario where a user may or may not exist in the database, it needs to be either created if new or updated if already present. The process seems fine as TypeORM's .save() method efficiently handles updating existing entities and creating new on ...

Tips for avoiding the transmission of className and style attributes to React components

Hey there! I'm working on a custom button component that needs to accept all ButtonHTMLAttributes except for className and style to avoid any conflicts with styling. I'm using TypeScript with React, but I've run into some issues trying to ac ...

What is the purpose of adding a missing import in VSCode and why does it open a new tab with

Hey there! I've been experiencing an issue with my IDE VSCode for the past couple of weeks. Previously, everything was working fine but now I'm facing a peculiar problem. Whenever I miss an import in VSCode while working on my Angular project, i ...

encountering problems with Next.js routing resulting in 404 errors

I developed a Next Js 14 app where I had to change the routing names inside the pages before going live. For example, instead of 'Charts', I changed it to 'charts' and made similar modifications to other pages as well. However, after de ...

Hermes js engine encounters a TypeError when attempting to access the property '__expo_module_name__' of an undefined value

After updating my expo and react native app to the latest version, I encountered a problem that I couldn't find a solution for despite searching on Google. Link to image ...

Why isn't my Promise fulfilling its purpose?

Having trouble with promises, I believe I grasp the concept but it's not functioning as expected in my project. Here is a snippet of my code : (I am working with TypeScript using Angular 2 and Ionic 2) ngOnInit() { Promise.resolve(this.loadStatut ...

Learn the process of setting up a connection between Express JS and the NotionAPI using both POST and

As someone who is new to backend development, I am currently working on integrating a simple Notion form into a Typescript website. To guide me through the process, I found a helpful tutorial at . The tutorial demonstrates how to send data from localhost:3 ...

EventEmitter asynchronous callback

Can you attach an asynchronous callback to an EventEmitter in TypeScript or JavaScript? someEmitter.on("anEvent", async () => console.log("hello")); If so, does using an async function guarantee that the function will run asynchronously? Also, what ar ...

Encountering warnings when upgrading Next.js v10.1.13 to webpack5, specifically regarding the inability to resolve 'fsevents' in chokidar

npm install next react react-dom and Node.js v12 is running. I created a simple file at pages/index.tsx export default function PageHome(props) { return <>Hello World!</> } (I also followed the TypeScript configuration as per Next.js instru ...

Ways to retrieve unique attributes from a merged collection of two distinct object arrays?

Exploring object Arrays in TypeScript. const objArr1: { commonProperty: string; ABC: string }[] = [ { commonProperty: "I am common", ABC: "I am different in object 1", }, { commonProperty: "I am ...

I recently upgraded to Next v13 and I've been grappling with integrating redux. However, I keep encountering a context error. Can someone please advise me on what I might be doing incorrectly and suggest possible solutions?

I am embarking on creating a new game and need to maintain track of the user's life within the redux store. To accomplish this, I crafted a life slice as shown below: export const lifeslice = createSlice({ name: "life", initialState: { ...

How to modify a specific property of an array object in JavaScript

I have an array of objects that looks like this: [ { number: 1, name: "A" }, { number: 2, name: "e", }, { number: 3, name: "EE", } ] I am looking for a way to insert an object into the array at a specific position and ...

What is the syntax for declaring a variable with multiple types in Angular/Typescript?

Imagine having a variable declared with the following type: test?: boolean | { [key in TestEnum ]: boolean }; Now, let's assign this test variable within a constant where it can hold either a boolean value or a mapping to an enum. Consider the exampl ...

Refill ag-grid with fresh data

Setting up the ag-grid initialization directly from the HTML using an onGridReady method in the component file. <div style="flex-grow:1;"> <ag-grid-angular style="float:left;width: 100%; height: 201px;margin-top:10px;" class="ag- ...

What is the recommended way to handle data upon retrieval from a Trino database?

My goal is to retrieve data from a Trino database. Upon sending my initial query to the database, I receive a NextURI. Subsequently, in a while loop, I check the NextURI to obtain portions of the data until the Trino connection completes sending the entire ...

The eslint command encounters an issue on the CI Server, displaying the error message "ESLint is unable to locate the 'standard' config to extend from."

My local eslint configuration works perfectly fine with vscode editor, but I'm encountering an issue on the CI Server. When running the linting command, I receive the following error: eslint:config-array-factory Config file found: /home/worker/worksp ...

How can a contextual type be utilized independently of a class instance in TypeScript?

My goal is to find a way to use the this type or something similar outside of a class or interface method in TypeScript, rather than being limited to just within a class or interface. Consider this example: class TypedArray { [index: number]: number; ...

An effective way to extract targeted information from an array of objects using Typescript

I'm having trouble extracting the IDs from the selected items in my PrimeNG DataTable. Despite searching on Google, I couldn't find much information about the error I'm encountering... ERROR in C:/Users/*****/Documents/Octopus/Octopus 2.0/s ...

Notification that appears during the process of writing Python code in Visual Studio Code:

I'm a beginner learning Python and using VS Code as my code editor. However, when I write code, I keep seeing a message in a red circle like the one highlighted in the screenshot below. It's starting to get on my nerves. Can someone help me figu ...

Creating a type that can be used with a generic type T along with an array of the same generic type T

I am experimenting with TypeScript for this project type ArrayOrSingleType<T> = T | T[]; interface TestType<T> { a: ArrayOrSingleType<T>; b: (v: ArrayOrSingleType<T>) => void; } const testVariable: TestType<number&g ...