Error compiling project Angular 5 " is missing from the TypeScript compilation."

When I try to run the angular server to test the project it fails to compile with the following error:

ERROR in ./src/app/shared/objeto/Venda.ts

Module build failed: Error: F:\Xampp\htdocs\www\Angular\fidaliza\src\app\shared\objeto\Venda.ts is missing from the TypeScript compilation. 

Please make sure it is in your tsconfig via the 'files' or 'include' property.
at AngularCompilerPlugin.getCompiledFile (F:\Xampp\htdocs\www\Angular\fidaliza\node_modules\@ngtools\webpack\src\angular_compiler_plugin.js:674:23)
at plugin.done.then (F:\Xampp\htdocs\www\Angular\fidaliza\node_modules\@ngtools\webpack\src\loader.js:467:39)
at <anonymous>

Everything was working normal until I created this class:

export class Venda {
venda_cliente: string;
venda_loja: string;
venda_cupom: number;
venda_produtos: number;
venda_valor: number;
venda_resgate: number;
venda_dtresgate: string;
resgatar: boolean;
}

The error occurs when this line is executed:

@Input() venda: Venda = new Venda();

When I comment the above line it runs normal the application, I have tried to do the includes of the paths in tsconfig.app and tsconfig.spec but not resolve.

tsconfig.app.json

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

tsconfig.spec.json

{
  "extends": "../tsconfig.json",
  "compilerOptions": {
    "outDir": "../out-tsc/spec",
    "baseUrl": "./",
    "module": "commonjs",
    "target": "es5",
    "types": [
      "jasmine",
      "node"
    ]
  },
  "files": [
    "test.ts"
  ],
  "include": [
    "**/*.spec.ts",
    "**/*.d.ts"
  ]
}

tsconfig.json

{
  "compileOnSave": false,
  "compilerOptions": {
    "outDir": "./dist/out-tsc",
    "sourceMap": true,
    "declaration": false,
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "target": "es5",
    "typeRoots": [
      "node_modules/@types"
    ],
    "lib": [
      "es2017",
      "dom"
    ]
  }
}

resgatar.component.ts

import { Component, OnInit, Input } from '@angular/core';
import { routerTransition } from '../../../router.animations';
import { ClientesService } from '../../../shared/services   /clientes.service';
import { VendasService } from '../../../shared/services/vendas.service';
import { Cliente } from '../../../shared/objeto/cliente';
import { Venda } from '../../../shared/objeto/Venda';
import { FormBuilder, FormGroup } from '@angular/forms';

@Component({
  selector: 'app-resgatar',
  templateUrl: './resgatar.component.html',
  styleUrls: ['./resgatar.component.scss'],
  animations: [routerTransition()],
})
export class ResgatarComponent implements OnInit {
  @Input() venda: Venda = new Venda();
{restante da classe acho que não é util pois só tem funções de botões}

When I did this include "include: ["**/*.d.ts"] in tsconfig.app.json no error in the compilation, but the application it is just loading and does not appear any error in the console!

Author: Hebert Lima, 2018-02-28

3 answers

I discovered the problem, import { Venda } from '@app/shared/objeto/Venda'; the V uppercase, looking at the code I have an include of another classe in that same component import { Cliente } from '../../../shared/objeto/cliente'; I realized it was in lowcase, so I changed the import from Venda to venda, compiled normal. my stupidity=)

 5
Author: Hebert Lima, 2018-03-05 17:27:59

Have you tried to change the line

@Input() venda: Venda = new Venda();  para @Input() venda = new Venda();

But it seems that the logic ta wrong. Because @Input is a value that the component has to receive or be input value. I don't remember if you can boot it like that!

It can be initialized, but as you ta saying that it is of Type sale then have to be careful as it is an input property what will come has to be an object of type sale if not of the error. Try to take the :Venda and leave only sale = new Venda();

 2
Author: Paulo Rodolfo, 2018-03-05 20:20:38

Go to your file tsconfig.json and add the following property inside Property "compilerOptions":

"paths": {
    "@app/*": ["app/*"]
}

After that, in your Component in the row where you do the import of Class Venda change to:

import { Venda } from '@app/shared/objeto/Venda';

I believe your error is in import, so this should fix it.

 0
Author: Marcus Hert da Coregio, 2018-03-05 20:03:29