Is it possible to configure strict settings for specific files using tsconfig.json?

Check out my tsconfig.json file:

{
  "compilerOptions": {
    "allowArbitraryExtensions":true,
    "target": "ES2021",
    "lib": [
       "ES2021", "dom", "dom.iterable"
    ],
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "strictFunctionTypes": true
    
  },
  "lib": ["ES2021"],
  "exclude": ["node_modules", "dist","tmp"]
}

This configuration is working well for me, but I am interested in implementing stricter rules for a specific section of my project. Specifically, I want to enforce the rule "noImplicitAny": true,

Is there a way to do this within my existing setup?

Answer №1

You can achieve this:

Create a new tsconfig.json file in the specified subfolder.

{
  "extends": "../../../tsconfig.json", //In order to inherit the same configurations from the main project
  "compilerOptions": {
    "noImplicitAny": true, //additional settings
  },
  "include": ["*"]
}

Ensure you extend it correctly. The goal is to enable inheritance so that the subfolder adheres to all the guidelines of the main project and only modifies necessary ones.

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

Setting up a Typescript class for seamless use in both Browser and Node applications

I developed a web app consisting of two separate projects, each housed in different folders with their own set of unique files. The client component is built using Angular 2 (RC-4) with SystemJS Typescript 1.8.10 (as per instructions found here). The serv ...

The Typescript loop appears to be stuck and not moving through the

I have encountered a problem while trying to iterate through my array using foreach and forloop in an angular 8 application. Despite having 250 objects in the array, it is not iterating through any elements. I am unable to figure out what the issue could b ...

Exploring TypeScript and React Hooks for managing state and handling events

What are the different types of React.js's state and events? In the code snippet provided, I am currently using type: any as a workaround, but it feels like a hack. How can I properly define the types for them? When defining my custom hooks: If I u ...

Error encountered: `npm ERR! code E503`

While attempting to execute npm install on my project, which was cloned from my GitHub repository, I encountered the following error: npm ERR! code E503 npm ERR! 503 Maximum threads for service reached: fs-extra@https://registry.npmjs.org/fs-extra/-/fs-ex ...

Exploring i18nNext integration with antd table in React

Presently, this is the UI https://i.stack.imgur.com/CMvle.png App.tsx import "./styles.css"; import MyTable from "./MyTable"; export default function App() { const data = [ { key: "1", date: "2022-01- ...

The data structure '{ variableName: string; }' cannot be directly assigned to a variable of type 'string'

When I see this error, it seems to make perfect sense based on what I am reading. However, the reason why I am getting it is still unclear to me. In the following example, myOtherVariable is a string and variableName should be too... Or at least that&apos ...

Generic Typescript Placeholder Design

Imagine you have the following data: const dataA = { name: "John", age: 25, attributes: {specificA: "hello", specificA2: 14, nonspecific:"Well"}, } const dataB = { name: "Lisa", age: 38, attributes: {spe ...

Exploring the process of dynamically incorporating headers into requests within react-admin

Currently utilizing react-admin with a data provider of simpleRestProvider. I am in need of a solution to dynamically add headers to requests based on user interactions. Is there a way to achieve this? Appreciate any assistance. Thank you! ...

Getting a specific array from the API with fetch in Angular: A step-by-step guide

I am trying to retrieve images from an API, but I'm having trouble accessing all the arrays to get to the data. Currently, I am only able to fetch the posts arrays in a single call and not beyond that. https://i.stack.imgur.com/aFWlD.jpg My method fo ...

The specified type 'Observable<string | null>' cannot be assigned to type 'string'

I am struggling with the following code: id$!: Observable<string | null>; characterDetail$!: Observable<CharacterData | undefined>; //?????? constructor( private router: ActivatedRoute, private store$: Store ) {} ngOnInit(): void ...

Execute the React Native application on Windows by using the command npx react-native run-windows

I recently created a test application using React Native by running npx react-native init Test --template react-native-template-typescript (https://reactnative.dev/docs/typescript). Everything seemed to be working fine, but I encountered an issue where the ...

Subscribing to valueChanges in reactive forms to dynamically update checkbox options

My goal is to create a select dropdown with options for bmw, audi, and opel. The user can only select one option from the dropdown, but they should also have the ability to select the options that were not chosen using checkboxes. cars = [ { id: 1, na ...

display a dual-column list using ngFor in Angular

I encountered a situation where I needed to display data from an object response in 2 columns. The catch is that the number of items in the data can vary, with odd and even numbers. To illustrate, let's assume I have 5 data items to display using 2 co ...

Angular 5 - Implementing "similar to %" Filter (similar to SQL)

I have created a method in my code to filter an array based on a specific type. filterByType(type: string) { console.log("Filtering by type"); this.filteredArray = null; this.filteredArray = this.mainArray.filter((item: Item) => item.type === type); t ...

Storing the compiled TypeScript file in the source file's directory with the TypeScript compiler

I am in need of assistance with compiling TypeScript files (ts) into JavaScript files (js) and mapping files (js.map) all within the same directory as the source file. I have attempted to configure this in my tsconfig.json file using: { "compilerOption ...

Why do I keep getting an ExpressionChangedAfterItHasBeenChecked error after trying to update a random color in an

Is there a way to assign a random color from an array without causing the error message: "ExpressionChangedAfterItHasBeenChecked"? Even though the color of the chip changes quickly before the message appears, it seems like it's working. How can I reso ...

Encountering a Typescript issue when linking a class component with the reducer

Within my class component that is linked to the redux rootReducer, I am encountering a TypeScript error specifically related to the mapPropsToState section. The error message reads: Property 'unit' does not exist on type 'DefaultRootState&ap ...

The static side of the class `typeof _Readable` is erroneously extending the static side of the base class `typeof Readable`

I am currently developing a Discord bot using node/typescript. After running the typescript compiler on my code, I encountered this error: node_modules/@types/readable-stream/index.d.ts(13,15): error TS2417: Class static side 'typeof _Readable' ...

What is the best way to incorporate an AJAX GET request into an HTML element?

Currently, I am attempting to execute a JavaScript code that will convert all <a></a> elements found within another element <b></b> (the specific name in the HTML) into links that trigger an HTTP get request. However, the code I hav ...

Connecting Angular modules via npm link is a great way to share common

Creating a project with a shared module that contains generic elements and components, such as a header, is my goal. This shared module will eventually be added as a dependency in package.json and installed through Nexus. However, during the development ph ...