Skip to main content

Questions tagged [tsconfig]

tsconfig.json files are configuration for TypeScript projects. They contain the command line options to tell TSC (the TypeScript transpiler) how to build the JavaScript output.

Filter by
Sorted by
Tagged with
406 votes
20 answers
501k views

How can I use paths in tsconfig.json?

I was reading about path-mapping in file tsconfig.json, and I wanted to use it to avoid using the following ugly paths: The project organization is a bit weird because we have a mono-repository that ...
Remo H. Jansen's user avatar
313 votes
17 answers
246k views

How to force tsc to ignore node_modules folder?

I'm using tsc build tasks. Unfortunately I'm always getting the same errors from the node modules folder Executing task: .\node_modules\.bin\tsc.cmd --watch -p .\tsconfig.json < node_modules/@types/...
Daniel Santos's user avatar
139 votes
3 answers
107k views

What is target in tsconfig.json for?

What does target in tsconfig.json signify? { "compilerOptions": { "sourceMap": true, "target": "es5", "module": "commonjs", "jsx": "react", "moduleResolution": "classic", ...
Ankit Raonka's user avatar
  • 6,699
134 votes
7 answers
105k views

Setting up tsconfig with spec/test folder

Say I put my code under src and tests under spec: + spec + --- classA.spec.ts + src + --- classA.ts + --- classB.ts + --- index.ts + tsconfig.json I want to only transpile src to the dist folder. ...
unional's user avatar
  • 15.3k
130 votes
5 answers
118k views

How to use multiple tsconfig files in vs-code?

I am using Visual Studio Code and have a fairly common project structure: ├── client/ │ ├── tsconfig.json ├── shared/ ├── server/ │ ├── tsconfig.json ├── project.json The two tsconfig files have ...
Mike Jerred's user avatar
  • 10.3k
124 votes
24 answers
206k views

Why are these tsconfig paths not working?

I'm trying to do something very similar to the jquery path example in the documentation, but TS keeps throwing TS2307 (webpack compiles fine): "compilerOptions": { "baseUrl": "./src", "paths":...
Jakob Jingleheimer's user avatar
117 votes
3 answers
47k views

Why does Vite create two TypeScript config files: tsconfig.json and tsconfig.node.json?

I'm using Vite to create a new React + TypeScript project. After creating the project, there are two TypeScript config files on the root folder: tsconfig.json and tsconfig.node.json. These are the ...
rodrigocfd's user avatar
  • 7,471
114 votes
18 answers
176k views

Cannot find module that is defined in tsconfig `paths`

I am trying to setup aliases for my mock server. Whenever I try to compile ts files, it returns error that it couldn't find proper modules even though those are defined in tsconfig,json->paths Folder ...
Jamil Alisgenderov's user avatar
95 votes
5 answers
184k views

Typescript image import

I found a solution here: Webpack & Typescript image import But I am getting error for this: [ts] Types of property 'src' are incompatible. Type 'typeof import("*.png")' is not ...
Mario Petrovic's user avatar
88 votes
10 answers
55k views

Problem with Visual Studio Code using "react-jsx" as jsx value with create-react-app

I'm struggling with following "error" in VSCode : Argument for '--jsx' option must be: 'preserve', 'react-native', 'react' Hence, react-scripts (create-react-app) automatically sets the jsx ...
Denis Lebon's user avatar
85 votes
9 answers
62k views

Overriding `tsconfig.json` for ts-node in mocha

Is it possible to override which tsconfig.json ts-node uses when called from mocha? My main tsconfig.json contains "module": "es2015", but I want to use "module": "commonjs" for ts-node only. I ...
Ralph's user avatar
  • 32.1k
83 votes
2 answers
68k views

Exclude with pattern in tsconfig.json

Is there any way to add a pattern in the exclude property of a tsconfig file or is it only able to support directories? I'm trying to exclude all my test files from compilation so I was wondering if ...
Nick Tsitlakidis's user avatar
83 votes
8 answers
52k views

'package.json' is not under 'rootDir'

I'm trying to import package.json in my TypeScript application: import packageJson from '../package.json'; My tsconfig.json contains the following: { "compilerOptions": { "...
Kousha's user avatar
  • 35.2k
73 votes
2 answers
51k views

Typescript noEmit use case

What is the use case for noEmit in Typescript? I'm interested because I want to see if I can use this for development where I'll compile and run the compiled code without outputting them onto the file ...
hwkd's user avatar
  • 2,548
72 votes
3 answers
65k views

Exclude node_modules from "problems"

I'm running this task: { "taskName": "tsc watch", "command": "tsc -w", "type": "shell", "problemMatcher": "$tsc-watch" } with this tsconfig: { "compileOnSave": ...
Olian04's user avatar
  • 6,721
58 votes
15 answers
102k views

(ESLint/Cypress): Parsing error: ESLint was configured to run on `<tsconfigRootDir>/component/TestComponent.cy.ts` using `parserOptions.project`

I am setting up a new project with Remix (remix.run) and I am trying to configure Cypress/ESLint for component testing. I have a TestComponent.cy.ts with some boilerplate code: describe('TestComponent....
T. Duke's user avatar
  • 926
57 votes
5 answers
37k views

Typescript paths not resolving when running jest?

Attempting to convert this project over to jest using these instructions. I have everything working except for the files that use the paths configuration: "paths": { "@fs/*": ["./src/*"], ...
Ole's user avatar
  • 45.3k
57 votes
6 answers
52k views

What is the purpose of tsconfig.json?

I was reading Angular2 references and found this: tsconfig.json. I would like to know what the following parameters mean? { "compilerOptions": { "target": "es5&...
Bhushan Gadekar's user avatar
54 votes
7 answers
45k views

tsc - doesn't compile alias paths

I have typescript and uses the aliases. Here is part of tsconfig.json "compilerOptions": { "baseUrl": "./src", ... }, By setting the base url, I can change import User from "src/models/User....
ahadortiz's user avatar
  • 1,116
52 votes
9 answers
40k views

Visual Studio Code can't resolve angular's tsconfig paths

I'm trying to import some services using barrels and tsconfigs paths options but I can't get angular and vscode to get along. If it works for one it doesn't for the other and viceversa... My ...
Doc's user avatar
  • 5,236
50 votes
1 answer
28k views

What is module option in tsconfig used for?

I am trying to understand the typescript module compiler option. I went through typescript documentation - docs It says module option is to Specify module code generation. What does that mean? ...
troglodyte07's user avatar
  • 3,958
49 votes
9 answers
67k views

node_modules/@types/node/index.d.ts(20,1): error TS1084: Invalid 'reference' directive syntax

I have a problem with typescript compilation. Has anybody else received this error? node_modules/@types/node/index.d.ts(20,1): error TS1084: Invalid 'reference' directive syntax. tsconfig.json: { ...
heyJoe's user avatar
  • 591
49 votes
6 answers
26k views

How to get tsc to Resolve Absolute Paths when Importing Modules using baseUrl?

Consider a simple typescript project with the following directory structure: | package.json | tsconfig.json | \---src | app.ts | \---foobar Foo.ts ...
Zsw's user avatar
  • 4,058
49 votes
3 answers
29k views

Best practice to setup tsconfig "files" vs "include"?

I was wondering what is better and what are the pros and cons of using "files" vs "include" in tsconfig? I don't really like the include pattern because is just including all ts files in the src ...
Totty.js's user avatar
  • 15.7k
45 votes
4 answers
93k views

exclude subdirectories in tsconfig.json

I have installed TypeScript 1.8.2, and using Visual Studio 2015. I have a simple project where I have problems excluding folders from the tsconfig.json file. The problem is I would like to exclude the ...
DNRN's user avatar
  • 2,459
40 votes
1 answer
29k views

How to exclude specific files in typescript only for the build?

Is it possible to exclude all test files only for the build but use them with nodemon to run tests locally? When I exclude test files within the tsconfig.json file I get a typescript error that it can'...
thiloilg's user avatar
  • 2,013
37 votes
2 answers
4k views

Visual Studio 2017, JavaScript intellisense inconsistencies

TL;DR: How do you include a tsconfig.json file in Visual Studio 2017 and still have JavaScript intellisense work like it does by default, giving code hints both for your own code and 3rd-party ...
Caleb Bergman's user avatar
36 votes
6 answers
46k views

Webpack ts-loader : change tsconfig filename

I have 2 tsconfigs, one for my dev build and one for my prod build. I choose the tsconfig with the -p flag : tsc -p dev.tsconfig.json Ts-loader is looking for a tsconfig.json file. How can I specify ...
gr3g's user avatar
  • 2,894
34 votes
6 answers
72k views

ts-node execute typescript with module import and module defined

I try to initialize database base via typescript. my ts is like: import { User, UserRole } from '../entity/User'; import crypto from 'crypto'; import {dbManager, pwhash } from '..'; async function ...
user504909's user avatar
  • 9,329
34 votes
7 answers
46k views

Exclude files from build in Angular 2

How to exclude files from the Angular build using Angular-CLI. I've just added the path to exclude in the tsconfig.json and tsconfig.app.json files, but when I run ng serve, Angular is still trying ...
Matías González's user avatar
33 votes
3 answers
23k views

Angular language service in VSCode does not work because it is not an Angular project ('@angular/core/core.d.ts' could not be found)

Somehow the Angular (v11.0.4) language service in VSCode does not work anymore. I get the following error message.: [Info - 17:52:04] Angular language server process ID: 147359 [Info - 17:52:04] ...
BuZZ-dEE's user avatar
  • 6,627
32 votes
2 answers
27k views

How to have absolute import paths in a library project?

I have a library with a workspace containing two projects, one for the library itself and one for a test application. ├── projects    ├── midi-app    └── midi-lib In the workspace tsconfig.json ...
Stephane's user avatar
  • 12.5k
30 votes
8 answers
27k views

Angular 6 application cannot find namespace 'google'

This question has appeared similarly in many places where the solution is to simply add import { } from '@types/googlemaps'; which worked as a solution in past versions of angular. The issue ...
Murphy4's user avatar
  • 1,531
29 votes
11 answers
67k views

Cannot find module 'next' or its corresponding type declarations

Getting Cannot find module '' or its corresponding type declarations. when importing in Next.js project. This happens on every single import. Preview Yarn version : 3.1.0-rc.2 Next version: 11.1.2 ...
asobirov's user avatar
  • 493
28 votes
1 answer
3k views

skip library check only in node_modules

There are several questions about disabling errors in mistyped node_modules (e.g., this one, or this one), but they all involve using the skipLibCheck compiler flag. Are there other solutions to this ...
Felipe's user avatar
  • 3,121
27 votes
2 answers
9k views

Why are dom and dom.iterable separate?

In tsconfig.json you can define additional libs, that give you typings for HTML or DOM "libraries"(? I don't know the correct terminology). I don't understand why dom and dom.iterable are ...
Manuel Meister's user avatar
27 votes
1 answer
42k views

typescript tsconfig.json include exclude not working

I have a web project I have folders src/app/shared/models src/app/shared/services src/app/shared/types Each one of those is subfolder that have folders or files inside it, I want to exclude those ...
Zakk's user avatar
  • 768
27 votes
2 answers
22k views

eslint rule @nrwl/nx/enforce-module-boundaries fails

Intro I was very confused with that rule when I recently ported the Ng code base to Nx 12.x. I hope this post helps others who begin migrating from Ng to Nx. The code base above is a rather small ...
Juri Sinitson's user avatar
26 votes
2 answers
14k views

How to type check a single file from command line, using the setting in tsconfig.json?

Normally I run tsc -p ./tsconfig.json which type checks all files in the ./src folder relative to tsconfig. But if I run tsc -p ./tsconfig.json src/specific-file.ts, it complains error TS5042: ...
trusktr's user avatar
  • 45k
25 votes
3 answers
17k views

How to set paths property in a project with multiple tsconfig.json?

I have the following file structure |__ app1/ | |__ tsconfig.json |__ utilities/ | |__ files.ts |__ base-tsconfig.json In base-tsconfig.json I have set the paths property as following "...
starcorn's user avatar
  • 8,451
24 votes
1 answer
9k views

ts-node 'MODULE_NOT_FOUND' when using absolute imports in TypeScript

I stumbled upon a problem with absolute imports. The repository is publicly available here: https://github.com/repetitioestmaterstudiorum/ts-boiler When I'm trying to import a file with absolute path (...
codingforworlddomination's user avatar
24 votes
2 answers
26k views

TypeScript 3.7.2 - Support for the experimental syntax 'optionalChaining' isn't currently enabled

In my project I am using TS 3.7.2 which should support optional chaining. But when I try to use it like that: const state = urlParams.state?.toString() I get the error: Support for the experimental ...
flppv's user avatar
  • 4,271
24 votes
2 answers
9k views

Preventing inappropriate imports and enforcing project hierarchy in Typescript

In a TS project I'd like the following to be blocked: A file from folder common importing from folder projectA A file from folder projectB importing from folder projectA I'd like the following to be ...
Ben Carp's user avatar
  • 25.8k
24 votes
6 answers
23k views

How can I compile my Typescript into a single JS file with no module loading system?

I have a small Typescript project of about 10 ts files. I want to compile all my files into es5 and into a single es5 file called all.js. Currently, with my tsconfig.json set up as { "...
CodyBugstein's user avatar
  • 22.9k
24 votes
1 answer
9k views

How to use different tsconfig file for test files in vscode?

This question is similar to this question: How to use different tsconfig file for tests? But I am asking for visual studio code. I have two tsconfig files: tsconfig.json for all application files ...
Michael Hilus's user avatar
23 votes
4 answers
25k views

Possibility of Suppressing any error (e.g. incl. TS7017) within a config file (e.g. tsconfig.json)

I would like to suppress any desired error; TS7017 is only an example. Maybe it is possible now? Can TypeScript v4++ help? I want to achieve something like (e.g., in the compilerOptions in tsconfig....
user avatar
23 votes
2 answers
11k views

What is the use-case of enabling declaration and declarationMap in tsconfig.json?

If we enable sourcemap which allows us to debug on the browser. Likewise looking for the use case of declaration and declarationMap. I have searched over the internet, but my bad could not found the ...
Sathishkumar's user avatar
23 votes
1 answer
19k views

What does tsconfig.spec.json do?

I have seen this and this posts and they have made me understand tsconfig.app.json and tsconfig.json. I have an angular app which has tsconfig.app.json, tsconfig.json and tsconfig.spec.json What is ...
YulePale's user avatar
  • 7,360
23 votes
2 answers
16k views

Monorepo with paths from Typescript is not working

I have monorepo (yarn workpaces) with following file structure: ├── client (workspace @client) │   ├── package.json │   └── tsconfig.json (extended tsconfig) ├── server ...
J V's user avatar
  • 733
23 votes
2 answers
14k views

Extend a "paths" tsconfig file for a monorepo

I've got a folder structure like so: - mono-repo tsconfig.paths.json - Website tsconfig.json - src test.ts index.ts - Tool - src index.ts // mono-repo/tsconfig.paths....
Seph Reed's user avatar
  • 10.1k

1
2 3 4 5
27