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

8

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 on the above line it runs normal the application, I already tried to include the path in tsconfig.app and tsconfig.spec but did not solve.

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"] on tsconfig.app.json not on compilation error, but the application just keeps loading and no error appears on the console!

    
asked by anonymous 28.02.2018 / 01:56

3 answers

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

    
05.03.2018 / 18:27
1

You've already tried changing the line

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

But it seems like the logic is wrong. Because @Input is a value that the component has to receive or is the input value. I do not remember if you can boot it like this!

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

    
02.03.2018 / 21:19
0

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

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

After this, on your Component on the line where you make 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.

    
05.03.2018 / 12:34