Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular5 - File is missing from the TypeScript compilation

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?

like image 534
Idov Avatar asked Apr 21 '18 07:04

Idov


People also ask

What is tsconfig file in Angular?

At the root tsconfig. json file specifies the base TypeScript and Angular compiler options that all projects in the workspace inherit. See the Angular compiler options guide for information about what Angular specific options are available.

Is Angular written in TypeScript?

Angular is a modern framework built entirely in TypeScript, and as a result, using TypeScript with Angular provides a seamless experience. The Angular documentation not only supports TypeScript as a first-class citizen, but uses it as its primary language.

How TypeScript works with Angular?

ts instead of . js is that Angular is written in a superset of JavaScript called TypeScript. TypeScript is the ES6 version of JavaScript plus a few other TypeScript only features which Angular needs in order to work. You can write Angular applications in either TypeScript, ES6 or even ES5 JavaScript.

Does TypeScript require compilation?

TypeScript provides a command-line utility tsc that compiles (transpiles) TypeScript files ( . ts ) into JavaScript. However, the tsc compiler (short for TypeScript compiler) needs a JSON configuration file to look for TypeScript files in the project and generate valid output files at a correct location.


1 Answers

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

like image 162
Naga Sai A Avatar answered Oct 16 '22 03:10

Naga Sai A