401

I have an ASP.NET core project and I'm getting this error when I try to build it:

error TS18003: Build:No inputs were found in config file 'Z:/Projects/client/ZV/src/ZV/Scripts/tsconfig.json'. Specified 'include' paths were '["**/*"]' and 'exclude' paths were '["../wwwroot/app","node_modules/*"]'.
1>         The command exited with code 1.
1>       Done executing task "VsTsc" -- FAILED.

This is my tsconfig.json file:

{
  "compileOnSave": true,
  "compilerOptions": {
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "lib": [ "es5", "dom" ],
    "module": "commonjs",
    "moduleResolution": "node",
    "noEmitOnError": true,
    "noImplicitAny": false,
    "outDir": "../wwwroot/app/",
    "removeComments": false,
    "sourceMap": true,
    "target": "es6"
  },
  "exclude": [
    "../wwwroot/app",
    "node_modules/*"
  ]
}

Is this a bug or am I doing something wrong? I did recently upgrade Visual Studio 2015 to update 3. Has anyone encountered this before?

Tagc
  • 8,736
  • 7
  • 61
  • 114
rood
  • 11,073
  • 3
  • 19
  • 18

34 Answers34

667

TypeScript expects there to be at least one TypeScript file in the folder in order to compile.

To fix the error, add an empty typescript file to the typescript scripts folder (the location of your tsconfig file).

Miguel Guthridge
  • 1,444
  • 10
  • 27
