Angular5 - File is missing from the TypeScript compilation
Asked Answered
S

2

9

I have a file.ts file which does not contain a component/service/etc but just a data type.

When I try to compile my program I get this error: Module build failed: Error: my path\File.ts is missing from the TypeScript compilation. Please make sure it is in your tsconfig via the 'files' or 'include' property.

Then I changed my tsconfig.app.json file to contain the include tag:

{
  "extends": "../tsconfig.json",
  "compilerOptions": {
    "outDir": "../out-tsc/app",
    "baseUrl": "./",
    "module": "es2015",
    "types": []
  },
  "include": [
        "**/*.ts"
    ],
  "exclude": [
    "**/*.spec.ts"
  ]
}

as the message suggested, but I got this error:

error TS18003: No inputs were found in config file 'tsconfig.json'. Specified 'include' paths were '["src/**/*.ts"]' and 'exclude' paths were '["**/*.spec.ts"]'.

What am I doing wrong?

Spile answered 21/4, 2018 at 7:59 Comment(8)
add at least one ts file to your app folder to resolve that errorGritty
I already have some files in the app folder: app.component.ts, app.component.css, app.component.html, app.component.spec.ts, app.module.tsSpile
did try include removing .tsGritty
Yes, it didn't help.Spile
"include": [ "src/**/*" ]Gritty
this is what I did...Spile
Let us continue this discussion in chat.Gritty
@ldov i have posted my answer and hope it helped to resolve your issueGritty
G
4

To achieve expected result, use correct path and folder name as everything looks fine

Error mentioned in POST is due to path

Other option is to use files

"files": [ 
"file.ts"]

in tsconfig.json

Check this link for more details- https://github.com/angular/angular/issues/20091

Gritty answered 21/4, 2018 at 18:31 Comment(1)
the error was due to mismatch in the upper-case/lower-case in the import statement and actual folder name :)Spile
P
0

In my case I had my file name was logger.ts however in my spec file I have imported the class with import { Logger } from '../contracts/Logger'; once I corrected the import with proper case sensitive it worked import { Logger } from '../contracts/logger';

Peewit answered 3/3, 2021 at 21:26 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.