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.

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.

Options can also include directives for the TypeScript editor, such as whether to compile on save and (in some editors) code formatting options.

The schema can be found at http://json.schemastore.org/tsconfig

For more details, see What is a tsconfig.json?.

The term "TSconfig" can also (much more rarely) refer to TypoScript used in the proprietary TYPO3 CMS.

1216 questions
380
votes
20 answers

How to use paths in tsconfig.json?

I was reading about path-mapping in 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 contains projects and libraries. The projects are…
Remo H. Jansen
  • 23,172
  • 11
  • 70
  • 93
278
votes
12 answers

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/node/index.d.ts(6208,55): error TS2304: Cannot find…
Daniel Santos
  • 14,328
  • 21
  • 91
  • 174
133
votes
3 answers

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", "lib": [ "es2015", "dom", "es2017" ] } }
Ankit Raonka
  • 6,429
  • 10
  • 35
  • 54
128
votes
6 answers

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. Since index.ts is the entry point of my package, my…
unional
  • 14,651
  • 5
  • 32
  • 56
116
votes
5 answers

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 different settings (e.g. the one under client/…
Mike Jerred
  • 9,551
  • 5
  • 22
  • 42
101
votes
22 answers

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": { "@client": [ "client", …
Jakob Jingleheimer
  • 30,952
  • 27
  • 76
  • 126
94
votes
15 answers

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 structure: ├── server │   └── src │   …
Jamil Alisgenderov
  • 1,448
  • 2
  • 12
  • 23
84
votes
9 answers

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 key to react-jsx value, when react value seems to…
84
votes
9 answers

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 tried this mocha --compilers…
Ralph
  • 31,584
  • 38
  • 145
  • 282
82
votes
4 answers

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 assignable to type 'string | undefined'. Type 'typeof…
Mario Petrovic
  • 7,500
  • 14
  • 42
  • 62
76
votes
2 answers

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 contents of each one: tsconfig.json { …
rodrigocfd
  • 6,450
  • 6
  • 34
  • 68
76
votes
2 answers

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 I can use something like this…
Nick Tsitlakidis
  • 2,269
  • 3
  • 22
  • 26
74
votes
7 answers

'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": { "rootDir": "./src/" "outDir": "./dist/", "baseUrl": ".", …
Kousha
  • 32,871
  • 51
  • 172
  • 296
67
votes
2 answers

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 system which would be more efficient. Edit:…
hwkd
  • 2,411
  • 3
  • 18
  • 27
64
votes
3 answers

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": true, "files": [ "src/index.ts" …
Olian04
  • 6,480
  • 2
  • 27
  • 54
1
2 3
81 82