rood
  • 11,073
  • 3
  • 19
  • 18
  • 150
    what does this mean? – Christian Matthew Feb 03 '17 at 19:25
  • 56
    @Christian Matthew This means, you need to add a t least one typescript file to the folder where your app is to satisfy typescript compiler. – rood Feb 04 '17 at 09:19
  • 32
    What do you mean by script folder. Can you please elaborate more?? – San Jaisy Feb 10 '17 at 00:48
  • @San Jaisy This is my custom folder where I keep my ts files and where tsconfig.json sits. – rood Feb 10 '17 at 09:48
  • 4
    Ironcially.. i used this answer a long time ago (added the tsconfig and it fixed this issue). When I added Vue to the project the issue popped up again... so I had to then delete the tsconfig I added in the past, and it worked :P – joshmcode Apr 06 '18 at 21:00
  • the empty ts in residing near tsconfig gets detected but it shows is 'rootDir(src)' is expected to contain all source files expected to contain all source files where i have kept all ts files - please help – Aromal Sasidharan Apr 24 '18 at 12:29
  • 5
    Thanks. Working for me. But can anyone explain what's actually happening behind? – DriLLFreAK100 Mar 13 '19 at 02:18
  • 2
    "what does this mean?" --> I think it means that you need to add at least a .ts file adjacent to your tsconfig.json file, or in a subfolder that the tsconfig.json file specifies as one that typescript should compile. If you're starting a new repo, this should go away when you start writing code. – Greg Micek May 13 '21 at 14:42
  • It doesn't even have to be a `.ts` file! I added my repo's `package.json` as workaround and it works well. – Nick Ribal Aug 14 '21 at 20:47
  • 1
    This worked for the Astro framework (https://astro.build). I created an empty.ts file in /src/components (you can name it as you wish). – Aamir Jul 20 '22 at 12:33
  • for me also fixed this with vue3 by removing tsconfig.json – DCX Apr 04 '23 at 16:15
  • By the way, if your configuration is `"include": ["src/**/*"]`, you must add a empty ts file in the `src` folder. – xgqfrms Aug 31 '23 at 16:41
310

You can also try to restart your code editor. That works well too.

desoga
  • 4,179
  • 1
  • 15
  • 18
236

This can occur because typescript server can't find any files described by the include array:

// tsconfig.json
{
  //...
  "include": [
    "./src/"
  ],
}

If you're using VSCode, you can restart your TS server within your editor super easily to prompt it to re-evaluate the file like this:

  1. Navigate to any .ts or .tsx file

  2. Open the command palette (CMD + SHIFT + P on mac)

  3. Run the TypeScript: Restart TS server command:

    TypeScript - Restart TS Server

TheScrappyDev
  • 4,375
  • 2
  • 21
  • 25
  • 1
    How do you get the _TypeScript_ command? I only have e.g. _File_, _Git_, _GitLens_, etc – Leo Mar 26 '20 at 19:47
  • 7
    @Leo make sure you're viewing a `.js`/`.jsx`/`.ts`/`.tsx` file when you look for the command. The command, for example, is not available when you're viewing an `.html` file – TheScrappyDev Apr 20 '20 at 18:21
  • restarting the ts server did it for me, didn't know that was a thing, thanks – Jeremy Aug 10 '21 at 20:20
  • this worked for me, others did not help as I did have .ts files there – Noob Nov 25 '21 at 03:30
  • This is the best answer, since it describes more in depth why the issue occurs (specific reference to tsconfig.json) and includes the case where the editor is bugging out. +1 – diggity Feb 28 '22 at 05:34
  • I ran into this after moving my tsconfig to the parent directory. This helped me to understand the very simple cause, thanks. – blwinters Mar 04 '23 at 19:58
39

I'm not using TypeScript in this project at all so it's quite frustrating having to deal with this. I fixed this by adding a tsconfig.json and an empty file.ts file to the project root. The tsconfig.json contains this:

{
  "compilerOptions": {

    "allowJs": false,
    "noEmit": true // Do not compile the JS (or TS) files in this project on build

  },
  "compileOnSave": false,
  "exclude": [ "src", "wwwroot" ],
  "include": [ "file.ts" ]
}
TreeAndLeaf
  • 1,064
  • 1
  • 13
  • 15
  • 2
    This can also be used for `jsconfig.js`. I am not using TS as well, but Vue and Vetur are starting to require this for some reason. That is a really bad architecture on their part. – Vladimir Jovanović Apr 22 '21 at 09:21
17

If you are using the vs code for editing then try restarting the editor.This scenario fixed my issue.I think it's the issue with editor cache.

Susampath
  • 706
  • 10
  • 13
16

In modern typescript config just set "allowJs" and no need to add any empty .ts file in include directories such as "src" (specified in include array)

tsconfig.json

{
  "compilerOptions": {
    "allowJs": true,
   ...
  },
  "include": [
    "src"
  ]
}
Nikhil Nayyar
  • 319
  • 4
  • 4
15

I have all of my .ts files inside a src folder that is a sibling of my tsconfig.json. I was getting this error when my include looked like this (it was working before, some dependency upgrade caused the error showing up):

"include": [
    "src/**/*"
],

changing it to this fixed the problem for me:

"include": [
    "**/*"
],
Corey Cole
  • 2,262
  • 1
  • 26
  • 43
11

When you create the tsconfig.json file by tsc --init, then it comments the input and output file directory. So this is the root cause of the error.

To get around the problem, uncomment these two lines:

"outDir": "./", 
"rootDir": "./", 

Initially it would look like above after un-commenting.

But all my .ts scripts were inside src folder. So I have specified /src.

"outDir": "./scripts", 
"rootDir": "./src", 

Please note that you need to specify the location of your .ts scripts in rootDir.

Pran Kumar Sarkar
  • 953
  • 12
  • 26
10

I was getting this error:

No inputs were found in config file 'tsconfig.json'.

Specified include paths were '["**/*"]' and exclude paths '["**/*.spec.ts","app_/**/*.ts","**/*.d.ts","node_modules"]'.

I had a .tsconfig file, which read TS files from the ./src folder.

The issue here was that with the source folder not containing any .ts files and I was running tslint. I resolved issue by removing tslint task from my gulp file, as I don't have any .ts files to be compiled and linted.

double-beep
  • 5,031
  • 17
  • 33
  • 41
9

Changing index.js to index.ts fixed this error for me. (I did not have any .ts files before this).

Note: remember to change anywhere you reference index.js to index.ts except of course, where you reference your main file. By convention this is probably in your lib or dist folders. My tsconfig.json:

{
  "compilerOptions": {
    "target": "es2016",
    "module": "commonjs",
    "outDir": "./dist",
    "strict": true,
    "esModuleInterop": true,
    "inlineSourceMap": true,
    "noImplicitAny": false
  }
}

My outDir is ./dist so I reference my main in my package.json as "main": "dist/index.js"

enter image description here

rose specs
  • 905
  • 8
  • 18
8
"outDir"

Should be different from

"rootDir"

example

    "outDir": "./dist",
    "rootDir": "./src", 
FDisk
  • 8,493
  • 2
  • 47
  • 52
7

You need to have the root index.tsx or index.ts file for the tsc command to work.

Gru
  • 817
  • 13
  • 20
7

The solution that worked for me was to add a ./ before each include path in the config file:

"include": ["./src/**/*.d.ts", "./src/**/*.js", "./src/**/*.svelte"]
Matt Parkins
  • 24,208
  • 8
  • 50
  • 59
5

I added the following in the root ( visual studio )

{
  "compilerOptions": {
    "allowJs": true,
    "noEmit": true,
    "module": "system",
    "noImplicitAny": true,
    "removeComments": true,
    "preserveConstEnums": true,
    "sourceMap": true
  },
  "include": [
    "**/*"
  ],
  "exclude": [
    "assets",
    "node_modules",
    "bower_components",
    "jspm_packages"
  ],
  "typeAcquisition": {
    "enable": true
  }
}
NicoJuicy
  • 3,435
  • 4
  • 40
  • 66
4

Ok, in 2021, with a <project>/src/index.ts file, the following worked for me:

If VS Code complains with No inputs were found in config file... then change the include to…

"include": ["./src/**/*.ts"]

Found the above as a comment of How to Write Node.js Applications in Typescript

Big Rich
  • 5,864
  • 1
  • 40
  • 64
3

When using Visual Studio Code, building the project (i.e. pressing Ctrl + Shift + B), moves your .ts file into the .vscode folder (I don't know why it does this), then generates the TS18003 error. What I did was move my .ts file out of the .vscode folder, back into the root folder and build the project again.

The project built successfully!

  • 1
    it puts the **.tsconfig** file into the .vscode folder. If you move it out of the .vscode folder, you may also need to edit .vscode/tasks.json to point to the new location – duggulous Apr 11 '18 at 16:02
3

add .ts file location in 'include' tag then compile work fine. ex.

"include": [
"wwwroot/**/*" ]
3

I had to add the files item to the tsconfig.json file, like so:

{
    "compilerOptions": {
        "target": "es5",
        "module": "commonjs",
        "sourceMap": true,
    },
    "files": [
        "../MyFile.ts"
    ] 
}

More details here: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html

Cosmin
  • 2,365
  • 2
  • 23
  • 29
3

For anyone experiencing the same error should try adding "node modules" to the exclude options

{
   "compilerOptions": {
     ...
   },
   "include": [
      "./src/**/*.ts"
   ],
   "exclude": [
      "./out.d.ts",
      "node_modules",
   ]
}
Mayor
  • 303
  • 2
  • 7
3

My VSCode was giving me the squiggly line at the beginning of my tsconfig.json file, and had the same error, so

  1. I made sure I had at least one .ts file in the folder specified in the "include" paths (one of the folders in the include path was empty and it was fine)
  2. I simply closed the VSCode and opened it back up, and that fixed it. (sigh..)

My folder structure

    tsconfig.json
    package.json
    bar/
         myfile.ts
    lib/
         (no file)

My tsconfig.json

   "compilerOptions": { ... },
   "include": [
    "bar/**/*",
    "lib/**/*"
   ],
   "exclude": [
    ".webpack/**/*",
    ".vscode/**/*"
   ]
   
il0v3d0g
  • 655
  • 6
  • 14
2

If you don't want TypeScript compilation, disable it in your .csproj file, according to this post.

Just add the following line to your .csproj file:

<TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>
RubbelDieKatz
  • 1,134
  • 1
  • 15
  • 32
2

Add one .ts file to your project root directory (same level as the.tsconfig file).

So in my case, I added one .ts file and named it: main.ts.

And inside my .tsconfig file I included main.ts.

{
  "include": ["src/**/*", "main.ts"]
}
Tri Dawn
  • 540
  • 6
  • 11
  • Adding main.ts was sufficient for me. My initial tsconfig.json file created by `npx tsc --init` doesn't even mention an include field in all its comments, so I live without one currently. Update: Is `rootDir` is the new `include` I wonder? – Will Jun 08 '23 at 08:48
1

Btw, just had the same problem.

If you had my case, then you probably have the tsconfig.json not in the same directory as the .ts file.

(In my case I stupidly had next to launch.json and tasks.json inside the .vscode folder :P)

Tha Brad
  • 148
  • 12
1

I had existing tsconfig files for 4 existing projects in my solution. After upgrading to vs2017 I experienced this problem. It was fixed by adding the (supposedly default) include and exclude sections to the files, as described by NicoJuicy.

Elroy Flynn
  • 3,032
  • 1
  • 24
  • 33
1

You need to have two folders, one for the source (typescript) and another for the output (javascript).

tsconfig.json:

{
  "compilerOptions": {
...
    "outDir": "out/", 
    "rootDir": "src/", 
...
danilo
  • 7,680
  • 7
  • 43
  • 46
  • In my case adding the rootDir attribute worked to get ride of the error. VS2022 + Micorosoft.TypeScript.MSBuild 4.6.4. tsconfig.json in root of ASP.NET Core Web Project. Incude, exclude, typeRoots Attributes where already there and the error kept on comming, until rootDir was added. – Karl Apr 09 '22 at 06:00
1

If you are using VSCode, and you have several folders opened then you need to open the one folder you are working on for it to go away.

Wrong Opening of Folder enter image description here Right Opening of Folder enter image description here

0

I have a tsconfig.json file that doesn't apply to any .ts files. It's in a separate folder. Instead I only use it as a base for other tsconfig files via "extends": "../Configs/tsconfig.json". As soon as I renamed the base config file to something else e.g. base-tsconfig.json (and updated the extends statements) the error went away and the extending still worked.

user764754
  • 3,865
  • 2
  • 39
  • 55
0

I got the same error and in my case it was because vscode couldn't recognize .ts file.

It was seeing it as text file and I had to rename it to remove one letter and add it back to make it work.

Bakhtiiar Muzakparov
  • 2,308
  • 2
  • 15
  • 24
0

I ran into this issue constantly while packing my projects into nugets via Visual Studio 2019. After looking for a solution for ages I seem to have solved this by following advice in this article

MSBuild & Typescript

especially part about <TypeScriptCompile /> where I included all my .ts resources with the Include operator and excluded others such as node_modules with the Remove operator. I then deleted the tsconfig.json file in each offending project and the nuget packages were generated and no more errors

Laurence73
  • 1,182
  • 1
  • 10
  • 14
0

I received this same error when I made a backup copy of the node_modules folder in the same directory. I was in the process of trying to solve a different build error when this occurred. I hope this scenario helps someone. Remove the backup folder and the build will complete.

Soturi
  • 1,486
  • 1
  • 14
  • 30
0

I had the same error because I had this:

"include": [ 
    "wwwroot/ts/*.ts" 
  ],
  "exclude": [ 
    "node_modules",
    "wwwroot"
  ]

The error appear because the folder wwwroot appear in include and exclude, you should quit one of them.

Dharman
  • 30,962
  • 25
  • 85
  • 135
0

I used that How to disable TypeScript compilation in .Net Core projects?

Because I use a template and those packages require for only my template. However I can see every packages' export in their node_module files. If you are in same situation you can use link above

user9399896
  • 27
  • 1
  • 7
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Feb 12 '22 at 17:01
0

For me, the solution was pass the folder to local disc, before i am copy the folder to google drive repository (g:/). When back the copy all work fine.

Mitolo
  • 330
  • 2
  • 8
-1

Make sure all your files has a correct name.